PDA

Просмотр полной версии : Движок Flixel - функция addAnimation()


Dmitron
10.09.2012, 11:51
Доброго дня!
Проясните пожалуйста работу функции. имеем код:

[Embed(source="alien.png")] private var ImgAlien:Class; //The graphic of the squid monster
loadGraphic(ImgAlien,true); //Load this animated graphic file
addAnimation("Default",[0,1,0,2],6+FlxG.random()*4);
//Time to create a simple animation! alien.png has 3 frames of animation in it.
//We want to play them in the order 1, 2, 3, 1 (but of course this stuff is 0-index).
//To avoid a weird, annoying appearance the framerate is randomized a little bit
// to a value between 6 and 10 (6+4) frames per second.
play("Default");

код использует картинку 46х16 пикселей
http://uselect-web.ucoz.com/temp/alien.png
и выделяет в ней 3 фрэйма

Формат png не поддерживает анимацию.

Как движок разделяет кадры?

Dmitron
11.09.2012, 12:39
картинка 46х16 пикселей
http://uselect-web.ucoz.com/temp/alien.png

NikolyA
11.09.2012, 13:58
Dmitron а коментарии в коде что говорят? или ты хочешь чтоб тебе перевели?

Dmitron
12.09.2012, 11:22
//Time to create a simple animation! alien.png has 3 frames of animation in it.
Пора сделать простую анимацию! В alien.png - 3 кадра.
//We want to play them in the order 1, 2, 3, 1 (but of course this stuff is 0-index).
Мы хотим их проигрывать в порядке 1,2,3,1 (индекс первого кадра конечно же 0)
//To avoid a weird, annoying appearance the framerate is randomized a little bit
разнообразим движение
// to a value between 6 and 10 (6+4) frames per second.
от 6 до 10 кадров в секунду

Мой вопрос: как к этим трём кадрам дорисовать ещё 10?

maxkar
12.09.2012, 11:35
А код Flixel'а смотреть не пробовали? Там все просто и понятно.