Search the Community
Showing results for tags 'circluar collision'.
-
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: game.physics.arcade.collide() 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'); game.physics.arcade.enable([bubble]); bubble.body.setCircle(160); bubble.body.collideWorldBounds = true; bubble.body.bounce.set(1); bubble.body.gravity.y = 0; bubble.body.velocity.set(150); character_g.add(s1); character_g.add(s2); character_g.add(over); bubble.update = function(){ s1 .x = bubble.x; s1 .y = bubble.y; s2 .x = bubble.x; s2 .y = bubble.y; } s1.inputEnabled=true; s1.events.onInputDown.add(this.itemClick,this); }