Game Development Reference
In-Depth Information
Adding states
Adding states to our ASM will take in the required information in order to create a new an-
imation state and assign the relevant information directly. We call ClearAnimation on
the passed-in animation to make sure that it is in a known state.
Assigning the state to the ASM is done based on the state's name. This ensures the unique
naming of states. As we will be interacting with an ASM through state names, this unique-
ness is important:
Sandbox.lua :
function AnimationStateMachine.AddState(
self, name, animation, looping, rate)
local state = AnimationState.new();
state.name_ = name;
state.animation_ = animation;
state.rate_ = rate or state.rate_;
state.looping_ = looping or state.looping_;
self.states_[name] = state;
ClearAnimation(animation);
Animation.SetLooping(animation, state.looping_);
end
Search WWH ::




Custom Search