Creating custom behaviors
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;
Respond to collisions and other events
Use a random number to make gameplay less predictable
Utilize a timer to carry out actions at regular or delayed intervals
Implement custom events that can be triggered by other behaviors
Creating our first custom behavior
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:
Camera Follow
Cannot Exit Scene
Jump and Run Movement
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...