[Resolved] solving a rogue "tap" event ?

So, on my menu screen I press a ui.button and it’s onRelease fires me to a new scene.

In the new scene, I immediately set up a “tap” listener for an image.

The tap event listener works fine, telling me in the console window every time I tap the screen.

HOWEVER amd here’s the problem - when I initially enter this scene from the ui.button above, the tap event fires ONE TIME immediately, without me touching anything.

Is it possible its a caused by the previous ui.button ? And what’s the best way to solve this ?
[import]uid: 97524 topic_id: 26105 reply_id: 326105[/import]

I don’t think it is caused by the previous ui.button because you set it to fire onRelease which means your finger has to leave the screen in order for this to fire.

You can try adding a delay timer (short like 100ms) to the tap event so the tap activates 100ms after you get to the next screen.

You can also use touch event with ended phase for the menu button to detect that the touch has ended. [import]uid: 39031 topic_id: 26105 reply_id: 105717[/import]

Thanks.

I tried replacing the ui.button with a normal image with “touch” event. I touched it, the touch event fired, telling me in the console window, and moved onto the next scene.

The tap event fired immediately as it always does?!

So I tried changing the tap event listender to a touch event listener and this works perfectly.

Think I might try your delay idea.

But there’s a rogue tap event triggering somehow! It’s just I’d love to know what’s causing it. I’m using director 1.4 and it’s happening as soon as I’m entering pages.lua (see the books example that comes with director 1.4)
[import]uid: 97524 topic_id: 26105 reply_id: 105720[/import]

Update:

Took your advice and added a 200ms delay before I issue the director1.4 commands to change the scene AND IT WORKS!!! :wink:

Big thanks!

Think I’ll now try your other suggestion of adding a touch listener to the previous scene’s ui.button and checking to see if phase == “ended” makes any difference. [import]uid: 97524 topic_id: 26105 reply_id: 105730[/import]

Solution

Director1.4 seems to have a bug in that if you add a tap eventListener to pages, it takes at least 2 taps to execute a turnToScenes() command

The temporary solution i came up with was to use a touch event listener to behave like a tap event listener…

Simply add some logic…

If event.phase == “ended”

If event.x == event.xStart then
turnToScenes()
changeScene (“your scene”)
End

End
[import]uid: 97524 topic_id: 26105 reply_id: 105802[/import]

I never used turnToScenes() so I am not familiar with it but glad you figured it out and thanks for posting the solution for others! [import]uid: 39031 topic_id: 26105 reply_id: 105824[/import]