Is touching firing in more than one layout

0 favourites
  • 6 posts
From the Asset Store
5 Types of Touch Buttons containing 90 touch buttons from D-Pads to Touch Joy Sticks and more.
  • 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.   <img src="smileys/smiley1.gif" border="0" align="middle" />

  • 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 ;)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thankyou that is just what I needed.

  • Why don't you use 'on touched' on the buttons instead of 'is touching'?

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)