Reputation: 11153
I don't see why this code isn't working. I load the images in a booter state, add the sprites in the preloader state, but setPreloadSprite
ends up making the image not even appear.
Here is my fiddle: http://jsfiddle.net/J5fUE/115/
What am I doing wrong? Phaser 2.2.1
Also, I am planning on having 2 different loading images. Is it possible to setPreloadSprite
for multiple sprites/images?
var game = new Phaser.Game(500, 500, Phaser.CANVAS, 'game_div');
var gameStates ={};
var hello;
gameStates.booter = function(){};
gameStates.booter.prototype = {
preload: function(){
game.world.setBounds(0,0,500,500)
game.load.image('hello', 'https://s3.amazonaws.com/uploads-1969f46zwpmbh5cm3kr2/hello.png');
},
create: function(){
game.state.start('preloader');
}
}
gameStates.preloader = function(){};
gameStates.preloader.prototype ={
preload: function(){
hello = game.add.sprite(150, 150, 'hello');
game.load.setPreloadSprite(hello);
},
create: function(){
}
}
// Add and start the 'main' state to start the game
game.state.add('booter', gameStates.booter);
game.state.add('preloader',gameStates.preloader);
game.state.start('booter');
Upvotes: 1
Views: 893
Reputation: 351
Another reason is that all of your assets are coming from cache.
You can verify if this is the case by going to Chrome Developer Tool > Network
. If your assets are coming from cache they will display "from cache" in the Size column.
What I did to see my progress bar is check the "Disable cache" option and refresh the page. This will ensure that all assets are loaded from their source and trigger the progress bar.
Upvotes: 0
Reputation: 3385
There's nothing wrong with your code / jsfiddle that I can see. The reason it doesn't appear is that you're not loading anything. If I add a bunch of load calls into your Preloader preload method then it fills up as normal for me as they load.
Upvotes: 1