• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

280
Vistas
Images not loading (Phaser)

I am trying to load/show my sprites into the Game Scene, but it's not working.

This is my code for the Game scene:

import Phaser from 'phaser';

export default class Game extends Phaser.Scene
{
    preload()
    {
        this.load.atlas("asteroid1","Bilder/asteroid1-0.png","Bilder/asteroid1.json")
        this.load.multiatlas("asteroid2","Bilder/asteroid2.json","Bilder")
    }

    create()
    {
        this.add.text(40,250, 'Hello')
        this.asteroid = this.add.sprite(200,200,"asteroid1")
        this.asteroid2 = this.add.sprite(100,200,"asteroid2")
        var background = this.add.sprite(0, 0, 'asteroid2', 'Bilder/asteroid2-0.png');
    }
}

This is the beginning of the json file that was created by TexturePacker.

{
        "textures": [
        {
            "image": "asteroid1-0.png",
            "format": "RGBA8888",
            "size": {
                "w": 2007,
                "h": 2002
            },
            "scale": 1,
            "frames": [
                {
                    "filename": "android01_00000.png",
                    "rotated": false,
                    "trimmed": true,
                    "sourceSize": {
                        "w": 2000,
                        "h": 2000
                    },
                    "spriteSourceSize": {
                        "x": 832,
                        "y": 865,
                        "w": 365,
                        "h": 443
                    },
                    "frame": {
                        "x": 1,
                        "y": 1,
                        "w": 365,
                        "h": 443
                    }
                },

My files

Pictures not loading

Errors

Appreciate your help!

about 3 years ago · Juan Pablo Isaza
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda