Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
How to set phaser 3 sprite animation to frame 1

I am currently developing a level creator platformer game using Phaser 3 and arcade physics. I have a tilemap that I use for the ground. For animated tiles I have a system where I create sprites at the positions in a grid similar to the tilemap. I have it setup so that when I press "M" on the keyboard, it turns on a "creative" mode and brings all of the sprites back to their initial positions. The issue is that the animations are not in sync and because of that, although the sprites go to the right position, the animation offsets it and the sprites aren't in their grid. I have tried stopping and starting the animation when they reset but it doesn't seem to have much of an effect. Is their a way that I can set them to frame 1 easily? do I need to subtract the current frames offset and use that to position them?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Well I'm not 100%, if this is the solution you are looking for, but with sprite.setFrame(...) (link to documentation) you can set the frame of a sprite to a specific FrameIndex, and with this.anims.get(...).frames[0].textureFrame) (link to Docs) you could get the first frame of a specific animation.

So you could theoretically, do something like:

 sprite.setFrame(this.anims.get(animationName).frames[0].textureFrame)

or if you just want to set the first frame of the current animation(link to documentation). Seting the progress to 0 sets the frame to the first frame, of the current animation.

sprite.anims.currentAnim.getFrameByProgress(0);
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda