创建精灵
local sprite = cc.Sprite:create("Images/grossini_dance_atlas.png", cc.rect(x,y,85,121) ) layer:addChild( sprite )
local BatchNode = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 50) layer:addChild(BatchNode, 0, kTagSpriteBatchNode) local sprite = cc.Sprite:createWithTexture(BatchNode:getTexture(), cc.rect(x,y,85,121) ) layer:addChild( sprite )
local cache = cc.SpriteFrameCache:getInstance() cache:addSpriteFrames("animations/grossini.plist") cache:addSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray.png") cache:addSpriteFrames("animations/grossini_blue.plist", "animations/grossini_blue.png") SpriteFrameTest.m_pSprite1 = cc.Sprite:createWithSpriteFrameName("grossini_dance_01.png") SpriteFrameTest.m_pSprite1:setPosition( cc.p( s.width/2-80, s.height/2) ) local spritebatch = cc.SpriteBatchNode:create("animations/grossini.png") spritebatch:addChild(SpriteFrameTest.m_pSprite1) function SpriteFrameTest.onExit() local cache = cc.SpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") cache:removeSpriteFramesFromFile("animations/grossini_blue.plist") end