1 影响DrawCall 因素(Cocos2d-x 3.16)
1.1 Texture 加入 CommandRender的顺序
ResourceLoader:loadSpriteFrames(ResourceManager:reward('reward'))
local nodes = {}
for i = 1, 100 do
d.sprite(ResourceManager:reward('#common_bg_list.png')):addTo(node):pos(1 * i, 100)
d.sprite(ResourceManager:reward('#goods_floor.png')):addTo(node):pos(1 * i, 200)
end
--- DrawCall 仅仅一次
ResourceLoader:loadSpriteFrames(ResourceManager:reward('reward'))
ResourceLoader:loadSpriteFrames(ResourceManager:personalInfo("personalInfo"));
local nodes = {}
for i = 1, 100 do
d.sprite(ResourceManager:reward('#common_bg_list.png')):addTo(node):pos(1 * i, 100)
d.sprite(ResourceManager:personalInfo("#common_Input_box_bg_2.png")):addTo(node):pos(1 * i, 200)
end
--- DrawCall 为 200
1.2 系统字体
ResourceLoader:loadSpriteFrames(ResourceManager:reward('reward'))
ResourceLoader:loadSpriteFrames(ResourceManager:personalInfo("personalInfo"));
local nodes = {}
for i = 1, 100 do
d.sprite(ResourceManager:reward('#common_bg_list.png')):addTo(node):pos(1 * i, 100)
d.label('123', 60):addTo(node):pos(1 * i, 100)
end
--- DrawCall 为 200
local nodes = {}
for i = 1, 100 do
d.label('123', 60):addTo(node):pos(1 * i, 100)
d.label('123', 60):addTo(node):pos(1 * i, 100)
end
--- DrawCall 也为 200
local nodes = {}
for i = 1, 100 do
d.label('123', 60):addTo(node):pos(1 * i, 100):enableOutline(cc.c4b(255, 0, 0, 255), 2)
end
--- DrawCall 也为 100
1.3 scale 为0
local nodes = {}
for i = 1, 100 do
d.label('123', 60):addTo(node):pos(1 * i, 100):scale(0)
end
--- DrawCall 也为 100 界面上无显示
1.4 opacity 为0
local nodes = {}
for i = 1, 100 do
d.label('123', 60):addTo(node):pos(1 * i, 100):opacity(0)
end
--- DrawCall 也为 100 界面上无显示
1.5 visible 为 false
local nodes = {}
for i = 1, 100 do
d.label('123', 60):addTo(node):pos(1 * i, 100):visible(false)
end
--- DrawCall 也为 0 界面上无显示
1.6 setBlendFunc
ResourceLoader:loadSpriteFrames(ResourceManager:reward('reward'))
ResourceLoader:loadSpriteFrames(ResourceManager:personalInfo("personalInfo"));
local nodes = {}
for i = 1, 100 do
local sp = d.sprite(ResourceManager:reward('#common_bg_list.png')):addTo(node):pos(0.5 * i, 100)
sp:setBlendFunc({src = gl.SRC_ALPHA, dst = gl.ONE_MINUS_DST_COLOR})
end
--- DrawCall 也为 1
ResourceLoader:loadSpriteFrames(ResourceManager:reward('reward'))
ResourceLoader:loadSpriteFrames(ResourceManager:personalInfo("personalInfo"));
local nodes = {}
for i = 1, 100 do
d.sprite(ResourceManager:reward('#common_bg_list.png')):addTo(node)
local sp = d.sprite(ResourceManager:reward('#common_bg_list.png')):addTo(node):pos(0.5 * i, 100)
sp:setBlendFunc({src = gl.SRC_ALPHA, dst = gl.ONE_MINUS_DST_COLOR})
end
--- DrawCall 也为 200
1.7 屏幕的显示范围
ResourceLoader:loadSpriteFrames(ResourceManager:reward('reward'))
ResourceLoader:loadSpriteFrames(ResourceManager:personalInfo("personalInfo"));
local nodes = {}
for i = 1, 100 do
d.sprite(ResourceManager:reward('#common_bg_list.png')):addTo(node):pos(10 * i, 100)
d.sprite(ResourceManager:personalInfo('#common_btn_edit.png')):addTo(node):pos(10 * i, 200)
end
--- drawCall 为 163 竖屏游戏 屏幕宽为 640 * 1136