Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda