Created: January 2011
Last Updated: January 2011
Original Author: Tony Huynh
Overview
Create the animation chain list file (.achx) to describe the entity's animations. This file will reference corresponding image files (e.g. PNG files) used for the animations.
Create the scene file (.scnx) to describe the entity's visual representation. This file will reference the animation chain list file.
Create an object to act as the visual representation of the entity. This will reference the scene file. In code, this is equivalent to creating a data member (i.e. variable) inside the entity's class.
I. Creating the Animation Chain List File
The animation chain list file is a description file that is internally written in XML. It describes the entity's possible animations by pointing to the corresponding image files (e.g., PNG files).
Create a .achx file for the entity by doing the following steps:
In Glue, expand the "Entities" tree and then expand your already created "Character" entity subtree.
Right-click on "Files" under the entity subtree and select "Add File"->"New File".
Under "Select the file type," choose "Animation Chain List (.achx)" from the drop-down list for the type, and enter an appropriate name such as AnimationChainListFile for the Animation Chain List file name.
The new file will appear under your Character Entity's "Files" tree item.
(Optional Step) If double-clicking the .achx file from the TreeView does not automatically open up the Animation Editor, then do the following steps to get this to happen:
In Glue, under the "Settings" drop-down menu select "File Associations".
For the "achx" property, instead of "<DEFAULT>" choose "New Application..." for its value.
A file directory window will open. Navigate to the AnimationEditor.exe and select it. It should be located at C:\Program Files (x86)\FlatRedBall\FRBDK\AnimationEditor.exe.
Close the File Association Window.
Open the .achx file with the FlatRedBall Animation Editor.
Use the Animation Editor to add in all of the animations for the entity. See http://www.flatredball.com/frb/docs/index.php?title=AnimationEditor:Tutorials:Creating_an_AnimationChain for using the animation editor. Note that it does not matter where (in the directories) your image files are currently at. If your image files are not located locally within the correct project directory, then when you save your animation chain list, it will give you the option to copy the image files there; that is, when saving, after the appropriate pop-up window is shown, choose the "Copy All Locally" option and click "Save".
II. Creating the Scene File
The scene file describes a scene, which is simply a collection of different types of objects which can be added as a group. For the purpose of this tutorial, the scene file will be used to contain the entity's animations.
Create a .scnx file for the entity by doing the following steps:
In Glue, expand the "Entities" tree and then expand your already created "Character" entity subtree.
Right-click on "Files" under the entity subtree and select "Add File"->"New File".
Under "Select the file type," choose "Scene (.scnx)" from the drop-down list for the type, and enter an appropriate name such as VisualRepresentationFile for the scene file name.
The new file will appear under your Character Entity's "Files" tree item.
Double-click the .scnx file to open it in the Sprite Editor. (If this does not happen, then see the optional step in the "Creating the Animation Chain List File" section above for a reference on getting this to work.)
In the Sprite Editor, click on the "Add" drop-down menu from the top, go to "Sprite ->", and choose "From File...".
After the file directory window pops up, choose the animation chain list file (.achx) that you want to reference.
You should now see an item (i.e. the sprite) listed in the Object List window. You may want to edit the properties of the sprite by using the Sprite Editor (where sprite refers to the animation list that was just added). Remark (on editing sprite properties): Regardless of the camera type (i.e. perspective projection or orthogonal projection) being used by your game, it is a good idea to modify the sprite properties so that the sprite appears at its full resolution on the screen when the game runs; if you plan to have dynamic screen resolutions during run-time then you will want to change the sprite properties in code. For doing this in Glue, you will mainly want to edit property values in the 1) Camera window ("Window-->Camera Properties" from the drop-down menu at the top) and 2) Sprite window (which automatically opens when you select your sprite from the Object List). Modifying properties in the Camera window will not change any properties in the scene file; it is only used to give visual feedback and aid in properly calibrating the properties of the sprites. In the Camera window, mainly all of the properties you will want to change are in the "uncategorized" section. After appropriately setting the values for the camera, you will want to adjust the properties of your sprite. In the Sprite window, go to the "Scale" category and click the "Set Perfect Pixel Scale" button to scale your sprite so that it will appear at its full resolution on the screen according to the camera properties. If you do not see your sprite within the Sprite Editor's viewport then you can fix this by going to the "Basic" category of the Sprite window and modifying the sprite's position (i.e. X, Y, Z values) or other properties. Note that the position refers to the center of an image. For more tutorials on using the Sprite Editor, see http://www.flatredball.com/frb/docs/index.php?title=SpriteEditor:Tutorials.
Save the .scnx file.
III. Creating the Visual Representation Object
The above steps only creates files, which does not modify anything in code about your class. This section deals with adding the visual representation to the entity via Glue, which will automatically create a Scene data member in the entity's generated class file.
Add an object to the entity by doing the following steps:
In Glue, expand the "Entities" tree and then expand your already created "Character" entity subtree.
Right-click on "Objects" under the entity subtree and select "Add Object".
Enter the object's name such as VisualRepresentation and press the "OK" button.
The new file will appear under your Character Entity's "Objects" tree item.
Click on the newly created object and you will see a list of properties on the left side of the Glue window.
Find the "Source" category in this list (which should be the last category) and do the following steps:
For the "SourceType" subcategory, set its value to "File".
For the "SourceFile" subcategory, choose your scene file (.scnx) for its value.
For the "SourceName" subcategory, choosing "Entire File (Scene)" for its value will work fine if you only have 1 sprite (e.g. the animation list), but you may choose a specific sprite from the scene file if you want only that to be displayed for the entity.