#encoding:utf-8 #============================================================================== # ■ Scene_Test #------------------------------------------------------------------------------ # 插入战斗场景的 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 准备 #-------------------------------------------------------------------------- def prepare(data) @data=data @time_max=data.size * 60 @time=data.size * 60 end #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super # * 逻辑数据初始化 @index=0 # * 渲染部分初始化 #背景 create_background # 时间条精灵 @sp_time = Sprite.new @sp_time.x = (Graphics.width-300)/2 @sp_time.y = 60 @sp_time.z = 5000 @sp_time.bitmap = Bitmap.new(300,20) #时间条皮肤 @sp_time_skin = Sprite.new @sp_time_skin.x = @sp_time.x - 10 @sp_time_skin.y = @sp_time.y @sp_time_skin.z = @sp_time.z + 1 @sp_time_skin.bitmap = Bitmap.new("Graphics/System/jindutiao") # 字母精灵组 @data=[] if @data.nil? @sp_data=[] @data.size.times{|i| @sp_data[i]=Sprite.new @sp_data[i].x=(Graphics.width-400)/2+i*32 @sp_data[i].y=100 @sp_data[i].bitmap=Bitmap.new(32,35) @sp_data[i].bitmap.draw_text(0,0,50,50,@data[i],1) @sp_data[i].z=500 } # 指针精灵 @sp_index=Sprite.new @sp_index.x=80 @sp_index.y=150 @sp_index.z=500 @sp_index.bitmap=Bitmap.new("Graphics/System/zhizhen") # @sp_index.bitmap.fill_rect(0,0,50,50,Color.new(255,0,0)) end #-------------------------------------------------------------------------- # ● 生成背景 #-------------------------------------------------------------------------- def create_background @background_sprite = Sprite.new @background_sprite.bitmap = SceneManager.background_bitmap @background_sprite.color.set(16, 16, 16, 64) end #------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- alias :old_update :update def update old_update # 判断按键 # 循环判断所有键是否被按下 Kboard::KEYS.each{|k,v| if Kboard.keyboard(v)# 如果有键被按下 if v==Kboard::KEYS[@data[@index]]#判断是否是正确的 @index+=1 else @index=0 end end } [url=home.php?mod=space&uid=134219]@Time[/url] -= 1 # 一秒-60 # 判断超时 $game_switches[1] = true if @index == @data.size return_scene if @index >= @data.size return_scene if @time <= 0 # 渲染刷新 # 时间 rate = @time.to_f / @time_max #p rate @sp_time.bitmap.fill_rect(0,0,300,30,Color.new(255,0,255)) @sp_time.bitmap.fill_rect(0,0,300*rate,30,Color.new(0,255,255)) # 指针 #@sp_data.x= @sp_data.x - @index*32 @sp_index.x=(Graphics.width-400)/2+[@index,@data.size-1].min*32 + 8 # 刷新一下 @sp_time.update @sp_index.update @sp_data.each{|i|i.update} end end
错.png (2.13 KB, 下载次数: 20)
1.43 MB, 下载次数: 65
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |