• 加载UI工程的csb,以及纹理缓存情况


    以plist+PNG模式加载csb,并播放UI工程做的动画,用法如下

    local Layer = cc.CSLoader:createNode("res/yk/interface/loading.csb")
    local Action = cc.CSLoader:createTimeline("res/yk/interface/loading.csb")    --序列帧动画
    Layer:runAction(Action)
    --Action:setTimeSpeed(10/60)
    Action:gotoFrameAndPlay(0, true)
    scene:addChild(Layer, 1)

    这种模式下,不用预先加载plist,加载csb时会自动加载,预先加载的话会重复加载,但是可以通过清缓存清理掉一个

    以下是测试时用的代码

    cc.FileUtils:getInstance():addSearchPath("res/yk")
    
    function MainSence:RefreshLayer(scene) 
    
        self.scene = scene--    local cache = cc.SpriteFrameCache:getInstance();
    --    cache:addSpriteFrames("res/yk/china/loading.plist")
    
        local test = cc.Node:create()
        scene:addChild(test)
    
        for i=1,8 do
            performWithDelay(test,function()self:add(i) end,i)
        end
    end
    
    function MainSence:add(key)
        --print("加载plist")
        --print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
        print("key "..key)
    
        if key == 6 then
            for i=1,5 do
                self.scene:removeChildByTag(i)
            end
            print("移除所有元素")
            print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
        end
        if key == 7 then
            print("移除元素后 清缓存")
            cc.Director:getInstance():getTextureCache():removeUnusedTextures()
            print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
        end
        
        if key < 6 then
            local layout = ccui.Layout:create()
            layout:setContentSize(cc.size(SCREEN_WIDTH, SCREEN_HEIGHT))
            layout:setTouchEnabled(true)
            layout:setAnchorPoint(cc.p(0, 0))
            layout:setPosition(cc.p(0, 0))
            self.scene:addChild(layout,1,key)
            LoadingLayer = layout
            local Layer = cc.CSLoader:createNode("res/yk/interface/loading.csb")
            local Action = cc.CSLoader:createTimeline("res/yk/interface/loading.csb")    --序列帧动画
            Layer:runAction(Action)
            --Action:setTimeSpeed(10/60)
            Action:gotoFrameAndPlay(0, true)
            LoadingLayer:addChild(Layer, 1)
    
            print("加载csb")
            print(cc.Director:getInstance():getTextureCache():getCachedTextureInfo())
        end
    end
  • 相关阅读:
    AE 线编辑
    ArcEngine判断要素(feature)是否为multipart feature及分解(炸开)代码
    AE二次开发技巧之撤销、重做
    ArcEngine数据编辑--选择要素
    java语言体系的技术简介之JSP、Servlet、JDBC、JavaBean(Application)
    MVC开发模式详解
    数据库设计中常见表结构的设计技巧
    Eclipse 保存文件时自动格式化代码
    优化你的java代码性能
    Hibernate 与mybatis的区别
  • 原文地址:https://www.cnblogs.com/mingfuqishi/p/7839922.html
Copyright © 2020-2023  润新知