Struggling with events order and animation

Game development with Board Game Arena Studio
Post Reply
Angst03
Posts: 12
Joined: 01 September 2023, 19:04

Struggling with events order and animation

Post 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.
User avatar
vurtan
Posts: 57
Joined: 13 June 2020, 19:54

Re: Struggling with events order and animation

Post 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.
Angst03
Posts: 12
Joined: 01 September 2023, 19:04

Re: Struggling with events order and animation

Post by Angst03 »

I will try synchronous notifications. Thank you for your answer.
Angst03
Posts: 12
Joined: 01 September 2023, 19:04

Re: Struggling with events order and animation

Post by Angst03 »

Only to let you know that synchronous notifications did the trick. Thanks again!
Post Reply

Return to “Developers”