How to create your own atlas?

How to create your own atlas?
0
#1

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?

#2

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

#3

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?

#4

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
#5

@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:

#6

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

#7

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