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
}
},
Appreciate your help!