If you're completely new to Construct, this course...
This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.
Behaviors are quick ways to make an object act a certain way. For example, you can add a Platform behavior to an object, and the Solid behavior to the floor, and you instantly can jump around like a platformer game. You can usually do the same in events, but behaviors are much quicker! Construct has a wide range of behaviors, but here are a few that we'll use in this tutorial.
Let's add these behaviors to the objects that need them.
Let's add the 8 direction movement behavior to the player. Click the player object to select it. In the Properties Bar, notice the Behaviors category. Click the Behaviors link there. The Behaviors dialog for the player will open.
Click Add new behavior in the behaviors dialog. Double-click the 8 direction movement to add it.
Do the same again and this time add the Scroll To behavior, to make the screen follow the player. Then also add the Bound to layout behavior, to keep them inside the layout. The behaviors dialog should now look like this:
Close the behaviors dialog. Now try pressing Preview to run the game so far! Once the preview starts, notice you can already move around with the arrow keys, and the screen follows the player. You also can't walk outside the layout area, thanks to the Bound to Layout behavior. This is what behaviors are good for - quickly adding common features. We'll be using the event system soon to add custom features.
We can add behaviors to the other objects by the same method - select it, click the Behaviors link to open the behaviors dialog, and add some behaviors. Let's add these other behaviors:
If you run the game, you might notice the only thing different is any monsters you can see suddenly shoot off rather quickly. Let's slow them down to a leisurely pace. Select the Monster object. Notice how since we added a behavior, some extra properties have appeared in the properties bar:
This allows us to tweak how behaviors work. Change the speed from 400 to 80 (this is in pixels travelled per second).
Similarly, change the Bullet object's speed to 600, and the Explosion object's Fade behavior's Fade out time to 0.5 (that's half a second).
Holding Control, click and drag the Monster object. You'll notice it creates another instance. This is simply another object of the Monster object type.
Object types are essentially 'classes' of objects. In the event system, you mainly deal with object types. For example, you might make an event that says "Bullet collides with Monster". This actually means "Any instance of the Bullet object type collides with any instance of the Monster object type" - as opposed to having to make a separate event for each and every monster. We'll cover more on object types vs. instances later. For now, a good example to think about is different types of enemy are different object types, then the actual enemies themselves (which there might be several of) are instances of those object types.
Using Control + drag, create 7 or 8 new monsters. Don't place any too close to the player, or they might die straight away! Remember you can zoom out with Control + mouse wheel down if it helps, and spread them over the whole layout. You should end up with something a bit like this.
Now it's time to add our custom logic with Construct's visual method of programming - events!
Comments have been disabled by the owner.