How to create your own atlas?

Hi i want to dynamically create a SpriteAtlas because my .plists are on a server and i am downloading them during run time? how do i do this? in the editor you just drag the plist in the atlas property… but do i make an instance of SpriteSheet atlas dynamically?

In v1.0 +, you can do the following:

cc.loader.load('url.plist', function (atlas) {
    var spriteFrame = atlas.getSpriteFrame('spriteFrameId.png');
    sprite.spriteFrame = spriteFrame;
});

atlas is an object of type cc.SpriteAtlas

hi @pandamicro in v1.1.1 its not working any more…
it give us an object version of the plist it self…
can you tell us the work around with that?

you can use

cc.loader.load('url', cc.SpriteAtlas, function (atlas) {
    var spriteFrame = atlas.getSpriteFrame('spriteFrameId.png');
    sprite.spriteFrame = spriteFrame;
});

in 1.1.1

1 Like

@jare thanks it worked
how about when im am loading an array of resources?
like this one

[
     'url.plist',
     'url.png'
     'url.json'
]

i was able to load all the resources but the plist is not an atlas :frowning:

Hi, by now you can use loadResAll to load every resources in a folder, otherwise you should load array by yourself.

Hi Jare, It doesn’t work in v2.1.0. Which method can be used for this situation?