Jump to content

Search the Community

Showing results for tags 'body.bounce'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. So we have sprite moving left right and the aim is to make it stop when hit a "invisible" wall. Let's presume that the x coordinate checks are 0px and 300px, so: if(game.input.keyboard.isDown(Phaser.Keyboard.A)) { paddle.body.velocity.x = -paddleSpeed; } else if(game.input.keyboard.isDown(Phaser.Keyboard.D)) { paddle.body.velocity.x = paddleSpeed; }and after checking some Phaser source i came up with this: if(paddle.x < paddle._cache.halfWidth) { paddle.x = paddle._cache.halfWidth; paddle.body.velocity.x *= -paddle.body.bounce.x; } if(paddle.x > game.world.width - paddle._cache.halfWidth) { paddle.x = game.world.width - paddle._cache.halfWidth; paddle.body.velocity.x *= -paddle.body.bounce.x; } If I use: paddle.body.collideWorldBounds = true; //like in the examples it-s all KO no bouncing/jitter when paddle hit the walls And since this is the code for checkWorldBounds: if (this.x < this.game.world.bounds.x){this.x = this.game.world.bounds.x;this.velocity.x *= -this.bounce.x;}else if (this.right > this.game.world.bounds.right){this.x = this.game.world.bounds.right - this.width;this.velocity.x *= -this.bounce.x;}I used the same approach... but still when it hit the right or left border the sprite passes the border and then it's positioned back ... you can check it, here: http://mihail.ilinov.eu/games/PhaserBreakoutJSBuggy/ Just press "A" and "D" for moving left and right and hit the wall you will see the problem... Also what's the deal with: body.bounce
×
×
  • Create New...