1
我下面這個教程,https://phaser.io/examples/v2/sprites/extending-sprite-demo-2,我有以下幾點:移相器 - 創建播放器對象
MonsterBunny = function (game, x, y, rotateSpeed) {
Phaser.Sprite.call(this, game, x, y);
var test = game.add.sprite(x, y, 'player');
test.rotateSpeed = rotateSpeed;
};
MonsterBunny.prototype = Object.create(Phaser.Sprite.prototype);
MonsterBunny.prototype.constructor = MonsterBunny;
MonsterBunny.prototype.update = function() {
this.angle += this.rotateSpeed;
console.log('a');
};
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.crossOrigin = 'anonymous';
game.load.image('player', 'http://examples.phaser.io/_site/images/prize-button.png');
}
function create() {
var wabbit = new MonsterBunny(game, 0, 100, 1);
var wabbit2 = new MonsterBunny(game, 150, 100, 0.5);
}
精靈不旋轉和update
功能不登錄控制檯。我該如何解決?謝謝。
但是,如果不喜歡,我們只建立一個精靈。我修改示例以在對象中創建多精靈 – DeLe
@BdR對於他的代碼是正確的。這裏是我分開做的一個更正的小提琴,所以它不包括'anchor'修飾:https://jsfiddle.net/31odrwLz/ –