【发布时间】:2015-09-18 10:20:51
【问题描述】:
我正在尝试将图像添加到我的画布,但出现以下错误:
Uncaught TypeError: Cannot read property 'hasLoaded' of undefined
它说错误来自这一行:
this.add.image('block',100,255);
index.html:
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Camera Learning</title>
<script src="js/phaser.min.js"></script>
<script src="js/states/boot.js"></script>
</head>
<body>
<script>
(function(){
var game = new Phaser.Game(450, 510, Phaser.AUTO, 'game');
game.state.add('boot', boot);
game.state.start('boot');
})();
</script>
</body>
</html>
boot.js:
boot = function(game){
console.log("%cStarting my awesome game", "color:white; background:red");
};
boot.prototype = {
preload: function(){
this.load.image('block','./res/borderblock.png');
},
create: function(){
console.log('adding');
this.add.image('block',100,255);
console.log('added');
}
};
【问题讨论】:
标签: javascript html canvas phaser-framework