Go to layout(by name) not working

Get help using Construct 2

Post » Wed Apr 03, 2013 11:54 pm

I've been trying to use Go to layout(by name) for quite a while and I have not been able to get it to work.

I have a layout called "2". When the player reaches the end of level 1 the global variable CurrLevel is set to the integer 2.

Then in the Go to layout(by name) field I've tried:

"" & CurrLevel
"CurrLevel"
str(CurrLevel)

None of these work. I know the code itself is executing because it works fine when I just use Go to layout and select from the drop down.

Any help on this small issue?
B
5
S
1
G
1
Posts: 28
Reputation: 615

Post » Thu Apr 04, 2013 1:14 am

What happens when you execute that? The layout just stays at level 1?

It could be an issue with your global variable not being changed for some reason. If you can share the capx I can look into it.rosareven2013-04-04 01:17:05
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Thu Apr 04, 2013 1:53 am

Here is the .capx https://dl.dropbox.com/u/54560475/issues.capx

The problem area is at the end of the Game Event Sheet.

Thank you so much.
B
5
S
1
G
1
Posts: 28
Reputation: 615

Post » Thu Apr 04, 2013 3:21 am

I got it.

First, remove the bottom event that you say is causing the problem. It's easier for me to explain this from scratch:

Player->On collision with Dimentionator->Add 1 to CurrLevel, Save game to mysave

(on a separate event, not sub event) System->On save complete->Go to layout str(CurrLevel)

=== That's it ===

"Trigger" condition, that is, the ones with the small green arrow on the event icons, cannot be used twice in an event block, including sub events.

"Is overlapping" will continuously append 1 onto CurrLevel, and "Trigger Once" can't stop it.

Ideally "On collision with" should be used instead of "overlapping", but because "on save complete" is a trigger in itself, "On collision with" isn't available as an option and "overlapping" just won't stop adding onto CurrLevel. The solution above will work.
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Thu Apr 04, 2013 3:28 am

Awesome thank you so much!
B
5
S
1
G
1
Posts: 28
Reputation: 615


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], mnmco and 39 guests