#encoding:utf-8
#==============================================================================
# ■ Sprite
#------------------------------------------------------------------------------
# RGSS
#==============================================================================
class Sprite
#--------------------------------------------------------------------------
# ● 移动到
#--------------------------------------------------------------------------
def move_to(x, y, zoom, duration, opa=nil)
@old_x = self.x
@old_y = self.y
@target_x = (x ? x : self.x)
@target_y = (y ? y : self.y)
@old_zoom = self.zoom_x
@target_zoom = (zoom ? zoom : self.zoom_x)
@target_opa = (opa ? opa : @target_opa)
@old_opa = self.opacity
@duration = duration
@duration_full = duration.to_f
end
#--------------------------------------------------------------------------
# ● 刷新移动
#--------------------------------------------------------------------------
def move_update
return true if @duration.nil? or @duration <= 0
@duration -= 1
var = 1-Math.f(@duration/@duration_full+1)
self.x = (@old_x + (@target_x-@old_x) *var+0.5).to_i
self.y = (@old_y + (@target_y-@old_y) *var+0.5).to_i
self.zoom_x = @old_zoom + (@target_zoom-@old_zoom) *var
self.zoom_y = self.zoom_x
self.opacity = (@old_opa + (@target_opa - @old_opa)*var+0.5).to_i if @target_opa
false
end
end
def Math.f(x)
return self.f(x+2) if x < 0
return self.f(x-2) if x >= 2
(x-1)**2
end