class Sprite
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
alias angle_initialize initialize
def initialize(viewport = nil)
angle_initialize
init_rotate
end
#--------------------------------------------------------------------------
# ● 初始化旋转角度和速度
#--------------------------------------------------------------------------
def init_rotate
self.angle = 0
@rotate_speed = 0
end
#--------------------------------------------------------------------------
# ● 更改旋转速度
#--------------------------------------------------------------------------
def rotate(speed)
@rotate_speed = speed
end
#--------------------------------------------------------------------------
# ● 更新旋转
#--------------------------------------------------------------------------
def update_rotate
return if @rotate_speed == 0
self.angle += @rotate_speed / 2.0
self.angle += 360 while self.angle < 0
self.angle %= 360
end
end
class Scene_Anglepictrue < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
@speed = 0
@last_time = 750
end
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
#生成各种图像精灵#
@anglepictrue = Sprite.new
@anglepictrue.bitmap = Cache.picture("转盘")
@anglepictrue.x = 272
@anglepictrue.y = 208
@anglepictrue.z = 99
@anglepictrue.ox = @anglepictrue.bitmap.width / 2
@anglepictrue.oy = @anglepictrue.bitmap.height / 2
@cut = Sprite.new
@cut.bitmap = Cache.picture("转盘指针")
@cut.z = 999
@cut.x = 272
@cut.y = 208
@cut.ox = @cut.bitmap.width / 2
@cut.oy = @cut.bitmap.height / 2
end
#--------------------------------------------------------------------------
# ●刷新
#--------------------------------------------------------------------------
def update
super
anglepic
#@cut.rotate(@speed)
end
#--------------------------------------------------------------------------
# ●旋转过程
#--------------------------------------------------------------------------
def anglepic
loop do
@cut.rotate(@speed)
@speed -= 1 if @speed > -50 && @last_time > 0
@speed += 1 if @speed < 0 && @last_time == 0 && ![0,90,180,270].include?(@cut.angle.round)
@last_time = 0 if Input.press?(:C) && @speed == -50
if @speed == 0
break
end
end
go_event
dispose_pictrue
end
#--------------------------------------------------------------------------
# ●执行公共事件
#--------------------------------------------------------------------------
def go_event
case @cut.angle.round
when 1..89
$game_temp.common_event_id = 31
when 91..179
$game_temp.common_event_id = 32
when 181..269
$game_temp.common_event_id = 33
when 271..359
$game_temp.common_event_id = 34
end
end
#--------------------------------------------------------------------------
# ●消除图片
#--------------------------------------------------------------------------
def dispose_pictrue
@anglepictrue.dispose
@cut.dispose
end
end