Jump to content

Group creation with rotation


Jirka1111
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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