i3Designer Posted April 18, 2015 Share Posted April 18, 2015 I can not find a way to create a 100 % bounce as here :ARCADE BOUNCE I need to do with physics P2.PS:I tried with the body.restitution = 1, but does not work (as here) Link to comment Share on other sites More sharing options...
valueerror Posted April 19, 2015 Share Posted April 19, 2015 you either need to set the "global" p2 restitution to 1 or define two materials and a "contactmaterial" that defines what happens when bodies of those two materials meet.. and configure this contactmaterial to have restitution 1 if you want it to go on forever you need to deactivate the global damping Link to comment Share on other sites More sharing options...
i3Designer Posted April 20, 2015 Author Share Posted April 20, 2015 I tried with : " game.physics.p2.restitution = 1; " But the same does not work.Now try with the materials , you already have in mind the code ?IIn this example the sprite is always slower , as I do to get it going at the same speed ? I also disabled the gravity Link to comment Share on other sites More sharing options...
valueerror Posted April 20, 2015 Share Posted April 20, 2015 function create() { game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 1000; game.physics.p2.applyDamping = false; material1 = game.physics.p2.createMaterial(); material2 = game.physics.p2.createMaterial(); game.physics.p2.createContactMaterial(material1, material2, { friction: 0 , restitution: 1.0 }); var sprite1 = game.add.sprite(300, 100, ''); game.physics.p2.enable(sprite1,true) sprite1.body.setCircle(30); // sprite1.body.damping=0; sprite1.body.setMaterial(material1); var sprite2 = game.add.sprite(190, 400, ''); game.physics.p2.enable(sprite2,true) sprite2.body.setRectangle(600,20); sprite2.body.static = true; sprite2.body.setMaterial(material2); }something like this perhaps.. tips4design 1 Link to comment Share on other sites More sharing options...
i3Designer Posted April 20, 2015 Author Share Posted April 20, 2015 Thanks!!!!! this is solution game.physics.p2.applyDamping = false; and material Link to comment Share on other sites More sharing options...
valueerror Posted April 20, 2015 Share Posted April 20, 2015 you should know that if you disable damping for the whole gameworld nothing will (or at least in theory) ever stop moving.. except if friction is applied Link to comment Share on other sites More sharing options...
Recommended Posts