Crash Course 2: Invaders - Part 2
by Hectate (Updated on 2015-02-01)
Part 2: Creating Actor Types
Step 3: Now that we have a blank game, it’s time to create our Actor Types. We’re going to start with our spaceship, which the player will control. Click the Actor Type button in the Dashboard menu on the left (under Resources, as shown).
Step 4: Next, click the large box in the workspace on the right (shown below) to create our first Actor Type.
Step 5: We will see the "Create New..." dialog appear (shown below). Name your Actor Type "Ship" as shown. Click the Create button.
Stencyl will create our new Actor Type and then open it for us.
Step 6: Our Actor Type does not yet have any images in it, we need to fix that so it can be seen by players. All images for an Actor Type are gathered in Animations, so we need to import images for these Animations. To do this, we need to first create at least one Animation to hold the images.
Since Stencyl opened the new Actor Type for editing in the Appearance tab, we are already where we need to be. Click the large box with the dotted line in the workspace on the right (shown below).
Stencyl will create a new Animation for us and open it in the workspace.
Step 7: We are now looking at the Animation Editor for the new Animation, which by default will be named "Animation 0".
An Animation typically represents a “state” that an Actor could be in, such as Walking, Running, Jumping, etc. As such, it is ideal for us to rename our Animation so that later we can easily identify what state it represents. We need to erase "Animation 0" from the Name field and type "Flying" into it.
Now that our new Animation has been named properly, let's give it some images. We will click on the "Click here to add a frame" box to open our image importer.
Step 8: The image importer dialog below will pop up for us. First we have to select an image to import; click the Choose Image button.
We should have saved and extracted the example assets earlier somewhere on our computer, so we should navigate to that folder. We want to open the "Ship_flying.png" image for this Animation (if you still need to download the assets, click here to download them).
Step 9: Individual "frames" of an Animation image are commonly stored in a single larger image. In this case, Ship_flying.png contains four frames. Of course, Stencyl does not automatically know this, so we need to change some settings so the image is not imported as one single, large frame. Set the value in the “Columns” field to 4. This will split our image evenly into four frames separated by black lines, as shown below. Once ready, click Add and Stencyl will import the image as four frames of our Flying animation.
We are back in the Animation Editor and can see that our Flying animation is now showing an animation preview in the list, with the four individual frames in the workspace to the right.
Step 10: Now that we have our single Animation, we need to choose the correct Physics settings for our Ship Actor Type. Click the Physics tab, as shown below.
Step 11: The first page that will appear is the “General” page under Physics. Let's leave the "What kind of Actor Type?" option set to Normal, but set "Can Rotate? and "Affected by Gravity?" both to No.
Step 12: Now we need to set the Collision Group that our Actor Type is a member of. This will allow us to specify what our Ship can collide with and what it can’t. Click the Properties tab (shown below).
Step 13: Set the Group to "Players", as shown. If we want to create more Groups, there is an Edit Groups button on the right. You can read more about creating Groups here. Note the Players Group is built into Stencyl and will appear by default on when we click the dropdown, so we don't need to Edit Groups at this point.
Step 14: We want to save our Ship Actor Type (and the game) by clicking File and then Save Game. Note that there is a keyboard shortcut available for this, as well as the "Save Game" disk icon.
We have our Ship Actor Type set up now, so it's time to move on to determining how our Ship, and the other Actor Types we'll create, can collide with one another.