How to force stop a touch between scenes?

Hi guys,

I have a problem with a project I am working on. In short, there is a button which

the user must press in order to move a character. On event.phase == “began” I set

[lua] display.getCurrentStage():setFocus( event.target )[/lua]

and on event.phase == “ended”  I set this

[lua]display.getCurrentStage():setFocus( nil )[/lua]

However, there is a scenario when the character can die while the user holds the button and then

I go to a new screen using the storyboard API.

If the user holds the button after the scene changes I get a crash because the storyboard has cleared the previous scene.

Is there a way to force stop the touch before I change scenes?

Thanks

Have you tried calling display.getCurrentState():setFocus(nil) just before you call storyboard.gotoScene()?

Rob

Oh, thanks a lot, that fixed the problem. I didn’t know display.getCurrentStage():setFocus( nil ) can be called outside a touch listener - not sure why I thought this, maybe I have only seen it in such examples.

Anyways, thank you :slight_smile:

Have you tried calling display.getCurrentState():setFocus(nil) just before you call storyboard.gotoScene()?

Rob

Oh, thanks a lot, that fixed the problem. I didn’t know display.getCurrentStage():setFocus( nil ) can be called outside a touch listener - not sure why I thought this, maybe I have only seen it in such examples.

Anyways, thank you :slight_smile: