Tutorial Downloads

File Size
Instance Variable.capx266KB

Translations

Know another language? Translate this tutorial!

Stats

1,108 visitors
5.5K page views

Instance Variable

Favourite 20 favourites
Tutorial written by Lordshiva1948Originally published on 13th, January 2014

Instance Variable

With Instance Variable you could do amazing things. Your imagination is the limit. Here is demo to start you off.

Create new project and call whatever you like. I am making my project Instance Variable.
Set Layout to 640 x 480
Margin to 640, 480
Window size to 640, 480
Call this layer BG
Create another Layer and name it Player
Create another Layer and name it HUD, do not forget to set PARALLAX to 0, 0

Create player and name it whatever you like I am calling mine HERO
Give hero behaviour 8 direction and flash
Create Wall and behaviour solids
Wall should be on BG
Create another layer and call it Objects. On this layer we can add our other stuff like pickups, door, and switches and so on

First object let’s say Pickup like fruit in this case BANANA, STRAWBERRY and so on
Just name it Fruits
Give INSTANCE VARIABLE NAME say Fruited and NUMBER 1
Now open your animation of first Fruit and set frame rate to 0
Now add frame and import another object in and set that anim to frame on and so on
Now Give second frame INSTANCE VARIABLE NUMBER 2 and so on
Create about 4 pickups
Create TEXT and name it Score
Create another TEXT name it FruitID
Add code BELOW

Let’s create enemies
Same as above about INSTANCE VARIABLE and create about 4 enemies
Each having Bullet behaviour and set angle NO
Bullet speed = 200
Angle set NO

Create TEXT and name it EnemiesID
Create another TEXT and name it Enemydestroyed
Add code BELOW

Let’s create door & Switch
Same as above about INSTANCE VARIABLE and create about 4 doors and name it DoorID and create 4 Switch same or see DEMO
Add code BELOW

your main screen looks something like this

and your code
Open full size image
Happy learning

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Share and Copy this Tutorial

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

Comments

1
Forsaken 1,505 rep

Nice work!!! Thanks for sharing I will be using this in a game.

Monday, January 13, 2014 at 3:48:36 PM
1
BettySmit 1,844 rep

Awesome tut thanks

Sunday, January 19, 2014 at 7:13:29 AM
1
AbelaNET 14.8k rep

Nice. thanks for sharing.

Monday, January 20, 2014 at 11:04:34 PM
2
K969 1,499 rep

A nice simple example of instance variable use ;o)

Wednesday, January 22, 2014 at 10:55:33 AM
0
Bass_X 603 rep

Awesome tutorial! But frankly speaking, I don't understand why "pick where fruit.fruitid=fruit.fruitid" works. Have you any explanatations?

Friday, June 20, 2014 at 3:02:53 PM
0
DeathSpecter9 2,958 rep

Thanks for the examples and tutorials.

Friday, August 26, 2016 at 9:12:42 AM

Leave a comment

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