Beginner's guide to Construct 2

Favourite 629 favourites
Tutorial written by AshleyOriginally published on 26th, June 2011 - 48 revisions

Adding behaviors

Behaviors are pre-packaged functionality in Construct 2. 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. You can do the same in events, but it takes longer, and there's no point anyway if the behavior is already good enough! So let's have a look at which behaviors we can use. Amongst others, Construct 2 has these behaviors;

- 8 Direction movement. This lets you move an object around with the arrow keys. It will do nicely for the player's movement.
- Bullet movement. This simply moves an object forwards at its current angle. It'll work great for the player's bullets. Despite the name, it'll also work nicely to move the monsters around - since all the movement does is move objects forwards at some speed.
- Scroll to. This makes the screen follow an object as it moves around (also known as scrolling). This will be useful on the player.
- Bound to layout. This will stop an object leaving the layout area. This will also be useful on the player, so they can't wander off outside the game area!
- Destroy outside layout. Instead of stopping an object leaving the layout area, this destroys it if it does. It's useful for our bullets. Without it, bullets would fly off the screen forever, always taking a little bit of memory and processing power. Instead, we should destroy the bullets once they've left the layout.
- Fade. This gradually makes an object fade out, which we will use on the explosions.

Let's add these behaviors to the objects that need them.

How to add a behavior

Let's add the 8 direction movement behavior to the player. Click the player to select it. In the properties bar, notice the Behaviors category. Click Add / Edit there. The Behaviors dialog for the player will open.

Opening the Behaviors dialog.
Click the green 'add behavior' icon in the behaviors dialog. Double-click the 8 direction movement to add it.

Adding the 8-direction movement.
Do the same again and this time add the Scroll To behavior, to make the screen follow the player, and also the Bound to layout behavior, to keep them inside the layout. The behaviors dialog should now look like this:

The Player with all three behaviors added.
Close the behaviors dialog. Hit Run to try the game!

The Run button.
Hopefully you have a HTML5 compatible browser installed. Otherwise, be sure to get the latest version of Firefox or Chrome, or Internet Explorer 9 if you're on Vista and up. Once you have the game running, 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 bits of functionality. We'll be using the event system soon to add customised functionality.

Adding the other behaviors

We can add behaviors to the other objects by the same method - select it, click Add / Edit to open the behaviors dialog, and add some behaviors. Let's add those other behaviors:

- Add the Bullet movement and Destroy outside layout to the Bullet object (no surprises there)
- Add the Bullet movement to the Monster object (because it just moves forwards as well)
- Add the Fade behavior to the Explosion object (so it gradually disappears after appearing). By default the Fade behavior also destroys the object after it has faded out, which also saves us having to worry about invisible Explosion objects clogging up the game.

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:

Bullet behavior properties
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).

Create some more monsters

Holding control, click and drag the Monster object. You'll notice it spawns 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. With Sprites, all instances of an object type also share the same texture. This is great for efficiency - when players play your game online, rather than having to download 8 monster textures for 8 monsters, they only need to download one monster texture and Construct 2 repeats it 8 times. 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! 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.

Several monsters in the layout.
Now it's time to add our custom functionality via Construct 2's visual method of programming - the event system.

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.

Comments

48
kemosabe 2,531 rep

Nice.i like it

Thursday, June 30, 2011 at 10:42:49 AM
24
ludodesign 22.5k rep
Saturday, July 02, 2011 at 3:26:03 AM
16
ludodesign 22.5k rep

I love you Ashley

Tuesday, July 12, 2011 at 4:00:10 AM
30
luisgmolina 6,461 rep

Very cool.
we need a advanced tutorial now, please.
thank you.

Friday, July 15, 2011 at 7:49:43 PM
17
Skodex 2,362 rep

Thanks for this. You made something which I first thought to be rather complicated, seem extremely easy.

Monday, July 25, 2011 at 6:14:40 PM
14
Dicon 2,498 rep

A great tutorial and not too difficult to get your head around. Are there any books out there for Construct? We all need them.
Thank.
Dicon

Wednesday, July 27, 2011 at 12:08:49 PM
12
driftish 2,312 rep

thanks a whole lot this tutorial was extremely helpful.

Thursday, July 28, 2011 at 8:36:42 AM
13
Mehtab 3,074 rep

awesome tutorial and awesome tool!

Saturday, July 30, 2011 at 10:45:41 AM
9
stufa 2,281 rep

I love it!!!
I've always wanted to create a video game. Your tutorial was clear and interesting. You make a great teacher Mr Ashley.

Oh I tried running your additional tutorial on Ghost Shooter. For some reason I can't run the demo play.

I'm afraid I'm quite a computer noob.

Saturday, August 06, 2011 at 12:14:18 PM
15
ianbrown3003 2,466 rep

This is great! I've just started a games designer course, and although I get a full version of Gamemaker at some point during the course, I wanted to get hands on with using game-making software now...this program looks great, and your beginners guide has eased me in really well, it's well written and very user-friendly. Top work!

You've inspired me to play around more with this program, and that means I'll probably end up buying the full version soon. Good work!

Friday, September 09, 2011 at 9:27:08 PM
11
Ghengis 4,643 rep

This is a must read. Excellent overview of how Construct 2 works.

Tuesday, September 13, 2011 at 4:13:04 AM
15
Ashley 113.1k rep

Just made an update: the tutorial now covers image points (added in r56). It's on page 5.

Saturday, September 17, 2011 at 5:48:10 PM
10
chrisbrobs 6,470 rep

Brilliant tutorial.

Saturday, September 24, 2011 at 11:02:10 PM
9
carminielloz 8,401 rep

oh my Gosh !!! this is amazing , thank you guys !!!!
I only just finished page 1 but I love it
the possibilities to creat a variety of videogames seem endless.
THANK YOU VERY MUCH GUYS !!!

Friday, September 30, 2011 at 6:03:17 AM
9
carminielloz 8,401 rep

my hero moves nicely ( 8 direction , bound to lay out and scroll to )
but i think i missed something , the monster doesn t move , i changed the speed but it never moved in the first place ( i gave him bullet movement but nothing )

Friday, September 30, 2011 at 6:34:29 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.