Skip to content

Commit

Permalink
animation
Browse files Browse the repository at this point in the history
  • Loading branch information
asiryk committed Sep 14, 2020
1 parent 73916ab commit 744be6e
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/core/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,25 @@ export default class Game {
}

handleStart() {
const start = Date.now()
this.playBtn.setDisabled();
this.reels.elements.forEach(reel => {
reel.spinOneTime()
.then(() => {
this.playBtn.setActive();
})
});
let finishedCounter = 0;
const tick = () => {
this.reels.elements.forEach(reel => {
reel.spinOneTime()
.then(() => {
if (Date.now() >= start + 2000) {
finishedCounter++;
}
if (finishedCounter === this.reels.elements.length) {
this.playBtn.setActive();
this.app.ticker.remove(tick);
}
})
});

}
this.app.ticker.add(tick);

}
}

0 comments on commit 744be6e

Please sign in to comment.