2017-02-17 19 views
0

我有一组对象,我想访问被触摸的对象(使用game.physics.arcade.overlap),因为我需要访问它的一个变量。任何人都可以指出我的建议吗?提前致谢。PHASER - 访问组内的obj变量

回答

1

没有指定物理学的类型,但我以为这是商场:当事件发生时,你可以用它来“sprite vs group”或“group vs group

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); 
    } 

的“碰撞”功能捕捉族元素“(用ARCADE物理)

+0

非常感谢! – UpARiver