Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
¿Cómo puedo detener el bucle de animación, pero no la mitad de la animación en Phaser 3?

Tengo una animación, que generalmente se supone que debe reproducirse 3 veces, por lo que la configuración actualmente dice repeat: 2 . Sin embargo, bajo cierta condición (el jugador deja de arrastrar un elemento) quiero que la animación termine y se detenga sin repetir.

Con eso quiero decir que no quiero que se detenga justo en el cuadro en el que se encuentra en el segundo, sino que quiero que termine de reproducirse hasta el último cuadro que asigné en frames y luego se detenga antes de que se repita.

¿Cómo sería capaz de hacer esto?

 // ANIMATION CREATED HERE this.anims.create({ key: "nom", frameRate: 12, frames: this.anims.generateFrameNames("chara", { prefix: "nom_000", start: 0, end: 4}), repeat: 2, }); this.input.on('drag', (activePointer, gameObject, dragX, dragY) => { gameObject.x = dragX; gameObject.y = dragY; if(Phaser.Geom.Intersects.RectangleToRectangle(gameObject.getBounds(), character.mouth.getBounds())) { gameState.snack_cursor.play("fries_cursor", true); // ANIMATION PLAYED HERE character.sprite.play("nom", true); } }); this.input.on('dragend', (pointer, gameObject, dragX, dragY) => { if (gameObject.anims.isPlaying) gameObject.anims.stop(); // ANIMATION STOPS HERE, BUT CURRENTLY AT WHATEVER FRAME IT'S AT if (character.sprite.anims.isPlaying) character.sprite.anims.stop(); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede utilizar la función stopAfterRepeat ( documentación ).
Simplemente llámelo con el parámetro 0 , y la animación actual finalizará, antes de que se detenga la animación. Creo que esto es lo que buscas.

 ... character.sprite.anims.stopAfterRepeat(0); ...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!