当然可以,需要你定义一个rotate_effect,这个旋转效果是指定一个速度然后永远旋转下去,如果想要改成旋转一个固定角度则和前面的move_effect类似。
def rotate_effect(speed) @rotate_speed = speed if @rotate_speed == 0 @rotate_effect = false return end @rotate_effect = true end def rotating? return @rotate_effect end
def rotate_effect(speed)
@rotate_speed = speed
if @rotate_speed == 0
@rotate_effect = false
return
end
@rotate_effect = true
end
def rotating?
return @rotate_effect
end
然后你需要自己定义update
def update if self.rotating? self.angle += @rotate_speed end end
def update
if self.rotating?
self.angle += @rotate_speed
end
end
代码未测试,可能有BUG,遇到笔误等问题请自行修改。 |