maxxxir Posted October 10, 2015 Share Posted October 10, 2015 i've updated this question ... i couldn't edit the title to something mor appropriate--------------------------------------- im trying to build a pool game as my first phaser projectthe biggest challenge today was to make the cue rotate around the white ball ... after hours of searching and not finding anything useful (there is a example about rotating points but no sprits ) i was able to crate something , not very clean but it workshere is the white ball balls = game.add.group(); balls.enableBody = true; balls.physicsBodyType = Phaser.Physics.P2JS; wball = balls.create(350, 240 , 'ballW'); wball.body.setCircle(15); wball.body.setCollisionGroup(wballCollisionGroup); wball.body.collides([wballCollisionGroup, ballsCollisionGroup , sidesCollisionGroup , holesCollisionGroup , playerCollisionGroup]); game.physics.p2.setImpactEvents(true);here is the cue which i call it player player = game.add.sprite( 0 , 0 , 'player');game.physics.p2.enable(player);player.enableBody = true;player.body.setCollisionGroup(playerCollisionGroup);player.body.setZeroVelocity();player.body.createBodyCallback(wball, ballHit , this);player.anchor.setTo(-0.5, 0.5);player.pivot.x = wball.x +150;player.pivot.y = 0;player.body.x = wball.x ;setTimeout(function(){player.body.y = 150 ;} , 1000 );setTimeout(function(){player.body.y = 200 ;} , 2000 );setTimeout(function(){player.body.y = 240 ;} , 3000 );as you can see i have set the y position for player in 3 steps to demonstrate the problemit starts at the top of the page and comes down .. as soon as i set y=240 which is the wball y a collision happens even tough we can see clearly they are not colliding !pleas note both codes are in the create function here is the live codehttp://199.26.84.223/ Link to comment Share on other sites More sharing options...
jmp909 Posted October 10, 2015 Share Posted October 10, 2015 i think you may need to remove the body then add it againhttp://www.html5gamedevs.com/topic/13832-turning-p2-physics-on-and-off/https://github.com/photonstorm/phaser/issues/1362 maybe sleepMode could help. http://phaser.io/docs/2.3/Phaser.Physics.P2.html#sleepMode Link to comment Share on other sites More sharing options...
MattMcFarland Posted October 11, 2015 Share Posted October 11, 2015 Maybe you should make the ball not collidable, at least not until everything is ready. You could create an event that fires once everything is ready, then turn collisions on. Link to comment Share on other sites More sharing options...
maxxxir Posted October 11, 2015 Author Share Posted October 11, 2015 thanx ... for anyone having this problem here is the answer http://gamedev.stackexchange.com/questions/109520/collision-happens-even-though-the-objects-are-not-colliding-according-to-what-we/109551#109551 Link to comment Share on other sites More sharing options...
Recommended Posts