嘿伙计,所以我有一个由地图集加载的精灵,我无法移动或应用物理到它,请看下面的代码:
谁能告诉我,我做错了什么?基本上我得到的只是精灵而不是在屏幕边缘移动。
//I load here:
this.load.atlas('Monsters', 'images/monsters.png', 'images/monsters.json');
/////////timer to initiilize
this.timerFiguras = this.time.events.loop(1000, this.makeFiguras, this);
/////////// below that 2 functions
makeOneFigura: function() {
this.figurai = this.game.add.sprite(0, 450, 'Monsters', this.rnd.integerInRange(0,4));
this.figura = this.game.add.group();
this.figura.enableBody = true;
this.game.physics.p2.enable(this.figura, false);
this.figura.add(this.figurai);
this.figura.setAll('anchor.x', 0.5);
this.figura.setAll('anchor.y', 0.5);
this.figura.setAll('outOfBoundsKill', true);
this.figura.setAll('checkWorldBounds', true);
},
makeFiguras: function(){
this.figuras = this.figura.getFirstExists(false);
if (this.figuras) {
this.figuras.reset(0, 450);
this.figuras.body.velocity.x = 1000;
}
},