How do I fix this issue with Layouts?

Just started using Construct 2? Post your questions here

Post » Sun Mar 16, 2014 6:56 pm

Heya all! I seem to be having a problem. I have a layout called World and every 5-10 seconds it's supposed to goto a layout called Battle.
This works fine. When I click a button labeled "Flee" it's supposed to return to "World". Unfortunately it's just re-initializing combat.
I use the variable init_combat to detect when combat should be fired and I reset it to 0 before switching layouts. Debugging shows it DOES change, but it's still consistently sending me back to Battle.

In the event sheet for World:
Image

in the event sheet for Battle
Image
B
13
S
2
Posts: 34
Reputation: 757

Post » Sun Mar 16, 2014 9:19 pm

1. Try setting timescale as it may be making 5-10 seconds happen really fast. It is a system event.
Note: Set the timescale first. Also during debugging try setting wait to 10 just so you don't get confused by the inconsistency of random.

2. Why even have that init_combat variable in this case. You can remove "every random(5,10) seconds" and turn it into--

"On start of Layout" -> Wait random(5,10) -> Go to Battle
B
73
S
10
G
6
Posts: 105
Reputation: 7,577

Post » Sun Mar 16, 2014 9:33 pm

1: Alright I'll try that and get back to you. Thanks for the input!
2: You're absolutely right. That was the way it was set up originally. It's only there as a remnant of code from where I was trying to figure out what was going wrong. I'll remove it immediately.
B
13
S
2
Posts: 34
Reputation: 757

Post » Mon Mar 17, 2014 11:41 pm

you are waiting 5-10 seconds to set init_combat to 1
and then if inti_combat = 1
then set it to 0 and go to battle

i think you should do it like this

at start of layout
>wait 10-5 seconds
go to battle

when clicked
> do all the neccesary actions
and then go to world..

i dont know what purpose init_combat has??
B
23
S
6
G
3
Posts: 316
Reputation: 3,461


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests