In Chapter 3, Detecting Collisions, we configured collision shapes for the actors and tiles so that collisions are detected when required, and our game now allows the player to traverse the scene with some basic, predictable interactivity. However, although the monkey is now colliding with other actors, there are currently no responses to these collisions, other than a bump when some of the actors collide.
We need to take control of the game, so in this chapter, we're going to learn how to create instructions that will carry out specific actions when collisions and other events occur within our game.
In this chapter we will be:
When an event such as a collision occurs during gameplay, we would like to be able to decide exactly what happens, rather than being limited to using the built-in behaviors that have been provided for us. We're going to create our own custom behaviors that;
As we discovered in the Using behaviors to interact with our game section in Chapter 2, Let's Make a Game!, behaviors are the instructions and rules that our game will use. We've already used some behaviors that have been built for us and are provided with Stencyl:
We found the previously mentioned behaviors in the built-in behavior library, and we attached them to the monkey actor so that it would follow the specified instructions. Up until now, we haven't concerned ourselves with how these behaviors work. We've just accepted that they do the required job, but now it's time to learn about what is going on in the background, and to create a custom behavior of our own.
Currently, when our monkey runs past a piece of fruit, nothing happens, not even a bump, because in Chapter 2, Let's Make a Game!, we configured all the fruit actors to be sensors.
However, we would like something to happen. In this case, we want the fruit to disappear so it can't be collected twice.
3.147.74.211