Hello,
In the game I'm developing, at one point I need to wait few seconds (2/3) to see if any player still want to do some action, before triggering the next state.
I tried with "sleep()", but the issue is everything is synchronous so the wait prevent players to play before the method related to the state execute.
What I want is:
- state "playerTurn" trigger "endTurn" at the end
- before endTurn is called, wait X seconds and let players still do action (slap the pile)
Here is what I did (with sleep implemented in first line of endTurn):
1. BuRner0 played a card, call method playCard() in 'playerTurn' state that triggers 'endTurn' state at its end
2. BuRner1 slapped the pile (during sleep)
3. BuRner0 slapped the pile (during sleep)
Here is what I get:

Here is what I want (same order as the pic):
3. BuRner0 plays 2 ♦
2. BuRner1 slapped the pile
1. BuRner0 slapped the pile
In the game I'm developing, at one point I need to wait few seconds (2/3) to see if any player still want to do some action, before triggering the next state.
I tried with "sleep()", but the issue is everything is synchronous so the wait prevent players to play before the method related to the state execute.
What I want is:
- state "playerTurn" trigger "endTurn" at the end
- before endTurn is called, wait X seconds and let players still do action (slap the pile)
Here is what I did (with sleep implemented in first line of endTurn):
1. BuRner0 played a card, call method playCard() in 'playerTurn' state that triggers 'endTurn' state at its end
2. BuRner1 slapped the pile (during sleep)
3. BuRner0 slapped the pile (during sleep)
Here is what I get:

Here is what I want (same order as the pic):
3. BuRner0 plays 2 ♦
2. BuRner1 slapped the pile
1. BuRner0 slapped the pile