Jump to content

Interacting Sprites with Physics overlap (and shouldn't)


Recommended Posts

I'm trying to make a little game using physics, where the user pushes balls around. The balls are defined as Sprite extensions, like this:


  function Player(game, type) {    Phaser.Sprite.call(this, game, game.world.randomX, game.world.randomY, 'player')    this.anchor.setTo(0.5, 0.5)    this.type = type    this.body.collideWorldBounds = true    this.body.allowRotation = true    this.body.bounce.setTo(0.6, 0.6)    this.body.setCircle(50)    this.body.angularDrag = 50    this.body.drag = 5    game.add.existing(this)  } 

And the interaction is based on doing:

        this.players.getAt(0).body.velocity.x -= 10

with every one of the directions, depending on the key pressed.


It works, I can push elements around. But I'm facing an issue, I don't know it it's a bug or it's just expected to work like this and I'm missing something. The problem is that the elements overlap in some situations. For example, if I keep pressing the key, forcing the sprite against another one, it may finally "break" the collision boundary and overlap.


Is there a solution for this? Is it a known issue?


Thank you





Link to comment
Share on other sites


  • Recently Browsing   0 members

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