Learning Stencyl 3.x Game Development Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Chapter 3. Detecting Collisions

In this chapter, we will continue to develop the game that we started to create in Chapter 2, Let's make a game. Although we have many of the basic game mechanics in place, we do not yet have a very interesting game that will engage our players, so we're going to introduce an additional element of interactivity to make the game more challenging.

In its current form, the game allows our monkey to navigate the jungle scene without any difficulty, and that isn't going to be much fun for players of our game — we need a more interesting environment!

To make the game more challenging, we're going to add some dangerous enemies for the monkey to avoid, and we're also going to create a challenge for the player to complete — the monkey will have to collect some items as it makes its journey through the jungle.

In order to be able to collect these items, we need our monkey to detect collisions with other objects, so our game can respond accordingly. In this chapter, we're going to learn the important aspects of implementing collision detection within Stencyl.

By the end of this chapter, we will have a good understanding of the following topics:

  • Working with collision detection in Stencyl
  • Modifying an actor's collision shapes
  • Configuring collision shapes for tiles
  • Adding enemies and collectibles
  • Working with collision groups
  • Using collision sensors
  • Implementing terrain collision shapes

The target for this chapter is to progress with our development of the game so that it looks something like the following screenshot:

As we can see, our monkey now has fruits to collect and dangerous animals to avoid!