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

96
Visualizações
Phaser3 framework javascript: current anims index

In phaser 3 framework, what syntax do I use to check the current frame index?

I want to make a hit area appear only when the player's sprite sheet reaches a certain index(the index displaying the motion of 'attack'). I want to accomplish this through detecting its current frame index.

How can I do this?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You could use the sprite events like: Phaser.Animations.Events.ANIMATION_UPDATE, details in official phaser documenation

    player.on(Phaser.Animations.Events.ANIMATION_UPDATE, function (anim, frame, gameObject, frameKey) {
       // Here you can check for the specific-frame
       if(frameKey == "show_hit_area_frame"){
           // ... show hitarea
       }

       // alternatively: with the index of the frame
       if(frame.index == 7){
           // ... show hitarea
       }
    });

In this selected Event, you can also check the current frame, for other properties of the frame object (details in official documenation), if you don't know/have the specific framekey/index.

about 4 years ago · Juan Pablo Isaza Relatório

0

The solution is found. //hitbox solution: https://newdocs.phaser.io/docs/3.52.0/Phaser.Animations.Events.ANIMATION_COMPLETE_KEY

//hitboxB listener
    gameState.playerB.on('animationstart-kill', function () {
      console.log("finish kill <3")
      gameState.hitBoxB.x = gameState.playerB.flipX ? gameState.playerB.x + 120 : gameState.playerB.x - 120;
      gameState.hitBoxB.y = gameState.playerB.y;
      // gameState.hitBoxB.visible = true;

    })
    gameState.playerB.on('animationcomplete-kill', function () {
      console.log("kill <3")
      gameState.hitBoxB.x =0 ;
      gameState.hitBoxB.y = 0;
      // gameState.hitBoxB.visible = false;
      
    })
about 4 years ago · Juan Pablo Isaza 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