纹理及其异步加载
2015-06-22 21:01
281 查看
<1>
--单例
winSize = cc.Director:getInstance():getWinSize()
frameCacheInstance = cc.SpriteFrameCache:getInstance()
textureCacheInstance = cc.Director:getInstance():getTextureCache()
defaultInstance = cc.UserDefault:getInstance()
schedulerInstance = cc.Director:getInstance():getScheduler()
--单例
winSize = cc.Director:getInstance():getWinSize()
frameCacheInstance = cc.SpriteFrameCache:getInstance()
textureCacheInstance = cc.Director:getInstance():getTextureCache()
defaultInstance = cc.UserDefault:getInstance()
schedulerInstance = cc.Director:getInstance():getScheduler()
function LoadingScene:createLayer() local layer = cc.Layer:create() frameCacheInstance:addSpriteFrames("texture/loading_texture.plist", "texture/loading_texture.png") --背景 local bg = cc.TMXTiledMap:create("map/red_bg.tmx") layer:addChild(bg) --logo local logo = cc.Sprite:createWithSpriteFrameName("logo.png") logo:setPosition(cc.p(winSize.width/2, winSize.height/2)) layer:addChild(logo) -- local sp = cc.Sprite:createWithSpriteFrameName("loding4.png") local x, y = logo:getPosition() sp:setPosition(cc.p(x, y - 130)) layer:addChild(sp) -- local animation = cc.Animation:create() for i = 1, 4 do local framename = string.format("loding%d.png", i) local spFrame = frameCacheInstance:getSpriteFrame(framename) animation:addSpriteFrame(spFrame) end animation:setDelayPerUnit(0.5) animation:setRestoreOriginalFrame(true) local animate = cc.Animate:create(animation) sp:runAction(cc.RepeatForever:create(animate)) local function loadingTextureCallBack(texture) frameCacheInstance:addSpriteFrames("hd/texture/LostRoutes_Texture.plist", "hd/texture/LostRoutes_Texture.png") local homeScene = require("HomeScene").create() cc.Director:getInstance():replaceScene(cc.TransitionFade:create(2.0, homeScene)) end textureCacheInstance:addImageAsync(texture_res, loadingTextureCallBack) return layer end
相关文章推荐
- 抓包工具-查尔斯
- 关于SQL SERVER的N前缀的理解
- LTE中的HARQ学习(2)——下行HARQ
- 《浪潮之巅》读后感3
- 最小生成树(普利姆算法、克鲁斯卡尔算法)
- t-sql/mssql用命令行导入数据脚本的SQL语句示例
- 物理引擎的使用及其监听器的添加
- Linux下获取帮助
- IOS子视图超过父视图frame后,无法交互响应
- 第五章
- 【原】记2015招商银行信用卡中心在线笔试------4.2
- 洪水填充(Flood fill)算法
- 《浪潮之巅》读后感2
- 简单破解 Sencha Architect 2.2 (ExtJs Designer) - 李路平 - 博客园
- Android4.4的zygote进程
- C++ 关键字typeid
- nagios插件之监控if8接口日志(新接口)
- Java基础——线程总结
- 数据结构-图的遍历
- 《浪潮之巅》读后感