module Math
def self.f(x)
return self.f(x+1) if x < 0
return self.f(x-1) if x > 2
(x-1)**2
end
end
class Window_Base
#--------------------------------------------------------------------------
# ● 移动到
#--------------------------------------------------------------------------
def move_to(x, y,duration, opa=nil)
@old_x = self.x
@old_y = self.y
@target_x = (x ? x : self.x)
@target_y = (y ? y : self.y)
@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.opacity = @old_opa + (@target_opa - @old_opa)*var if @target_opa
self.contents_opacity = self.opacity
false
end
end