jakubdev Posted September 24, 2020 Share Posted September 24, 2020 Hello, As once played AnimatedSprite stop on penultimate frame and i want to use same AnimatedSprite from start on another round to safe some lines, but when i use gotoAndPlay(0) it just plays one frame and stops also adding play() afterwards doesn't help. There aren't any errors catch'ed and I couln't find something special on profiler ,but I'm quite bad at it. export const attackEnemy = (playerTurn, enemyTurn, app, delta) => { return new Promise((resolve, reject) => { try { const [playerTurnIdleSprite, playerTurnCurrentSprite, enemyIdleCurrentSprite, enemyTurnCurrentSprite] = getBattleSprites(playerTurn, enemyTurn) const {playerOne, playerTwo} = getPlayersPositions(playerTurnIdleSprite, enemyTurnCurrentSprite); // To be replaced const dumbFunction = () => { if (!firstStep && playerTurnIdleSprite.x >= -playerTwo.x) { playerTurnIdleSprite.x -= 2 * delta if (playerTurnIdleSprite.y >= playerTwo.y) { playerTurnIdleSprite.y -= 2 * delta; playerTurnCurrentSprite.y = playerTurnIdleSprite.y; } } else if (!firstStep) { playerTurnCurrentSprite.x = playerTurnIdleSprite.x playerTurnIdleSprite.visible = false; playerTurnCurrentSprite.visible = true; playerTurnCurrentSprite.gotoAndPlay(0); enemyIdleCurrentSprite.visible = false; enemyTurnCurrentSprite.visible = true; enemyTurnCurrentSprite.gotoAndPlay(0); } playerTurnCurrentSprite.onComplete = () => { firstStep = true; playerTurnIdleSprite.visible = true; playerTurnIdleSprite.play(); playerTurnCurrentSprite.visible = false; enemyIdleCurrentSprite.visible = true; enemyIdleCurrentSprite.play(); enemyTurnCurrentSprite.visible = false; } if (firstStep && playerTurnIdleSprite.x <= playerOne.x) { playerTurnIdleSprite.x += 2 * delta if (playerTurnIdleSprite.x > playerOne.x) { playerTurnIdleSprite.x = playerOne.x; app.ticker.remove(dumbFunction, dumbFunction); firstStep = false; resolve('success'); } } } app.ticker.add(dumbFunction, dumbFunction) } catch (e) { console.log(e); reject(e); } }) } Quote Link to comment Share on other sites More sharing options...
jonforum Posted October 4, 2020 Share Posted October 4, 2020 (edited) it should work here a demo for you. can you make small demo to reproduce the issue ? https://www.pixiplayground.com/#/edit/J7rBe3O4pe_pZfxqKRWU_ Edited October 4, 2020 by jonforum Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.