我正在使用Phaser,我正在使用模塊模式,創建一個模塊,其原型爲Object.create(Phaser.Sprite.prototype)
並在主模塊中創建該模塊的一個實例。移相器模塊模式和精靈
問題是精靈似乎在創建函數的主模塊中創建,但精靈的圖像未加載,我無法找到問題或設置圖像。
非常感謝!
在Player.js:
// doenst work at all with game.load... on top
//game.load.spritesheet('playersheet', 'resources/data/foo.png', 64, 64);
Player = function(game, x, y){
game.load.spritesheet('playersheet', 'resources/data/foo.png', 64, 64);
Phaser.Sprite.call(this, game, x, y, 'playersheet');
this.anAttribute = 'whatever'; this.anotherAttribute = 20;};
Player.prototype = Object.create(Phaser.Sprite.prototype);
Player.prototype.constructor = Player;
拋出:
Phaser.Loader - 腳本[播放]:從URL資源/ JS錯誤裝載資產/ Player.js
和
Phaser.Cache .getImage:Cache中找不到的關鍵「playersheet」。
主:
預緊力game.load.script('Player', 'resources/js/Player.js');
在創建
testPlayer = new Player(game,77,77);
非常感謝,這真的幫助,真的很感謝 –