Search the Community
Showing results for tags 'radius'.
-
Hi I'm working on a prototype and have some problems with P2. I've some bubbles in the scene which grow over time. When changing the body's radius in the update function the whole scene gets out of control and the bubbles go crazy, jumping around everywhere. create: function() { this.game.physics.startSystem(Phaser.Physics.P2JS); for (var i = 0; i < 10; i++) { var x = (Math.random() * this.game.width) | 0, y = (Math.random() * this.game.height) | 0, d = 30; var s = this.game.add.sprite(x, y, ''); s.anchor.set(0.5, 0.5); this.game.physics.p2.enable(s); var p2Shape = s.body.addCircle(d, 0, 0, 0); s.body.debug = true; this.objects.push({ sprite: s, physicShape: p2Shape }); } }, update: function() { for (var i = 0; i < this.objects.length; i++) { var o = this.objects[i]; // same result //o.sprite.body.setCircle(o.physicShape.radius + 0.1, 0, 0, 0); o.physicShape.radius += 0.1; o.physicShape.boundingRadius = o.physicShape.radius; } }Am I doing something terribly wrong here?