我想延迟2秒触发一个功能,该功能将我的球重置到标准位置并在击中球门时提高得分。
我的游戏是这样的:
goal = game.add.sprite(35, 428, 'goal');
game.physics.p2.enable(goal, true);
goal.body.static = true;
goal.physicsBodyType = Phaser.Physics.P2JS;
goal.body.data.shapes[0].sensor = true;
var shape = new p2.Circle();
ball = game.add.sprite( game.world.centerX, game.world.centerY, 'ball');
game.physics.p2.enable(ball);
ball.anchor.setTo(0.5, 0.5);
ball.body.collideWorldBounds = true;
ball.body.data.gravityScale = 1;
ball.body.clearShapes();
ball.body.addCircle(shape);
我使用Arcade物理学中的Overlap函数一次,但是在P2中有什么等效功能吗?