RPG ツクール XP (ruby で作成) で動画を表示できるアニメーション スクリプトを作成しています。ここでの私の質問は厳密には RPG ツクールに関するものではなく、一般的な用語です。これは私がこれまでに見つけたコードであり、動作しますが、問題があります:
class Poser
attr_accessor :images
def initialize
@images = Sprite.new
@images.bitmap = RPG::Cache.picture('Character.png') #display picture
@images.x = 540 #place it on the bottom right corner of the screen
@images.y = 180
end
def move(x,y)
@images.x += x
@images.y += y
end
def animate(x,y,step,delay) #Animate moving the picture up and down with delay
forward = true
2.times { #the first loop, do code 2 times of :
step.times {
wait(delay) #wait x frame
if forward
move(x/step,y/step) #move the picture down
else
move(-x/step,-y/step) #move the picture up
end
}
wait(delay*3)
forward = false
}
end
def wait(time)
while time > 0
time -= 1
Graphics.update
end
end
end
次に、そのインスタンスを作成し、メソッドを呼び出します。
$test = Poser.new
$test.animate(0,10,10,10)
上記のコードが行うことは、画像を上下に移動することです (呼吸アニメーションのように、頭が上下に揺れます)。
ご覧のとおり、ループ関数を使用して画像を遅延させて移動しています。私が得たのは、アニメーションが終了するまで他に何もできないということです. 「その他」とは、キャラクターと一緒に歩き回ったり、NPC に話しかけたり、バックグラウンドでアニメーションが再生されている間にこれらのことを行いたいということです。結局、ゲームはループブロックで「一時停止」しました。
ループせずにアニメーションを行う別の方法、またはアニメーションが終了するまで画面を「一時停止」しない方法はありますか? 前もって感謝します。