0
對於大學我必須創建一個遊戲,我的遊戲涉及到下降的對象。但我不知道如何失去生命當對象超出界限。Phaser 2精靈檢測邊框?
繼承人我的一些代碼:當他們離開世界的界限
//my variables
var player;
var lives;
var max_lives = 3;
var objects;
var totalLife
var lifeText;
var totalScore;
var scoreText;
var inputs;
//creates the group for the objects
objects = this.add.group();
this.physics.enable(objects, Phaser.Physics.ARCADE);
objects.setAll('outOfBoundsKill', true);
objects.setAll('checkWorldBounds', true);
//spawns object
spawnObject: function() {
var random = this.rnd.integerInRange(0, 25);
if (random === 0) {
var randomX = this.rnd.integerInRange(0, this.world.width - 150);
var object = objects.create(randomX, -50, 'object');
this.physics.enable(object, Phaser.Physics.ARCADE);
object.body.velocity.y = this.rnd.integerInRange(200, 300);
}
}