Jirka1111 Posted November 18, 2014 Share 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 Link to comment Share on other sites More sharing options...
Jirka1111 Posted November 19, 2014 Author Share Posted November 19, 2014 Up. It's full "game". Not just fragments. Link to comment Share on other sites More sharing options...
rvizcaino Posted November 19, 2014 Share Posted November 19, 2014 Please paste here your function addGroupOfBunnies. Link to comment Share on other sites More sharing options...
Jirka1111 Posted November 19, 2014 Author Share 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*/]); }, Link to comment Share on other sites More sharing options...
rvizcaino Posted November 20, 2014 Share Posted November 20, 2014 Are you getting any error in the javascript console? Link to comment Share on other sites More sharing options...
Jirka1111 Posted November 20, 2014 Author Share 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. Link to comment Share on other sites More sharing options...
rvizcaino Posted November 21, 2014 Share Posted November 21, 2014 Are you starting the physics system? Link to comment Share on other sites More sharing options...
Jirka1111 Posted November 21, 2014 Author Share Posted November 21, 2014 Yes, and even enable body. But render just don't show body and, of course, collision doesn't work. Link to comment Share on other sites More sharing options...
rvizcaino Posted November 21, 2014 Share 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. Jirka1111 1 Link to comment Share on other sites More sharing options...
Jirka1111 Posted November 23, 2014 Author Share Posted November 23, 2014 That's it! Thank you Now I have to manage collision detection. Link to comment Share on other sites More sharing options...
Recommended Posts