Jirka1111 Posted August 26, 2014 Share Posted August 26, 2014 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 More sharing options...
Jirka1111 Posted August 26, 2014 Author Share Posted August 26, 2014 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 More sharing options...
Recommended Posts