我正在嘗試為自訂普利茅斯靴主題製作圖像動畫。我可以讓物件以像素增量移動,但它的更新速度不夠快,無法平滑。我不太明白以特定幀間隔刷新螢幕的技巧。我的程式碼如下所示:
wallpaper_image = Image("Win95.png");
plane_image = Image("paperairplaneShadow.png");
screen_width = Window.GetWidth();
screen_height = Window.GetHeight();
resized_wallpaper_image = wallpaper_image.Scale(screen_width,screen_height);
plane_sprite = Sprite(plane_image);
wallpaper_sprite = Sprite(resized_wallpaper_image);
wallpaper_sprite.SetZ(-100);
progress=0;
fun refresh_callback ()
{
for (i = 0; i < 4; i++){
plane_images[i] = Image("paperairplaneShadow" + i + ".png");
plane_sprite = Sprite();
}
plane_sprite.SetImage(plane_images[Math.Int(progress/6) % 4]);
//plane_sprite.SetImage(plane_images[]);
plane_sprite.SetX(progress);
//plane_sprite.SetY(progress);
progress++;
}
Plymouth.SetUpdateStatusFunction(refresh_callback);
我正在關注教程http://brej.org/blog/?p=197。我無法弄清楚幀速率變化是如何運作的:
butterfly_sprite.SetImage(butterfly_images[Math.Int(progress / 6) % 4]);
該網站表示,它應該每 6 幀將下一張圖像放入蝴蝶.sprite 陣列(有 4 個圖像)中。在我的腳本中,plane_sprite 將會更新,但大約每秒更新一次。任何幫助將不勝感激。