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

217
Visualizações
phaser 3 throws "Texture.frame missing:" warning and fails to load frame, how do I fix it?

Note: my code is already running and rendering the sprite

just one click to play with


I'm learning a phaser3 loader example

here is the code I wrote

class BootScene extends Phaser.Scene {
  constructor() {
    super();
  }
  preload() {
    this.load.path = 'https://raw.githubusercontent.com/liyi93319/phaser3_rpg/main/part1/assets/';
    this.load.atlas('player', 'knight_atlas.png', 'knight_atlas.json');
  }
  create() {
    var player = this.add.sprite(80, 100, 'player', 0);
    player.setScale(.5);
  }
}

var config = {
  width: 400,
  height: 300,
  pixelArt: true,
  physics: {
    default: 'arcade',
    arcade: {
      gravity: { y: 0 },
    }
  },
  backgroundColor: 0x000000,
  scene: [BootScene]
}

var game = new Phaser.Game(config);
<script src="https://cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"></script>

Everything works fine so far.

However, changing the create() as follows

  create() {
    var player = this.add.sprite(80, 100, 'player', 5);
    player.setScale(.5);
  }

doesn't load the frame as expected and throws a warning

Texture.frame missing: 5

I compared the 'knight_atlas.json' file with the one from the official example. I don't see the difference.

I also checked the doc but didn't find a solution.

What am I missing?

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

0

If you want to use the third parameter you would have to use the string (or Texture Object), in this case the filename from the atlas should work. Here the is relevant documentation

class BootScene extends Phaser.Scene {
  constructor() {
    super();
  }
  preload() {
    this.load.path = 'https://raw.githubusercontent.com/liyi93319/phaser3_rpg/main/part1/assets/';
    this.load.atlas('player', 'knight_atlas.png', 'knight_atlas.json');
  }
  create() {
    var player = this.add.sprite(80, 100, 'player', 'Attack (3).png');
    player.setScale(.5);
    
    var player2 = this.add.sprite(240, 100, 'player', 'Idle10');
    player2.setScale(.5);
  }
}

var config = {
  width: 400,
  height: 300,
  pixelArt: true,
  physics: {
    default: 'arcade',
    arcade: {
      gravity: { y: 0 },
    }
  },
  backgroundColor: 0x000000,
  scene: [BootScene]
}

var game = new Phaser.Game(config);
<script src="https://cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"></script>

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