GameSalad

GameSalad

Rank: ?
points: ?

Behaviors are actions that you can assign to actors to control how they interact, move, and change appearance. Behaviors are used to add logic to your game to control what happens when some event occurs (such as when an actor collides with an object), to make the actor take some action (such as changing its speed) or to change an actor's appearance, such as its size, image, color, or transparency. There are three types of behaviors:

  • rules: these can be used when you want a certain behavior to take place only under specific conditions. For example, you may have a rule that says when a specific actor is clicked, then show this prompt. These are indicated by a [G] next to the behavior name.
  • persistent behaviors: behaviors that continue to act on an actor continuously (unless placed in a rule whose conditions are no longer true). These are indicated by a [B] next to the behavior name.
  • action behaviors: behaviors that occur once, and only repeat themselves if placed in a rule whose conditions become false, and then true again. These are indicated by an [A] next to the behavior name.

In this tutorial we’ll go through each of the Behaviors; later tutorials will provide additional details on specific Behaviors that are used more often. There are currently 36 Behaviors; we’ve grouped them by use for your reference. You can also see each of these behaviors listed in our glossary.

Accelerate: “Use Accelerate to specify the rate and direction of acceleration for an actor. If the drag attribute or gravity is not also applied to an actor, acceleration will be continuously applied, increasing the actor’s speed until it reaches the maximum defined speed, if any. See also the “Accelerate Toward” behavior.”

Accelerate Toward: “Use Accelerate Toward to specify the rate of acceleration and the targeted location of an actor. Use the expression editor to specify a static or moving target position. If the drag attribute or gravity is not also applied to an actor, acceleration will be continuously applied, increasing the actor’s speed until it reaches the maximum defined speed, if any. The actor will continue accelerating past the target location along the existing trajectory unless slowed through other behaviors or attributes. See also the “Accelerate” behavior.”

Animate: “Drag and drop a sequence of images into this behavior from your project library. Once added, images can be reordered, and additional images can be inserted. The controls in this behavior allow you to specify the frame rate of the animation, up to 30 frames per second; whether or not the animation loops, stops at the last frame, or returns to the last image used before the animate behavior started.”

Change Attribute: “This behavior allows you to set, change, or increment a game, scene, or actor attribute. It can be used to change a numerical value, color, size, movement, acceleration, or any other value determined by an attribute."

Change Image: “Specify an image to replace the current image on an actor. You can either drag the new image to this behavior or specify an image from the drop-down menu.”

Change Scene: “This behavior will stop the current scene and immediately move to the designated scene. It’s best to place this behavior inside a rule that changes to the game credits scene, menu scene, or to a new game level after certain objectives are met.”

Change Size: “This behavior changes an actor’s size by a scale factor (use a negative number to shrink an actor). Note: the actor’s original size will still determine its collision volume; to change this, use “change attribute” or “interpolate” instead. Use a timer to specify the amount of time that the transformation should take to occur."

Change Velocity: “Specify the direction of movement for the actor at a constant designated speed. Once the direction is specified, other influences on movement will begin to affect the actor, such as drag, gravity, or other movement behaviors.”

Collide: “This behavior controls which actors or groups of actors will collide with each other. A group of actors may be created by using a tag in the project editor.”

Constrain Attribute: “This behavior continuously updates the value of one attribute to match another attribute. This is particularly useful to keep two objects moving in sync, or to keep an actor tied to the movement of the mouse or touch.”

Control Camera: “Add this behavior to an actor and the scene’s camera will scroll to follow. The tracking area for the camera can be changed in the Scene Editor using Camera Edit mode. Only one actor instance per scene can have this behavior; actors in non-scrollable layers cannot use the Control Camera behavior.”

Destroy: “Immediately removes the actor from the scene.”

Display Text: “This behavior will show the text entered in the box, and includes controls over the color, alignment, font, wrapping, and size of the text displayed. Wrapping will cause line breaks in order to keep all of the text inside the actor.”

Group: “This is an organizational behavior, which allows you to group certain behaviors and rules together easily and clearly. It can also be created by selecting the “Create Group” button.”

Interpolate: “This behavior allows you to change attributes from their existing value to a new value over a set period of time. Interpolate will use a constant rate of change over the designated time period. This behavior can effect a rapid or gradual change in any game attribute, and cannot be obstructed or stopped by any other behavior.”

Load Attribute: “Loads the value stored with a custom key name using the Save Attribute behavior. A key is basically a storage location for a specific attribute. Use any key you want when saving an attribute, and then use the same key to load that same information later.”

Move: “Use to move in a particular direction relative to the actor or the scene at a specified velocity. Additive movement allows multiple move behaviors to stack, or act on an actor simultaneously; Stacked movement causes only the most recent active movement behavior to control the actor.”

Move to: “Use to move towards a specific X/Y coordinate relative to the actor or to the scene. This movement will stop upon arrival at the designated coordinates unless the controlling conditions are no longer valid and “run to completion” is not checked, in which case the movement behavior will cease as soon as the controlling conditions are no longer valid.”

Note: “This behavior allows the developer to record reference notes explaining a rule, behavior, group, or other aspect of the game. These will not be visible in or affect the operation of the game.”

Particles: “Spawns a designated number of particles from behind the actor. This behavior includes options for color, size, lifetime, velocity, images, and more.”

Pause Game: “This behavior will pause the current scene and display the scene selected in the behavior over the current scene. Using the “unpause game” behavior removes the scene and resumes the original scene.”

Pause Music: “This behavior will pause the currently music track, if one is playing. Use the “play music” behavior to resume the track.”

Play Music: “This behavior causes the selected music file to start playing. Select “loop” to cause the selected music to begin again once it has played through to the end.”

Play Sound: “This behavior causes the selected sound file to start playing. Select “loop” to cause the selected sound file to repeat each time it completes; select “run to completion” to prevent other behaviors from interrupting the sound before it has played through to the end. “Positional Sound” and “Velocity Shift” will affect the volume and pitch of the sound as the actor controlling the sound effect moves through the scene.”

Replicate: “This creates duplicates of an actor without actually spawning additional actors into a scene, based on the value of an attribute. It is most commonly used to display the number of lives a player has left.”

Reset Game: “Resets the game and all the scenes in it. This will restore all attribute values to their original state, but will not delete keys saved using the “Save Attribute” behavior.”

Reset Scene: “Resets the current scene and all the actors in it. If placed in the scene that appears during a pause, will not reset the underlying paused scene.”

Rotate: “Causes the actor to spin clockwise or counter-clockwise at the speed specified in the expression editor. The “rotate to angle” and “rotate to position” behaviors perform similar, but unique tasks.”

Rotate to Angle: “Causes the actor to spin clockwise or counter-clockwise at the speed specified until it reaches a particular angle, at which point rotation will cease. Unchecking “stops on destination” will cause this behavior to act similarly to the “rotate” behavior.”

Rotate to Position: “Causes the actor to spin clockwise or counter-clockwise at the speed specified until it reaches the designated X/Y coordinate, at which point rotation will cease. Unchecking “stops on destination” will cause this behavior to act similarly to the “rotate” behavior. Use “Offset Angle” to rotate to a position a designated number of degrees from the specified X/Y coordinate.”

Rule: “Creates a condition or set of conditions to check before activating an enclosed behavior. These conditions include player input (mouse clicks, touches, key presses) and attribute values. Rule also includes an “otherwise” section; behaviors placed here will trigger whenever the conditions in the Rule are not true.”

Save Attribute: “Stores the value of an attribute with a custom key name. Any key name can be used; inputting the key name in the “Load Attribute” behavior will yield the stored value. Saving a new attribute value with a previously used key name will result in overwriting any existing saved data. Values stored using ”Save Attribute” will remain accessible, even if the game or device is turned off.”

Spawn Actor: “Creates a new actor instance in the scene. Specify which actor to spawn and the directional and position of that actor relative to the scene or spawning actor. This allows any actor in a scene to spawn additional actors anywhere else in the same scene. Newly-spawned actors will immediately begin following any movement or other behaviors associated with them.”

Stop Music: “This behavior stops the current music track. Unlike the “pause music” behavior, this behavior resets the track, so that a “play music” behavior acting afterwards will start the music track from the beginning.”

Timer: “This behavior allows you to activate behaviors or rules at specified intervals. All timer values are in seconds. “After” triggers the behavior or rule once after the given time period; “every” triggers the behavior repeatedly with a given delay between each trigger; “for” keeps a behavior active for the duration of the time.”

Unpause Game: “If the “pause game” behavior has activated and opened the pause scene, this behavior will remove the pause scene and resume the underlying paused scene.”