Is touching firing in more than one layout

Get help using Construct 2

Post » Sat Jan 05, 2013 8:09 pm

I have a menu system for my game, which just passes the user between a set of different layouts, like this:

MainMenu > LevelSelect > Level1

Both the LevelSelect & Level1 layouts have a back button on them, which have actions bound to the is toughing event. On the LevelSelect layout the back buttons action is to go to MainMenu layout and this works just fine.

With the Level1 layout the back button's action is to go to the LevelSelect layout. When I click this button it first takes me back to the LevelSelect layout, as expected, and then immediately goes back to the MainMenu layout.

It looks to me like the is touching event is still active when the LevelSelect layout is displayed and since the back buttons are in the same place on both layouts the event on the LevelSelect layout is fired too.

I hope I have explained this clearly. It seems like a simple issue, but I can't seem to find a way to fix it, any help would be appreciated.   
B
3
Posts: 5
Reputation: 710

Post » Sat Jan 05, 2013 8:21 pm

On first layout, set a global variable (global canTouch = 1)

In all your touch events...

+ on back button touched
+ if canTouch = 1 <<<<<<<< add this condition
-> canTouch = 0   <<<<<<<< and this action
-> go to layout whatever

and also in every layout add..

+ on touch end
-> canTouch = 1

I'm pretty sure that'll work. Post your capx for better answers ;)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Sat Jan 05, 2013 8:41 pm

Thankyou that is just what I needed.
B
3
Posts: 5
Reputation: 710

Post » Sat Jan 05, 2013 8:47 pm

Why don't you use 'on touched' on the buttons instead of 'is touching'?ramones2013-01-05 20:48:06
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Jan 05, 2013 9:23 pm

Ah I misread and thought he was using on touched (hence what's in my reply). I thought it was firing every time the layout changed as the OP suggested. In that case yeah, you shouldn't need to use a global variable then.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Sun Jan 06, 2013 2:44 am

becaused onTouched object still fires if the menu change is too fast. I had this troubled where I had an object for the first touch(ie Touch to Start). however I had a menu object on a different layout, but if I touched the start in the same place. Both objects on two different layouts would fire the event. crummy. So isTouching or onTouched will produce the same even in this case.

My suggestions it to add a wait 0.5. That's long enough for the fire event to finish triggering. So it will trigger once, end the trigger event. then change to the new layout. jayderyu2013-01-06 03:03:55
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests