How do I

Get help using Construct 2

Post » Wed Dec 21, 2016 10:50 am

Hi,

I've been stuck on this for over a week :( any help would be soooo welcome!

I have a 'menu page' which shows the levels, only level 1 is unlocked at the start.

When the player wins level 1, I set 'lvl2 unlocked and make the lvl2 button visible' this is perfect as the player can now select level 2.

But because on level 1 I have added "reset global variables" (I have to do this as that level takes turns between the player and computer) it resets the global and if the player plays level 1 again (even if they have completed it) the global gets reset and if they die or use the 'menu page button' the lvl2 button is invisible again.

I've tried sooo many different ways from saving to local variables, really what I need is a way to do this on the menu page:

If lvl2 button visible then permanently change global to 1 from 0, then when the player goes back to lvl and all global are reset, the global that I want is reset to 1, which keeps the lvl2 button visible.

I thought 'set global' would have set it permanently?

Is this possible or is there another way that I'm missing?

Thank you.
B
10
S
3
Posts: 56
Reputation: 804

Post » Wed Dec 21, 2016 11:10 am

MarkThomas wrote:Hi,

I've been stuck on this for over a week :( any help would be soooo welcome!

I have a 'menu page' which shows the levels, only level 1 is unlocked at the start.

When the player wins level 1, I set 'lvl2 unlocked and make the lvl2 button visible' this is perfect as the player can now select level 2.

But because on level 1 I have added "reset global variables" (I have to do this as that level takes turns between the player and computer) it resets the global and if the player plays level 1 again (even if they have completed it) the global gets reset and if they die or use the 'menu page button' the lvl2 button is invisible again.

I've tried sooo many different ways from saving to local variables, really what I need is a way to do this on the menu page:

If lvl2 button visible then permanently change global to 1 from 0, then when the player goes back to lvl and all global are reset, the global that I want is reset to 1, which keeps the lvl2 button visible.

I thought 'set global' would have set it permanently?

Is this possible or is there another way that I'm missing?

Thank you.


If you use "reset global variables" it does exactly that and will reset all of them to their default values. What you can do instead if you rely on these global variables for switching between player and computer turn, is to make a "Sprite controller". Basically this is just a normal sprite that you add to your project, make it something like 16x16 pixel so it doesn't use any resources and you could name it something like "Level controller" so you know what it is.

The only purpose of this sprite is to hold variables. So you simply add whatever you need to it that is related to switching and keeping track of levels. You then turn it into a global object in the "Properties" menu and that way you will have access to it through out all your layouts.

"Reset global variables" doesn't reset these variables.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Dec 21, 2016 12:01 pm

Well knock me down with a feather! it worked! Thank you so much nimos100

I was worried to post on here, (I seem to ask a lot of dumb questions) and was also worried there wasn't a way to do it.
But that's such a cool way I didn't know that could be done.

Me and my game thank you :)
B
10
S
3
Posts: 56
Reputation: 804

Post » Wed Dec 21, 2016 12:15 pm

MarkThomas wrote:Well knock me down with a feather! it worked! Thank you so much nimos100

I was worried to post on here, (I seem to ask a lot of dumb questions) and was also worried there wasn't a way to do it.
But that's such a cool way I didn't know that could be done.

Me and my game thank you :)


Don't ever be afraid to ask questions - that's how we all learn :)
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,545
Reputation: 60,434

Post » Wed Dec 21, 2016 5:00 pm

MarkThomas

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

here find file called Select Level capx file
B
257
S
42
G
15
Posts: 1,991
Reputation: 41,411


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests