transition.to() blocking other code

In my game, when you click the character the board gets overlayed with the spaces he’s able to move to. When you click one of those spaces, I move him there using transition.to() and then clear the overlay using object:removeSelf()

When I run the code, the character slides nicely to his new spot, but the overlay doesn’t clear. It’s not until I click the character again (to select him in preparation for another move) that the overlay goes away.

I know that in Corona the screen is not drawn until all the code has finished running, and if I comment out the transition.to() call then the overlay clears immediately after clicking the new location. But even if the screen doesn’t update before the transition animation begins, shouldn’t it at least update once it’s done?

That said, what’s the best way around this? Using the onStart or onComplete callback in the transition seems clunky. Using coroutines seems like overkill. I simply want to clear the overlay, and then begin the transition. [import]uid: 42158 topic_id: 29104 reply_id: 329104[/import]

It’s doubtful that transition.to is blocking. Something is just not unfolding the way you expect it to in the code. Please post some code so we can get a better look at what you are doing.

In your last sentence you say you want to “clear the overlay, and then begin the transition.” Did you try putting the object:removeSelf() directly before the transition? No need for it to be directly after, the tranistion will start and the overlay removed before the user gets a screen update. [import]uid: 56820 topic_id: 29104 reply_id: 117086[/import]

Attach some code, and it would be easier to assist you!

Joakim [import]uid: 81188 topic_id: 29104 reply_id: 117089[/import]

I didn’t attach any code because it’s deeply nested in a bunch of pseudo-classes.

You’re right though, it’s not the transition that’s blocking the refresh. It’s that my “selectUnit()” method was getting called twice through some faulty event checking which was creating two overlays! Thanks for helping me look past what I was fixated on. [import]uid: 42158 topic_id: 29104 reply_id: 117102[/import]