Jump to content

bounce problem


qwertxp
 Share

Recommended Posts

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.html

http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=platformer+material.js&t=platformer%20material

 

With Arcade you can check collide with

game.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

 

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.html

http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=platformer+material.js&t=platformer%20material

 

With Arcade you can check collide with

game.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

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 second

So "a" === player and "b" === layer in my last post.

 

object a will not bounce when first hit, after first hit, it will bounce

You want to delay the bounce ?

Link to comment
Share on other sites

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 second

So "a" === player and "b" === layer in my last post.

 

object a will not bounce when first hit, after first hit, it will bounce

You 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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...