alvatar

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

 

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.