8. Asset Management¶
8.1. Changing the Image of an Entity¶
Actimator accepts .PNG, .BMP, .GIF, and .JPEG images. Image assets can either be used for Actors , or as backgrounds. It is best to use .png files for image assets.
The .PNG format:
PNG(Portable Network Graphics) is a widespread lossless image format that supports transparency. Thanks to compression, PNGs tend to have a very small file size.
Image assets are just for visuals, they can’t have a program or physics. You can drag an Image Asset directly to the scene to be used as a background, by default, it will be placed on layer 1. While on the scene, we can control the size, position, layer, etc. of each image by clicking on it. The Image Asset Properties will appear in the Property Explorer.
Image boundaries are traced in purple with a purple dot on each side and corner. We can use these dots to resize each image.
An image can also be applied to an actor, all entities of that actor will have the same image. The entity parameters; Image, Image Width, Image Height, Image Left Offset, Image Top Offset, and Rotation control how an entity’s image looks.
Image assets can be used in sequence to create animations. There are many methods for creating animation. For this example, we’ll use the Tick Count.
This animation has 6 frames that we want to cycle through in the Before Render event. We have to make an If statement for each frame. We’ll check if Tick Count modulo 5 is equal to a number corresponding with each frame. For example, if Tick Count modulo 5 equals 0 then change image to frame 1.
8.2. Playing an Audio Asset¶
Audio Assets can either be .WAV or .MP3 files. You can drag an Audio Asset directly onto the scene to be used as looping background music, or you can play sound effects during Run Time with code.
The Play Audio Command is perfect for sound effects, it plays a sound as soon as its executed.
If you need more control over audio, you can use the Audio Action Command. First you need to use the Create Audio Command, this will return an Audio Id that you can save in a variable. The Audio Action Command will play, pause, resume, stop, or destroy the audio who’s Id is specified.
The example below creates audio and stores its Id in a variable. The audio with its Id stored in the variable is then played. If the player clicks on the entity, the audio is stopped.
8.3. Writing Text on the Scene¶
The Text Command displays text on the scene with the desired position, layer, font, etc.
- Text – The text you would like to display, this could be a String, Number, Mathematical Operation, Variable, or Parameter
- X – The X Position of the text
- Y – The Y Position of the text
- Layer – The layer for the text, -1 is the front-most layer
- Font – Pick a cool font
- Size – Size of the font
- Color – Color of the text
- Background – The background color of the text
The Text Command is also useful for debugging. The example pictured below displays the This Entity Speed parameter as text. You can compare parameter values with how entities behave, to improve the quality of your game.