Bug: UI Buttons + Director's Class

Hi,

so I just stumbled upon a problem when using director's class along with the UI-class. Here it is:
I've got an object that the user controls with the accelerometer. This object collides with other objects. Some of them make the game change scene to gameover.lua, some don't.

In the same scene I've got a pause button. Now, when I click and hold the pause button, and at the same time collide with a gameover object, director's class will change the scene, but everything will freeze afterwards. The pause button is gone, but the new buttons I've got in this new scene don't work?

Can someone confirm that this is a bug? Or is there a chance I'm doing something wrong?

Thanks in advance,

Are you managing your listeners correctly ?

I guess so.. They are working perfectly when not switching scenes

I'm thinking removing the listener for the pause button before switching scenes should solve this? But using the UI-class, how do you go about doing this? Since I'm assuming the listener is within the ui.lua file that I include at the top of my code?

Thanks,

what about stopping the object from moving when you press pause? or removing the accelerometer event while your game is paused....

UI.lua does not include the ability to remove listeners so if you switch screens and remove the buttons, the listeners are still there. This may be the reason the new buttons don't work.

Yeah I'm guessing that's what's causing this issue but I can't find a solution to this anywhere. Is it even possible to fix it?

Yup, use a different button library.

I made one because of this issue.

My site is down at the moment but i can upload it to a filesharing site if you want to try it

Sure! But does it work the same way or do I have to modify my code? Because I've got aaaaa lot of buttons..

@NahirC, I believe you can remove the Listeners yourself before switching screens. You need to do the following for each active button that was created with the UI library.

1
youButton:removeEventListener( "touch", yourButton )

It's still not working.. I get the same issue..

Edit: Can there be a problem with holding down the button then removing the eventlistener also?

You should only remove the button listeners on the button "release" event.

Holding down the button sets the focus (setFocus) on the button which needs to be released before the focus can go to any other object (e.g. other buttons). The focus is removed when the button is released.

If I can't remove the listener while holding down the button, it wont help my situation? :/ So I guess I've got to add a line of code making the button reach the release.event without the user actually letting go of the button before I switch scenes? I thought about this before but have no clue how to do it

I hope it's not too late to help you. I had the same problem and that worked out for me:

display.getCurrentStage():setFocus(nil)

I hope it works out for you too!

views:1393 update:2011/10/12 18:33:00
corona forums © 2003-2011