我不明白为什么这段代码不起作用。我将图像加载到引导状态,将精灵添加到预加载器状态,但setPreloadSprite
最终使图像甚至不显示。
这是我的小提琴:http://jsfiddle.net/J5fUE/115/
我做错了什么? Phaser 2.2.1
另外,我计划有两种不同的加载图像。有多个精灵/图像可以setPreloadSprite
吗?
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');