datahandler Posted January 14, 2018 Share Posted January 14, 2018 Let's say I have 3 balls in a game: large, medium, small. I want each of these balls to bounce to a maximum height (defined by me) but without bouncing at the top. Simply to arc naturally to the maximum height, then start falling again. Is there a straightforward way to accomplish this? Link to comment Share on other sites More sharing options...
Shb Posted January 14, 2018 Share Posted January 14, 2018 what do you mean by bounce? Do you mean when it hits the ground you want to it to bounce or do you mean you want it to be projected to a certain height and then fall back down? Link to comment Share on other sites More sharing options...
samid737 Posted January 14, 2018 Share Posted January 14, 2018 You could try something parabolic: If you don't need physics, then you can also use sine / trigonometric functions to get A similar bounce motion : For vertical bounce, Yoyoing A bouncing tween could work. Link to comment Share on other sites More sharing options...
datahandler Posted January 16, 2018 Author Share Posted January 16, 2018 Thank you Shb and samid737 for replying. Sorry if I did not explain myself very well. Basically, I created a javascript game (one level only) that I want to convert and continue to develop using Phaser (Arcade physics). The game is here Each ball spawned initially moves upwards before arcing and falling again. After the first bounce, the ball will continue to bounce at a fixed height determined by its type (large, medium etc). Note. the height after the first bounce may be lower than the balls initial height depending on where it was spawned. Getting a ball to bounce in Phaser is straightforward but I cannot work out how to keep bounce height fixed after the initial bounce. WIth my current attempt, the height the ball bounces is determined by the height from which it was spawned. I hope this makes more sense. Link to comment Share on other sites More sharing options...
datahandler Posted January 30, 2018 Author Share Posted January 30, 2018 In case this is of use to anyone, here's how I solved the issue this.hitGround = function() { this.body.velocity.y = -(Math.sqrt(2*this.body.gravity.y*(game.world.height/this.template.preferredHeightRatio))); } Link to comment Share on other sites More sharing options...
Recommended Posts