philip9
January 24, 2019, 11:21am
1
Hi people, I started learning Phaser couple a days ago, I have rendered my game but I can’t set my background to the desired photo, the console doesn’t give me any errors and I can’t figure out what I am doing wrong? Here is my code:
var config = {
type: Phaser.AUTO,
width: 600,
height: 800,
physics: {
default: ‘arcade’,
arcade: {
gravity: {y: 500},
debug: false
},
scene: {
preload: preload,
create: create
}
},
};
var game = new Phaser.Game(config);
function preload() {
this.load.image(‘background’, ‘./assets/star-background.jpg’);
}
function create() {
this.add.image(400, 300, ‘background’);
}
function update() {
}
hcakar
January 24, 2019, 11:24am
2
Hello @philip9 ,
please see the examples here: https://labs.phaser.io/edit.html?src=src/game%20objects/images/single%20image.js
This one is a single image with rotation but you can find lots of them in labs.phaser.io
Please try to copy this:
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: 'arcade',
arcade: {
gravity: {y: 500},
debug: false
},
},
scene: {
preload: preload,
create: create
},
};
var game = new Phaser.Game(config);
function preload() {
this.load.image('background', './assets/star-background.jpg');
}
function create() {
this.add.image(400, 300, 'background');
}
function update() {
}
Only difference that you are using different kind of quetos use double or single quetos instead and it should work
1 Like
philip9
January 24, 2019, 12:23pm
3
Wow, so the problem was that my quotes were a different ASCI character? No wonder that was driving me nuts after checking so much examples, thanks!
1 Like