Event Sheet Includes - do they include variables?

Discussion and feedback on Construct 2

Post » Tue Jun 11, 2013 9:57 pm

Hi!

Just a quick question - When you Include an Event Sheet into another, does it also include all the Global Variables declared in the previous one all over again?


For example you have declared a globalVariable1 = 0 in Sheet 1. Let's say during the course of gameplay globalVariable1 becomes = 5.

If you include Sheet 1 in Sheet2, when the game switches to Sheet2, will globalVariable1 be set to 0 again or will it remain at 5?
B
10
S
3
Posts: 233
Reputation: 1,537

Post » Tue Jun 11, 2013 10:17 pm

Global variables are global to the whole project.
It means that you can access the variables declared even in a non-included event sheet.

So no, the global variables are not included "again".
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
267
S
95
G
66
Posts: 7,215
Reputation: 73,096

Post » Tue Jun 11, 2013 10:27 pm

If they are global to the whole project why are they only visible in the Event Sheet they were declared in?

Also, if you have EventSheet1 for Layout1 and EventSheet2 for Layout2.
If you declare a global variable in EventSheet2(which doesn't come into "play" before 5 mins have passed for example), will the global variables from EventSheet2 be availible for use by EventSheet1 at the very start, even tho EventSheet2 has never been "called" yet?Xionor2013-06-11 22:28:13
B
10
S
3
Posts: 233
Reputation: 1,537

Post » Tue Jun 11, 2013 11:05 pm

The declaration is only "visible" in the event sheet they are "created" into but yes they can be accessed through the whole project.

Simply do the test and you'll see the variable is nevertheless accessible (which means it can be modified and is visible in the dropbox of the action "Add to" for example).
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
267
S
95
G
66
Posts: 7,215
Reputation: 73,096


Return to Construct 2 General

Who is online

Users browsing this forum: arthurtomazz and 6 guests