Adding enemies and collectibles

Now that we have refined the collision detection for the monkey and the tiles, it's time to add some enemies for our monkey to avoid, and we also need to find some interesting items for the monkey to collect. Adding these objects into our game will introduce the first level of challenge for our players.

We've already learned how to import actors from StencylForge, and that's where we'll find the new actors we're going to place into the jungle scene.

Downloading the enemies and collectibles

The game file to import and load for this session is 5961_03_05.stencyl.

We already know how to search for and download actors from StencylForge, so let's download the actors with the following names:

  • Stencyl Book Croc
  • Stencyl Book Snake
  • Stencyl Book Melon
  • Stencyl Book Bananas
  • Stencyl Book Pineapple
  • Stencyl Book Grapes

If we now go to the Dashboard tab and click on Actor Types, we should see the following display in the main panel:

Downloading the enemies and collectibles

Now that we have added all the actors, we need to save the game!

Placing the new actors into the jungle scene

The game file to import and load for this session is 5961_03_06.stencyl.

Now that we've downloaded the actors from StencylForge, it's time to place them into the jungle scene. As a designer, it's our job to place the enemies and collectibles into locations that will provide a challenge for players of our game, but as with the design of the collision bounds for the actors, we must not make the game too frustrating nor should we make it too easy.

We have already added actors to the scene by clicking on the Add to Scene button when viewing the actor in the Animation Editor. However, there is a more efficient way to add multiple actors into a scene without having to display each actor's animations first.

If we display the scene, we can see two buttons at the top of the right-hand panel: one is for displaying the available tiles and the other is for displaying the available actors. If the available actors are not already on display, click on the Actors button. We can now add actors to the scene in exactly the same way that we added tiles: click on an actor, then add it to the scene by clicking on the required location. It's great to know that all the skills we learned when adding tiles work equally as well for actors!

Here's another useful tip before we start adding more actors to the scene; holding the Shift key on the keyboard while positioning actors on a scene snaps the actor into place on an invisible grid. This can be very useful for placing actors at regular evenly spaced positions within a scene. Also have a look at the tools available within the Scene Designer, at the upper-right of the main panel. Hovering the mouse pointer over each tool will provide a tip. We're most interested in the three grid tools at this point!

  • Add each of the new actors (fruits and enemies) to the jungle scene.
  • Save the game.

Note

If we test the game right now, we'll see that there is a problem with the collision testing, and we may also experience some strange effects, such as some of the fruit or enemies moving unexpectedly.

Don't worry, it's just the Stencyl's physics engine behaving as it should; we're going to fix these problems!

We can now test the game. Although all the enemy actors and the collectible fruits are clearly visible, when the monkey collides with them, nothing happens; he runs straight past them without even the slightest bump!

This might lead us to believe that there is a problem with the collision bounds of the newly added actors. However, if we have a look at the collision bounds for these actors, we can see that they are all in place. The collision shapes of two of the new actors are shown as follows.

Placing the new actors into the jungle scene

Clearly, something is wrong with the collision detection! We have one final task to complete to ensure that Stencyl can detect collisions correctly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.95.216