Game Development Reference
In-Depth Information
with the value of the curve at that time index. A time index is another way of looking at the
animation, but instead of it being index based, we set the time index to specify the animation/
transform at that point in time.
anim = MOAIAnim:new()
anim:reserveLinks(1)
anim:setLink(1, curve, prop1, MOAIProp2D.ATTR_INDEX)
anim:setMode(MOAITimer.LOOP)
anim:start()
We use the MOAIAnim class to create our animation. We set up a link between prop1 and curve on the
Index attribute. We set the mode to loop as a timer. Then we start the animation with the start function.
prop1 object on the screen at 100,100.
MOAITimer.EVENT_TIMER_KEYFRAME . This is called every time the keyframe
is changed and is a callback function that has the following signature:
onKeyFrame ( MOAITimer_self, number_keyFrame, number_timesExecuted, number_time,
number_value)
MOAITimer.EVENT_TIMER_LOOP . This is called every time the function loops
and has the following callback signature:
onLoop(MOAITimer_self, number_timesExecuted)
MOAITimer.EVENT_TIMER_BEGIN_SPAN . This is called when the timer playback
mode reaches the beginSpan time set using the setSpan function;
otherwise this is 0 (i.e. as soon as the animation starts). This has the
following callback signature:
onBeginSpan(MOAITimer_self, number_timesExecuted)
MOAITimer.EVENT_TIMER_END_SPAN . This is called when the timer playback
reaches the endSpan time set using the setSpan function otherwise this
is set to the end of the animation. This has the following callback
signature:
onEndSpan(MOAITimer_self, number_timesExecuted)
Here's an example of using the MOAITimer.EVENT_TIMER_KEYFRAME listener:
function onKeyFrame(self, index, time, value)
print("Keyframe : ", index, time, value)
end
anim:setListener(MOAITimer.EVENT_TIMER_KEYFRAME, onKeyFrame)
Search WWH ::




Custom Search