qwertxp Posted August 5, 2014 Share Posted August 5, 2014 how to set bounce only collide object top side?and for other object should bounce when collide all sides.how to done this?thanks for your help and sorry for my poor english. Link to comment Share on other sites More sharing options...
cub Posted August 5, 2014 Share Posted August 5, 2014 What physical system do you use?With P2.js you can use the materials to vary friction/restitution...See :http://schteppe.github.io/p2.js/demos/restitution.htmlhttp://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=platformer+material.js&t=platformer%20material With Arcade you can check collide withgame.physics.arcade.collide(player, layer, onCollide);And check touching (up, down, left or right)function onCollide(a, { if (a.body.touching.up === true) { // particular bounce when top hit }} Link to comment Share on other sites More sharing options...
qwertxp Posted August 5, 2014 Author Share Posted August 5, 2014 What physical system do you use?With P2.js you can use the materials to vary friction/restitution...See :http://schteppe.github.io/p2.js/demos/restitution.htmlhttp://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=platformer+material.js&t=platformer%20material With Arcade you can check collide withgame.physics.arcade.collide(player, layer, onCollide);And check touching (up, down, left or right)function onCollide(a, { if (a.body.touching.up === true) { // particular bounce when top hit }}i use Arcade, i have try this, if (a.body.touching.up === true) { a.body.bounce.setTo(0.8);} but it not run as my expected, object a will not bounce when first hit, after first hit, it will bounce.i want object a bounce when object a top side hit object b, otherwise object a should not bounce. Link to comment Share on other sites More sharing options...
cub Posted August 5, 2014 Share Posted August 5, 2014 Sorry but... can you explain what you want with a draw ?function onCollide(a, {"a" is a reference of your first params in game.physics.arcade.collide() and "b" the secondSo "a" === player and "b" === layer in my last post. object a will not bounce when first hit, after first hit, it will bounceYou want to delay the bounce ? Link to comment Share on other sites More sharing options...
qwertxp Posted August 6, 2014 Author Share Posted August 6, 2014 Sorry but... can you explain what you want with a draw ?function onCollide(a, {"a" is a reference of your first params in game.physics.arcade.collide() and "b" the secondSo "a" === player and "b" === layer in my last post. object a will not bounce when first hit, after first hit, it will bounceYou want to delay the bounce ?yes, object a is player, i want object a bounce when object a top side touch object b.object a should not bounce if object a top side not touch object b.but when i use 'a.body.bounce.setTo(0.8);', object a will bounce when touch another object. Link to comment Share on other sites More sharing options...
cub Posted August 6, 2014 Share Posted August 6, 2014 If "layer" from game.physics.arcade.collide(player, layer, onCollide); is a group that contain only object where you want bounce effect there should be no problem. The function onCollide will start only when you hit your special zone. And then it checks if you are touching.up.You may check the other side (down, left, right) is false to be sure you are not collide your special zone at left for exemple and your are hitting, at the same time, an other sprite on the top. Link to comment Share on other sites More sharing options...
Recommended Posts