• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
养眼大魔王
博客园    首页    新随笔    联系   管理    订阅  订阅

cocos-lua基础学习(九)spite类学习笔记

创建精灵

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

 

posted @ 2015-11-06 21:01  养眼大魔王  阅读(585)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3