zoukankan      html  css  js  c++  java
  • cocos 帧率测试

    有人说导致cocos2dx 帧率下降的是getPosition,我测试以后发现并不是这样的。

    
    local MainScene = class("MainScene", function()
        return display.newScene("MainScene")
    end)
    
    function MainScene:ctor()
    
        -- 随便创建500个Node
        local nodes = {};
        for i = 1, 1500 do
            nodes[i] = cc.Node:create();
            self:addChild(nodes[i]);
        end
        -- 注册update函数
        self:scheduleUpdateWithPriorityLua(function(dt)
            local pos = nil;
            local size = nil;
    
            -- 遍历所有节点,仅仅是进行了获取坐标和大小的操作
            for index, node in pairs(nodes) do
                pos = node:getPosition();
                size = node:getContentSize();
            end
        end, 0);
    
    
        self:addNodeEventListener(cc.NODE_ENTER_FRAME_EVENT,handler(self , self.update))
        self:scheduleUpdate()
    
        self.sum=0
        self.frameIndex=0
    
    end
    
    
    function MainScene:update(dt)
        
    	local rate=cc.Director:getInstance():getFrameRate()
    	--print(rate)
    	self.sum=self.sum+rate
    	self.frameIndex=self.frameIndex+1
    	
    	print(self.sum/self.frameIndex)
    end
    
    
    
    
    
    
    return MainScene
    
    
  • 相关阅读:
    比较好的总结runtime
    开发证书详解
    删除数组中特定元素推荐做法
    pbxproj文件冲突解决办法
    svn不提交user文件
    c提高第六次课 文件读取
    c++函数指针
    c提高第五次作业
    c提高第四次作业
    c提高第四课
  • 原文地址:https://www.cnblogs.com/yufenghou/p/4590192.html
Copyright © 2011-2022 走看看