How can i dynamically create a sprite from a plist?
i have a sprite sheet of buildings and my goal is to create a building in the area where the user touches in the screen… i have done this before(in cocos2d-x-js), but there is no example on how to create a sprite from a plist in cocos creator… all are editor oriented examples 
1 Like
nah! already solved it…
for the sake of those who doesnt know yet… you just have to load the plist… using cc.loader.loadRes. it will return an instance of SpriteAtlas which has all the spriteframes of your plist…
ex
var node = new cc.Node("New Sprite");
var sprite = node.addComponent(cc.Sprite);
node.parent = this.node;
cc.loader.loadRes('my.plist',function(err,data){
var frame = data.getSpriteFrame("frame.png");
cc.log(data);
sprite.spriteFrame = frame;
});
note that using cc.loader.loadRes, your files should be on a folder named resources
then your url will be relative to that folder… and you dont have to include the resources folder in your url… like what i did above…
3 Likes