how to assign sprites name variable using a function method?

hello everyone. I am starter and newbie in coco2d. my first application using coco2d-html5 is to create animation for my capstone project.

this is my function I’ve created.

normalAnimation:function()
{
var size = cc.Director.getInstance().getWinSize();

this.item = cc.TextureCache.getInstance().addImage(image);

this.sprite = cc.Sprite.createWithTexture(this.item, cc.rect(0, 0, 1296, 280));
……
},

is there have other way solution to use this function in different sprites name variable (unset sprite name variable)?

I’m sorry for my English grammar & Thank you for all your great advice. :slight_smile:

Hi, you could use TexturePacker to export plist and png files.
Code:

cc.SpriteFrameCache.getInstance().addSpriteFrames("res/animations/crystals.plist");
// Create sprite with spriteframe
var head = cc.Sprite.createWithSpriteFrameName("crystals/1.png");

thanks for your reply James, I will try it.