jakubdev

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. Hello, I'm trying to stop one of tickers which animate text. As app.ticker can be removed when he knows function location in memory so I used atm hack to make it work. Allocating pulsateText function in arrow function to know exacly his location,but it makes unnecessary code. How can i achieve that easier?
  2. 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); } }) }