加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 沙漠点灰 于 2013-1-22 10:52 编辑
以前控制精灵不透明度用变量控制(控制不透明度渐变方向),例如我的标题只有"New Game","Continue"两个精灵,一个选择框,代码可写为下:
# 更新精灵坐标 if @old_index != @command_window.index @sprite_chooser.y = @command_window.index == 0 ? 308 : 353 @old_index = @command_window.index @sprite_count = SpriteCount end # 渐变精灵 if @sprite_count > 0 @sprite_new_game.opacity = Math.sin((@sprite_count.to_f/SpriteCount+[1,0][@command_window.index])*Math::PI/2)*255 @sprite_continue.opacity = Math.sin((@sprite_count.to_f/SpriteCount+[0,1][@command_window.index])*Math::PI/2)*255 @sprite_count -= 1 end
# 更新精灵坐标
if @old_index != @command_window.index
@sprite_chooser.y = @command_window.index == 0 ? 308 : 353
@old_index = @command_window.index
@sprite_count = SpriteCount
end
# 渐变精灵
if @sprite_count > 0
@sprite_new_game.opacity = Math.sin((@sprite_count.to_f/SpriteCount+[1,0][@command_window.index])*Math::PI/2)*255
@sprite_continue.opacity = Math.sin((@sprite_count.to_f/SpriteCount+[0,1][@command_window.index])*Math::PI/2)*255
@sprite_count -= 1
end
简化了代码而已.... |