Game Development Reference
In-Depth Information
Creating helper functions
With our basic data structures out of the way, we need some helper functions to deal with
animations. The ClearAnimation InitializeAnimation and StepAnima-
tion functions will help when we need to transition to new states so that animations are in
an expected enabled/disabled state. The StepAnimation function is slightly different and
provides a means of handling the rate of animation playback.
Sandbox.lua :
local function ClearAnimation(animation)
Animation.SetEnabled(animation, false);
end
local function InitializeAnimation(animation, startTime)
Animation.Reset(animation);
Animation.SetEnabled(animation, true);
Animation.SetWeight(animation, 1);
if (startTime ~= nil) then
Animation.SetTime(animation, startTime);
end
end
local function StepAnimation(animation, deltaTimeInMillis,
rate)
rate = rate or 1;
Animation.StepAnimation(
animation, deltaTimeInMillis * rate);
end
Search WWH ::




Custom Search