Instance Variables

3

Index

Attached Files

The following files have been attached to this tutorial:

.capx

instance-variables-loops.capx

Download now 2.26 MB

Stats

5,044 visits, 8,399 views

Tools

Translations

This tutorial hasn't been translated.

License

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.

Published on 18 Jan, 2017. Last updated 19 Feb, 2019

How can we use Instance variable in RPG type game. Imagine we have desert RPG with signs showing water hole, camel yard, village, and nomad land, etc

To code above you will have enough line of code to add but, with instance variable it’s very easy.

Add new layout or just duplicate the Level_1 and name it Level_2. We don’t need another Event sheet in this tutorial but, in your game one should have separate Event Sheet. So you can see clearly what is going wrong in your game, if the game does not function as it should be, then all you do is use debug mode and scroll to event you want to observe where it’s not functioning as you desire.

Add background

Add Player

Give 8 directions, bound to layout.

Now add Desert_Objects like, trees, rocks etc

Add sign Board and name it Sign_Board and Instance Variable signboard_ID.

Sign_Board needs behaviour so add Line of site and set Range to about 70, also make Sign_Board solid too.

Add text and name it txtMSG. What happens here with Line of sight to our signboard, as soon as player come in its range MSG will pop up and also soon as player is out of range it will disappear?

Level 2 Screen:

At this point add 2 Global variables:

MSG = “” Text

MSG_Wait = 3

2 Global variable is very essential because we can use it again and again from anywhere in our code. As name imply we can set MSG in one code of line, and use MSG_Wait to wait then reset MSG. Simple

We need to add instruction code for player movement which are up, down, left and right, we already set behaviour to bound to layout so we do not need to check if player outside layout.

Our code is so simple I don’t think you need any explanation.

For our MSG signboard add these lines below:

Please remember this line of code is in SUB EVENT. By doing this we only needs to notify when player is in Range of sign board, appropriate sign board will display appropriate MSG. With this Example we also can create MSG (messages) for individual entity. Endless possibilities with logical thinking that is all for now let me know if you want other category TUTORIAL if I can provide you or help you with.

Next tutorial I am thinking is drag and drop game or street fighter type in Construct 2.

Only thing I ask in return is some comments from your friends, nothing more.

Lord Shiva bless you all

.CAPX

instance-variables-loops.capx

Download now 2.26 MB
  • 0 Comments

Want to leave a comment? Login or Register an account!