More About Actions

Tweaking Actions

Actions have a few methods that allow you to tweak how they work. You can change an action's easing function using the SetEase() method, as in the following example:

moveAction.SetEase(PRActionEaseQuadraticOut)

The above command changes the ease equation used for the action found in the moveAction variable to PRActionEaseQuadraticOut.

Actions also have 2 data parameters that certain action types and easing equations use to tweak their effect. To change those data values, use the following methods:

moveAction.SetData1(effectTweakValue)
moveAction.SetData2(limitValue)

Timed Actions vs Instant Actions

All of the action creation functions found in the cPRActionStandardActions script asset return actions that take time execute. You specify how much time (in seconds) they take to execute when you create the action. On the other hand, there are a set of functions found in the cPRActionInstantActions script asset that creates instant actions. These actions do not animate over time and are executed immediately. These are typically one-shot actions that perform a specific duty as as calling a function or playing a sound effect. You can embed these actions within your compound actions to trigger things to happen. For example:

var jumpAction = PRActionCreateSequence(
    
PRActionCreatePlaySound(jumpSound), // Play jump sound effect
    
moveUpAction,
    
moveDownAction,
    
PRActionCreateCallFunction(JumpCompleted) // Run function when jump action is complete.
)

The above example creates an action that includes an instant action to play a sound effect, then two timed actions that move the object up and then down, and then finally one more instant action that calls a function as the last step. There are many instant action creation functions included in this module for you, including actions that change the object's sprite, depth and layer, hide and unhide objects, call functions and run user events, trigger other actions to play and more.


© 2021 Prismatic Realms, Inc. Contact

Green Hosting Badge