Jump to content

Circular Collision


Recommended Posts

First of all I'm not sure this is the best way to group element for collision detection but I'm crating CHARACTER elements that contain various sprites that I want to act as one element.  I want the different circles(made up of a few sprites) to bounce off of each other.

In order to keep all the elements together and since I can't set 'body.setCircle' on a group I'm using the 'circle' sprite for physics and just updating the positions of the other elements to match the x/y of the 'circle' in the bubble.update = function(){}.  Is there a better way to do this?

My other question is, as I add more CHARACTER's I'd like to add the corresponding 'bubble' sprite to a:


so that the 'bubble's bounce off each other.  ie

game.physics.arcade.collide(bubble1, bubble2, etc)

is there a way to do this?


CHARACTER _ctor: function() {
        var character_g = this.game.add.group();

        var s1 = imageLoader.sprite(0, 0, 'Idle.png');
        var s2 = imageLoader.sprite(0, 0, 'state1.png');
        s2.visible = false;
        var bubble= imageLoader.sprite(0, 0, circle.png');

        bubble.body.collideWorldBounds = true;
        bubble.body.gravity.y = 0;




        bubble.update = function(){

            s1 .x = bubble.x;
            s1 .y = bubble.y;
            s2 .x = bubble.x;
            s2 .y = bubble.y;




Link to comment
Share on other sites

  • 4 weeks later...

  • Recently Browsing   0 members

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