Project1
标题:
关于代码的优化
[打印本页]
作者:
退屈£无聊
时间:
2010-8-29 20:13
标题:
关于代码的优化
求简化,或者给个并行等待的代码 - - 就是说如果这个脚本中等待,但动画剧情什么的还是继续走 - -
@pic1.visible = true
2.times{ Graphics.update }
@pic1.visible =false
@pic2.visible = true
2.times{ Graphics.update }
@pic2.visible = false
@pic3.visible = true
2.times{ Graphics.update }
@pic3.visible =false
@pic4.visible = true
2.times{ Graphics.update }
@pic4.visible =false
@pic5.visible = true
2.times{ Graphics.update }
@pic5.visible =false
@pic6.visible = true
2.times{ Graphics.update }
@pic6.visible =false
@pic7.visible = true
2.times{ Graphics.update }
@pic7.visible =false
@pic8.visible = true
2.times{ Graphics.update }
@pic8.visible =false
@pic9.visible = true
2.times{ Graphics.update }
@pic9.visible = false
复制代码
作者:
菜鸟飞呀飞
时间:
2010-8-29 20:44
提示:
作者被禁止或删除 内容自动屏蔽
作者:
后知后觉
时间:
2010-8-29 22:45
这个是像你那样更改不同的 sprite?window? 的 visible
class Abc
def initialize
@sprites = []
for i in 0..9
sprite = Sprite.new
sprite.visible = false
sprite.z = 6000
sprite.y = 448
sprite.bitmap = Bitmap.new(640, 32)
sprite.bitmap.fill_rect(0,0,640,32,Color.new(i*30+15,255,0,(5-i).abs*50+5))
@sprites.push(sprite)
end
@wait_count = 3
@src_index = 0
@sprites[@src_index].visible = true
end
def update
@sprites[@src_index].update
if @wait_count > 0
@wait_count -= 1
return
end
@sprites[@src_index].visible = false
@wait_count = 3
@src_index += 1
@src_index %= @sprites.size
@sprites[@src_index].visible = true
return
end
def dispose
for sprite in @sprites
sprite.bitmap.dispose
sprite.dispose
end
end
end
class Scene_Map
alias old_main main
def main
@abc = Abc.new
old_main
@abc.dispose
end
alias old_update update
def update
@abc.update
old_update
end
end
复制代码
.
.这个是 只使用一个 sprite 不停的改变他的 bitmap
$__logo_jump__.call if $__logo_jump__
class Sprite_Logo < Sprite
def initialize
super
self.x = 512
self.z = 10000
self.visible = true
@bitmaps = Array.new
for i in 0..9
r = (5 - i).abs * 50 + 5
g = 255
b = 255 - (5 - i).abs * 50 + 5
a = (5 - i).abs * 50 + 5
clr = Color.new(r, g, b, a)
bmp = Bitmap.new(128, 32)
bmp.font.color = clr
bmp.font.bold = true
bmp.draw_text(0, 0, 128, 32, "66RPG", 1)
@bitmaps.push(bmp)
end
@src_index = 0
self.bitmap = @bitmaps[@src_index]
@wait_count = 3
end
def update
super
if @wait_count > 0
@wait_count -= 1
return
end
@wait_count = 3
@src_index += 1
@src_index %= @bitmaps.size
self.bitmap = @bitmaps[@src_index]
return
end
def dispose
for bitmap in @bitmaps
bitmap.dispose
end
super
end
end
module Kernel
alias old_exit exit
def exit(*args)
$logo.dispose
old_exit(*args)
end
end
class << Graphics
alias old_update update
def update
old_update
$logo.update
end
end
$logo = Sprite_Logo.new
callcc{|$__logo_jump__|}
复制代码
当然啦,这2个脚本其实是一个原理.
我做的是无限的循环.不知道你是不是要的这种动画的效果.
这2个脚本可以同时运行.放到新工程里看看吧.
作者:
fux2
时间:
2010-8-30 07:42
回复
退屈£无聊
的帖子
啊,我脚本里写等待也完全失效……
作者:
IamI
时间:
2010-8-30 07:45
for i in 0..9
g = eval("@pic#{i}")
g.visible = true
Graphics.update
Graphics.update
g.visible = false
end
复制代码
方法有危险,使用需谨慎= =b
作者:
退屈£无聊
时间:
2010-8-30 09:13
我用用看吧
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1