PhaserJS游戏对象“更新”不起作用

时间:2018-06-29 20:46:54

标签: phaser-framework

由于某种原因,对象水母上没有发生对象更新。 这是否可能是因为对象保存在数组中而不是相位游戏对象中?

请参阅代码结尾处的功能 console.log('UPDATE TEST');

BasicGame.Landing = function (game) { this.game; this.add; this.camera; this.cache; this.input; this.load; this.math; this.sound; this.stage; this.time; this.tweens; this.state; this.world; this.particles; this.physics; this.rnd;  };

var jellys = [];

BasicGame.Landing.prototype = {

    create: function () {
        for (var i = 0; i < 10; i++) {
            var jelly = new JellyFish(this);
            jellys.push(jelly);
        }
    },

    update: function () {
        //NOT THIS UPDATE
    }
}


JellyFish = function (objectScope) {
    var game = objectScope.game;

    this.alive = true;
    this.speed = 2;

    var min = 0;
    var max = game.world.width;
    var x = Math.random() * (max - min) + min;

    var min = 0;
    var max = game.world.height;
    var y = Math.random() * (max - min) + min;

    this.fishBody = game.add.sprite(x, y, 'spJellyFish');
    this.fishBody.animations.add('eat');    
    this.fishBody.animations.play('eat', 30, true);
    this.fishBody.anchor.set(0.5,0.5);

    var min = -180;
    var max = 180;
    var rot = Math.random() * (max - min) + min;

    return this;
};

JellyFish.prototype.constructor = JellyFish;

JellyFish.prototype = Object.create(Phaser.Sprite.prototype);

JellyFish.prototype.update = function(){
    console.log('UPDATE TEST');
}

0 个答案:

没有答案