PHASER - 访问组内对象的变量
PHASER - Access var of obj inside of group
我有一组对象,我想访问正在触摸的对象(使用 game.physics.arcade.overlap),因为我需要访问它的一个变量。谁能指出我的任何建议?提前致谢。
您没有指定物理类型,但我认为它是街机:
function create()
{
...
bullets = game.add.group();
bullets.enableBody = true;
bullets.physicsBodyType = Phaser.Physics.ARCADE;
veggies = game.add.group();
veggies.enableBody = true;
veggies.physicsBodyType = Phaser.Physics.ARCADE;
...
//Create veggies, bullets, etc...
}
function update()
{
...
game.physics.arcade.overlap(bullets, veggies, collision, null, this);
...
}
function collision(bullet, veg)
{
console.log(bullet);
console.log(veg);
}
"collision"函数在事件发生时捕获组元素,可以用于“sprite vs group" or "group vs group”(带ARCADE物理)
我有一组对象,我想访问正在触摸的对象(使用 game.physics.arcade.overlap),因为我需要访问它的一个变量。谁能指出我的任何建议?提前致谢。
您没有指定物理类型,但我认为它是街机:
function create()
{
...
bullets = game.add.group();
bullets.enableBody = true;
bullets.physicsBodyType = Phaser.Physics.ARCADE;
veggies = game.add.group();
veggies.enableBody = true;
veggies.physicsBodyType = Phaser.Physics.ARCADE;
...
//Create veggies, bullets, etc...
}
function update()
{
...
game.physics.arcade.overlap(bullets, veggies, collision, null, this);
...
}
function collision(bullet, veg)
{
console.log(bullet);
console.log(veg);
}
"collision"函数在事件发生时捕获组元素,可以用于“sprite vs group" or "group vs group”(带ARCADE物理)