Note: This PRAction documentation is out-dated and is for an older (pre-GMS v2.3) version of PRAction. For the most up-to-date docs on the latest version of PRAction, please refer to this page as well as the documentation included in the PRAction package.

Documentation Topics
Article

Creating and Playing Actions

Actions are the backbone of the PRAction extension. The basic idea is that you will first create actions that your objects will play, and then you will instruct your objects to play those actions.

For example, say that you want an object to move from it's current position in the room to the center of the room. First you’ll create the action that will move the object to the desired location:

var move = PRActionMoveTo(room_width/2, room_height/2, PRActionEaseIdLinear, 1);

Then you'll tell the object to play that action:

PRActionPlay(self, move);

And that's it! You will find that the above code moves the object to the center of the room, in a linear fashion and that the movement will take 1 second to perform.

Now, what if you wanted that object to perform a 360 degree rotation on its way to the center of the room? No problem, just add the following code to the above:

var rotate = PRActionRotateBy(360, PRActionEaseIdLinear, 1);
PRActionPlay(self, rotate);

Yes, you can run multiple actions on any given object and they will all play without interfering with each other. When the actions are done playing, they will stop themselves automatically.

If you need an action to move slower or faster, increase or decrease the duration of the action when you create it:

var rotateFaster = PRActionRotateBy(360, PRActionEaseIdLinear, 0.5);

You may want to animate an action using a more interesting motion than a simple, even, linear type of motion. Do so by specifying a different ease id for the action:

var moveInterestingly = PRActionMoveTo(room_width/2, room_height/2, PRActionEaseIdCubicInOut, 1);

There are lots of of different ease id's built into PRAction to use. Please see the list of available ease id constants found in the Constants topic of these documentation pages.

Another key point to understand is that actions are reusable. So, depending on what you need those actions for, you can certainly create an action once at game launch and play that action over and over on multiple objects throughout the life of your game. Thus, you can do the following:

PRActionPlay(object1, rotate);
PRActionPlay(object2, rotate);
PRActionPlay(object3, rotate);

There are many more standard actions available in the PRAction extension that will animate your objects in various ways than simply moving them across the screen and rotating them. There are actions to scale objects, fade them, hide and show them, change their animation speed, their depth and lots more.

But that's just the beginning! You will start to see the real power of PRAction when creating more complex animations by combining actions together using sequences and groups, and integrating repeating actions and waiting actions. Please read the next document to start delving into compound actions. You'll be creating cut-scenes, and much, much more in no time flat!

Also, please see a list of all available action creation functions under the Functions topic.