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

94
Views
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 answers
Answer question

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 Report

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 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!