加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
想在标题做个荧光缓慢飘起或者散开的效果,然后自己糊了一下代码之后再TITLE里调用UPDATE,发现虽然没有报错但是一点效果都没有。
class Fire_Flies < Sprite def initialize(type)#rise:1 spread :2 super(nil) @xadd_count = 0.0 @yadd_count = 0.0 @oadd_count = 0.0 @life = 300 - rand(100) @during = 0 @type = type case @type when 1 @aim = [0,rand(30)+100] @speed_x = 0.0#f @speed_y = @aim[1].to_f/@life#f x = rand(640) hue = rand(360) zoom = rand(0) self.bitmap = Bitmap.new("Graphics/Pictures/fireflies.png") self.ox = self.bitmap.width/2 self.oy = 0 self.opacity = 250 self.bitmap.hue_change(hue) self.x = x self.y = 480 self.zoom_x = zoom self.zoom_y = zoom when 2 @aim = [rand(30)+50,rand(30)+50] @speed_x = @aim[0].to_f/@life#f @speed_y = @aim[1].to_f/@life#f zoom = rand(0) self.bitmap = Bitmap.new("Graphics/Pictures/fireflies.png") self.ox = self.bitmap.width/2 self.oy = self.bitmap.height/2 self.opacity = 1 self.x = Graphics.width/2 self.y = Graphics.width/2 self.zoom_x = zoom self.zoom_y = zoom end end def fireflies_update @xadd_count += @speed_x @yadd_count += @speed_y @oadd_count += 250.0/@life if @xadd_count >= 1 self.x += @xadd_count @xadd_count -= 1 end if @yadd_count >= 1 self.x += @yadd_count @yadd_count -= 1 end if @oadd_count >= 1 if @during < @life / 3 and @type == 2 self.opacity += @oadd_count else self.opacity -= @oadd_count end @oadd_count -= 1 end @during += 1 self.dispose if @during == @life end end
class Fire_Flies < Sprite
def initialize(type)#rise:1 spread :2
super(nil)
@xadd_count = 0.0
@yadd_count = 0.0
@oadd_count = 0.0
@life = 300 - rand(100)
@during = 0
@type = type
case @type
when 1
@aim = [0,rand(30)+100]
@speed_x = 0.0#f
@speed_y = @aim[1].to_f/@life#f
x = rand(640)
hue = rand(360)
zoom = rand(0)
self.bitmap = Bitmap.new("Graphics/Pictures/fireflies.png")
self.ox = self.bitmap.width/2
self.oy = 0
self.opacity = 250
self.bitmap.hue_change(hue)
self.x = x
self.y = 480
self.zoom_x = zoom
self.zoom_y = zoom
when 2
@aim = [rand(30)+50,rand(30)+50]
@speed_x = @aim[0].to_f/@life#f
@speed_y = @aim[1].to_f/@life#f
zoom = rand(0)
self.bitmap = Bitmap.new("Graphics/Pictures/fireflies.png")
self.ox = self.bitmap.width/2
self.oy = self.bitmap.height/2
self.opacity = 1
self.x = Graphics.width/2
self.y = Graphics.width/2
self.zoom_x = zoom
self.zoom_y = zoom
end
end
def fireflies_update
@xadd_count += @speed_x
@yadd_count += @speed_y
@oadd_count += 250.0/@life
if @xadd_count >= 1
self.x += @xadd_count
@xadd_count -= 1
end
if @yadd_count >= 1
self.x += @yadd_count
@yadd_count -= 1
end
if @oadd_count >= 1
if @during < @life / 3 and @type == 2
self.opacity += @oadd_count
else
self.opacity -= @oadd_count
end
@oadd_count -= 1
end
@during += 1
self.dispose if @during == @life
end
end
在update里大概是这样调用的(自己删掉了……)
if rand(50) == 10
@light_list.push(Fireflies.new(1))#(初始化好了的)
end
for i in @light_list
i.fireflies_update
end
没有任何效果…………这是怎么回事? |