5 – Actors in GameSalad

Actors represent the visible objects within your game. Actors can represent the character that the player is controlling or they can be the surrounding objects/characters that your player talks to, collides with, jumps over, or generally interacts with during gameplay.

Game designers often begin their process in Creator by creating the set of actors that they will need in their game across different scenes. These are known as “prototypes” (or models) of the actual actors/characters instances that your players will interact with within your scenes. For example, in Pacman, you would create a ‘ghost’ prototype, specifying some visual attributes of the ghosts, and how the ghosts would behave in the game. Each ghost that actually appears in each scene/level of the game is a specific instance based on this ghost prototype (and would therefore inherit all the attributes and behaviors of the prototype). If you make a change to the ghost prototype, all ghosts within the game would also be changed.

Actors instances are the building blocks of a scene. To create an actor instance, simply drag an actor prototype into a scene. Any changes you now make to this specific actor within the scene will only affect that actor instance, not the prototype itself.

Actor Attributes

The following attributes define each actor:

General attributes:

  • Name: a descriptive way for you to refer to an actor within your game.
  • Time: the number of seconds an actor has been active or “alive” in the scene. This attribute can be read and incorporated into your rules/behaviors, but not changed.
  • Position: the x and y position of the actor in the current scene. This property is relevant for actor instances within a scene, not actor prototypes.
  • Size: the pixel dimensions (width and height) of the current actor.
  • Rotation: specifies the angle or rotation at which the actor appears initially in the scene. For example, if the value is 90, then the actor appears 90 degrees rotated counter-clockwise.
  • Color: the background color of the actor, represented by red, green, blue, and alpha integer values from 0 to 1. You can edit any of these individual values, or you can select a color from a color picker.
  • Image: the image displayed for the actor (if any). This is not manually editable, but you can modify this by dragging an image from your artwork/sprites on to the actor instance within the stage.
  • Tags: tags given to the actor, which are labels you can use in your game logic to apply actions groups of actors.

Graphics-related attributes

  • Visible: determines if an actor will be seen by the player. If checked, the actor will be seen. This attribute cannot change during gameplay. Unchecking this attribute will improve the performance of your game if the actor never needs to be seen.
  • Blending mode: determines how the actor’s graphics will be drawn with respect to its background. It can be one of the following:
    • Normal: overlays the actor over the background. This is the default blending mode. When in doubt, use this one.
    • Opaque: copies the actor’s pixels exactly, replacing the background and ignoring transparency. Opaque mode is the cheapest blending mode, so using it may improve the performance of your game, especially for large background images.
    • Additive: adds the color value of each pixel of the image to the color value of the image behind it. This has an intense brightening effect, and is commonly used to draw emissive light sources (fire, sparks, explosions, lasers, and other things that are awesome…)
    • Screen: similar to additive. Instead of adding the actor and background colors, Screen adds the actor color to the inverse of the background color. This results in a more realistic brightening effect, with less ‘overexposure’ of the image.
    • Multiply: multiplies the color values of the actor’s pixels with the background. This tints or darkens the background image, and is useful for gradient overlays, tinted windows, shadow effects, or masking. Note: Using transparency combined with multiply will have strange results because the Alpha channel is ignored when rendering the image. For this reason, we recommend avoiding this combination.
  • Horizontal wrap/ vertical wrap:
    • Stretch: the image will be stretched or compressed to fit within the boundaries of the actor.
    • Fixed: the actor will show its image at the size/resolution of the file. The image will be centered to the actor and the actor can be made smaller or bigger than the image resolution without changing the look of the image.
    • Tile: the image will be repeated if the actor is larger than the image resolution.
  • Horizontal Anchor: determines the location of the image on an actor when an image is set to fixed in Horizontal Wrap.
    • Left
    • Center
    • Right
  • Vertical Anchor, which has three options that determine the location of your actor when an image is set to fixed in Vertical Wrap.
    • Bottom
    • Center
    • Top
  • Flip Horizontally / Flip Vertically: These boolean attributes will invert your image vertically or horizontally.
  • Tile Width / Tile Height: the pixel dimensions (width and height) of the image if Tile has been selected under Horizontal or Vertical Wrap.

 Motion-related attributes

  • Linear velocity: the speed of an actor in a specific direction, specified in the X and Y directions.
  • Angular velocity: the speed at which the actor rotates. Values greater than 0 cause the actor to rotate counter-clockwise. Negative values cause clockwise rotation.
  • Max speed: the value of the maximum speed the actor can go if Apply Max Speed has been selected.
  • Apply max speed: if checked, the actor will be limited to the speed set in Max Speed. Otherwise, the actor will continue to increase in speed.

Physics-related attributes (non-motion physics)

  • Density: the heaviness of the actor. A higher value will make the object harder to move by less dense actors. A value of 0 will make an object immovable but still affect other actors in the scene. Density can be set to any real positive number. (i.e. Density >= 0)
  • Friction: specify how much the actor gets slowed down each time it contacts another actor. 0 is smooth; larger numbers make the actor slow down more quickly. Friction can be set to any real positive number. (i.e. Friction >= 0)
  • Bounciness: number that describes the bounciness of the actor. 0 is no bounciness. Bounciness can be set to any real positive number between 0 and 2.
  • Fixed rotation: specify whether or not the actor rotates when it collides with other actors in the scene.
  • Movable: this determines if the actor can be moved, including collision from another actor and gravity.
  • Collision shape: an actor can have a rectangular or circular collision area. For a circular collision area, it is the largest circle that can fit entirely in the dimensions of the actor.
  • Drag: this gives an actor linear drag. It will gradually slow down movement for an actor, if there are no other forces (movement behaviors) modifying the motion of the actor.
  • Angular drag: this gradually slows the rotation of an actor, if there are no other forces (rotation behaviors) modifying the motion of the actor.

New actor attributes may be created and removed using the (+) and (-) buttons on the bottom left of the attributes pane. The newly created attribute will appear highlighted near the bottom of the attributes list. These attributes can be accessed from the rules editor, and changed via the Change Attribute behavior unless otherwise noted.

As mentioned earlier, modifying an actor prototype affects all corresponding instances of this actor. You can customize specific actor instances as you like by double-clicking an actor instance. If you select an actor instance, the rules editor will initially be locked so that you do not accidentally modify the logic of your actor instance to differ from its prototype. However, you can simply click on the lock icon to unlock the space and allow editing. You can revert to the prototype’s rules by pressing the Revert to Prototype button at the top of the rules editor. You can modify the attributes of an actor instance without needing to unlock the attributes pane. You can revert individual attributes by selecting an attribute and pressing the Revert to Prototype button at the top of the attributes pane.

Actors can be added to your scene in a couple of different ways.  First, you can have your actors start in the scene.  To do this, simply load up the desired scene in the scene editor and drag your actor to where you want it.  Second, you could have your actor start “off-scene”, but enter the scene at some point during gameplay.  You’ll notice that if your scene size (located in the scene editor; select the “scene” toggle, and then the “attributes” tab) is larger than the camera size (dictated by the platform you’ve chosen), there will be areas of your scene editor that are outside the scope of the camera.  You can place actors here and have them move into the scene using a variety of movement behaviors, which are discussed in a later tutorial.  Finally, you can “spawn” actors using the Spawn Actor behavior.  This will place the actor at a designated location and velocity in your scene.