Page 1 of 1

Struggling with events order and animation

Posted: 06 July 2024, 00:17
by Angst03
Hi,

I'm having some sort of timing issues and would like to know what are best practices for this kind of problem in BGA Studio. Here's what it looks like:

I have some cards that I dojo.connect in the onEnteringState event. An action move the selected card somewhere, destroys it and then creates a new one (same HTML id as the original if it matters). The movement, destruction and re-creation happens in the action notification event. The destruction and re-creation is like 1 second into the animation process.

I've put some trace in my code and the events are triggered in the following order (the order is good):

1. MyActionNotification
2. onUpdateActionButtons
3. onEnteringState

So even though the MyActionNotification event is triggered first, the onEnteringState event is triggered before the animation is finished and the "new" card is not dojo.connect-ed because the dojo.connect is done on the card that will be destroyed less than 1 second later and not on the "new" card.

Looking for any advice for this situation.

Re: Struggling with events order and animation

Posted: 06 July 2024, 16:11
by vurtan
Hi,

is your notification synchronous or async? If it is async you can change it.
https://en.doc.boardgamearena.com/Game_ ... ifications

An other option would be to not destroy the object and leave it as it is. That will depend on our code if possible.

Re: Struggling with events order and animation

Posted: 06 July 2024, 23:19
by Angst03
I will try synchronous notifications. Thank you for your answer.

Re: Struggling with events order and animation

Posted: 07 July 2024, 17:18
by Angst03
Only to let you know that synchronous notifications did the trick. Thanks again!