=begin ■スプライトムーブ RGSS2 DAIpage■ v1.0 ●機能と使い方●  Spriteクラスに移動用のメソッドを追加します。主に開発用。 ●追加されるメソッド● ----------------------------------------------------------------- move(duration, x, y[, opacity[, zoom_x[, zoom_y]]]) # スプライトの座標をdurationで指定したフレームをかけて x, yで指定した座標へ移動します。不透明度や拡大率も指定できます。 ----------------------------------------------------------------- start_tone_change(tone, duration) # スプライトのトーンをdurationで指定したフレームをかけて toneに変更します。 ----------------------------------------------------------------- moving? # スプライトが移動中、またはトーン変更中かを返します。 ----------------------------------------------------------------- ●更新履歴●  10/10/06:公開 =end #============================================================================== # ■ Sprite #============================================================================== class Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias DAI_move_initialize initialize unless $@ def initialize(viewport=nil) DAI_move_initialize(viewport) @duration = 0 @target_x = self.x @target_y = self.y @target_zoom_x = self.zoom_x @target_zoom_y = self.zoom_y @target_opacity = self.opacity @tone_target = Tone.new(0, 0, 0, 0) @tone_duration = 0 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias DAI_move_update update unless $@ def update move_update self.DAI_move_update end #-------------------------------------------------------------------------- # ● 移動中判定 #-------------------------------------------------------------------------- def moving? return (@duration >= 1 or @tone_duration >= 1) end #-------------------------------------------------------------------------- # ● 移動 # duration : 時間 # x : X 座標 # y : Y 座標 # opacity : 不透明度 # zoom_x : X 方向拡大率 # zoom_y : Y 方向拡大率 #-------------------------------------------------------------------------- def move(duration, x, y, opacity=self.opacity, zoom_x=self.zoom_x, zoom_y=self.zoom_y) @target_x = x.to_f @target_y = y.to_f @target_zoom_x = zoom_x.to_f @target_zoom_y = zoom_y.to_f @target_opacity = opacity.to_f @duration = duration end #-------------------------------------------------------------------------- # ● 色調変更の開始 # tone : 色調 # duration : 時間 #-------------------------------------------------------------------------- def start_tone_change(tone, duration) @tone_target = tone.clone @tone_duration = duration if @tone_duration == 0 self.tone = @tone_target.clone end end #-------------------------------------------------------------------------- # ● 自動移動の更新 #-------------------------------------------------------------------------- def move_update if @duration >= 1 d = @duration self.x = get_move_pos(self.x, @target_x, d).round self.y = get_move_pos(self.y, @target_y, d).round self.zoom_x = get_move_pos(self.zoom_x, @target_zoom_x, d) self.zoom_y = get_move_pos(self.zoom_y, @target_zoom_y, d) self.opacity = get_move_pos(self.opacity, @target_opacity, d).round @duration -= 1 end if @tone_duration >= 1 d = @tone_duration self.tone.red = get_move_pos(self.tone.red, @tone_target.red, d).round self.tone.green = get_move_pos(self.tone.green, @tone_target.green, d).round self.tone.blue = get_move_pos(self.tone.blue, @tone_target.blue, d).round self.tone.gray = get_move_pos(self.tone.gray, @tone_target.gray, d).round @tone_duration -= 1 end end #-------------------------------------------------------------------------- # ● 移動用座標取得 #-------------------------------------------------------------------------- def get_move_pos(n, t, d) return (n * (d - 1) + t) / d end end