Jirka1111 3 Report post Posted November 18, 2014 Hello,I am pretty desperate (yeah, again). Can you please look at this code and tell me, what I am doing wrong with function addGroupOfBunnies? I just want to generate bunch of sprites with body and then make a collision between player and each sprite from group. https://mega.co.nz/#!yVRzBAJI!WbRqInoZBF4zbeYoJbrz10fVZlh9NXW-tjtzo5OPo5Q Quote Share this post Link to post Share on other sites
Jirka1111 3 Report post Posted November 19, 2014 Up. It's full "game". Not just fragments. Quote Share this post Link to post Share on other sites
rvizcaino 6 Report post Posted November 19, 2014 Please paste here your function addGroupOfBunnies. Quote Share this post Link to post Share on other sites
Jirka1111 3 Report post Posted November 19, 2014 this.groupOfBunnies = this.add.group(); this.groupOfBunnies.enableBody = true; this.groupOfBunnies.physicsBodyType = Phaser.Physics.ARCADE; addGroupOfBunnies: function(){ for(var i = 1; i < 10; i++){ this.pos = this.bunniesPos(); this.bunny = this.groupOfBunnies.create(this.game.world.centerX, this.game.world.centerY, "player"); this.bunny.name = 'bunny' + i; this.bunny.rotation = this.pos + Math.PI / 2; this.bunny.x = this.game.world.centerX + Math.cos( this.pos ) * ( this.radius + this.bunny.height / 2 ); this.bunny.y = this.game.world.centerY + Math.sin( this.pos ) * ( this.radius + this.bunny.height / 2 ); } }, bunniesPos: function(){ return this.game.rnd.pick([/*0, 0.314, 0.628, */0.942, 1.256, 1.57, 1.884, 2.198, 2.512, 2.826, 3.14, 3.454, 3.768, 4.082, 4.396, 4.71, 5.024, 5.338, 5.652, 5.966/*, 6.28*/]); }, Quote Share this post Link to post Share on other sites
rvizcaino 6 Report post Posted November 20, 2014 Are you getting any error in the javascript console? Quote Share this post Link to post Share on other sites
Jirka1111 3 Report post Posted November 20, 2014 No, bunnies creates as I wish, but I can't set them body (render of the body doesn't work). So for example collision is not working. Quote Share this post Link to post Share on other sites
rvizcaino 6 Report post Posted November 21, 2014 Are you starting the physics system? Quote Share this post Link to post Share on other sites
Jirka1111 3 Report post Posted November 21, 2014 Yes, and even enable body. But render just don't show body and, of course, collision doesn't work. Quote Share this post Link to post Share on other sites
rvizcaino 6 Report post Posted November 21, 2014 Hi, I finally managed to find the problem, in the render method you can't debug the group itself, you must loop it, like this:this.groupOfBunnies.forEachAlive(function(bunny){ this.game.debug.body( bunny );}, this);Also, you're missing to include phaser.map in your src folder. 1 Jirka1111 reacted to this Quote Share this post Link to post Share on other sites
Jirka1111 3 Report post Posted November 23, 2014 That's it! Thank you Now I have to manage collision detection. Quote Share this post Link to post Share on other sites