Phaser.io를 사용하여 간단한 무한 러너 게임을 제작할 계획입니다. 라이더가 있고 라이더 개체가 계속 움직입니다. 방해물이 몇 가지 있습니다. 충돌이 발생할 때를 감지하고 싶습니다. 하지만 충돌이나 겹침을 감지 할 수없는 것 같습니다. 도와주세요! Phaser.IO로 충돌을 감지 할 수 없습니다.
내 코드 조각의 일부
은 다음과 같습니다 -function create() {
//obstacles initialization
obstacles = game.add.group();
obstacles.enableBody = true;
//player initialization
player = game.add.sprite(10, 250, 'tuktuk'); game.physics.arcade.enable(player);
player.body.bounce.y = 0.2;
player.body.gravity.y = 800;
player.body.bounce.x = 0.2;
player.body.collideWorldBounds = true;
player.animations.add('right', [0,1,2], 20, true);
create_random_obstacle();
game.physics.arcade.enable(obstacles);
game.world.bringToTop(player);
game.physics.arcade.overlap(obstacles, player, after_collision, null, null);
}
감사! 나는 이것을 놓치고 있었다. 이제 작동합니다. –