Jump to content

Creating group from atlas


Jirka1111
 Share

Recommended Posts

addLeftSpikes: function(){

        for(var i = 1; i < 6; i++){

            var group = this.leftSideSpikes.create(0, this.spikesPositions(), "leftSideSpikes", 0);

            group.body.immovable = true;

            group.body.setSize(22, 17, 0, 17);

        }

    },

 

So I have this function. leftSideSpikes is reference to the name which I have in my preloader state (when not using atlas). But how should I done that with atlas if I don't have an image load as usual (game.load.image)?

Link to comment
Share on other sites

Preloader:

 

this.load.atlas("atlas", "img/atlas.png", "img/atlas.json");

 

Main (create): 

 

this.leftSideSpikes = this.add.group();
this.leftSideSpikes.enableBody = true;
this.leftSideSpikes.physicsBodyType = Phaser.Physics.ARCADE;
 
Main:
 
addLeftSpikes: function(){
        for(var i = 1; i < 6; i++){
            var group = this.leftSideSpikes.create(0, this.spikesPositions(), "atlas", "spike.png");
            group.body.immovable = true;
            group.body.setSize(22, 17, 0, 17);
        }
    },
 
spike.png is really in .json file.
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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