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

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

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