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

232
Views
how to change character in phaser js i face issue

I set value of character but first time is work fine charter changed but when gameover then if i change the character value will be changed but character still same which i choose first time.

    this.player = this.physics.add.sprite(100, -500, this.charSelect).setOrigin(1, 1);
    this.player.body.setGravityY(1700);
    this.player.setBounce(0.1);

    this.physics.add.existing(this.player).body.setSize(15, 90, ).setOffset(20, 0)

this.charSelect is the variable where charachter name are stored. the value of this.charSelect is change but character still same

    this.load.spritesheet("dude-1", "../src/assets/Character/ch-1.png", {
        frameWidth: 72,
        frameHeight: 92,

    });

    this.load.spritesheet("dude-2", "../src/assets/Character/ch-2.png", {
        frameWidth: 72,
        frameHeight: 92,

    });
    this.load.spritesheet("dude-3", "../src/assets/Character/ch-3.png", {
        frameWidth: 72,
        frameHeight: 92,

    });
    this.load.spritesheet("dude-4", "../src/assets/Character/ch-4.png", {
        frameWidth: 72,
        frameHeight: 92,

    });
    this.load.spritesheet("dude-5", "../src/assets/Character/ch-5.png", {
        frameWidth: 72,
        frameHeight: 92,

    });
    this.load.spritesheet("dude-6", "../src/assets/Character/ch-6.png", {
        frameWidth: 72,
        frameHeight: 92,

    });
    this.load.spritesheet("dude-7", "../src/assets/Character/ch-7.png", {
        frameWidth: 72,
        frameHeight: 92,

    });
    this.load.spritesheet("dude-8", "../src/assets/Character/ch-8.png", {
        frameWidth: 72,
        frameHeight: 92,

    });

here is above character loading in spritesheet

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You would have to call the function setTexture of the sprite object, to change the texture. here is the link to the documentation, after the reselecting of a new character, or restarting of the game:

 this.player.setTexture(this.charSelect);
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!