From what i have tracked down display groups are bad and nested display groups are nasty. The strange thing is that there are no touch events and the FPS drops below 10 on touch. << on the Simulator!
Nested Displays kill the render?
Nested Displays register touch events?
-Darkmod
[code]-- FPS ---------------------------------------------
PerformanceOutput = {}; PerformanceOutput.mt = {};
PerformanceOutput.mt.__index = PerformanceOutput;
– LOCAL VARS ---------------------------------------
local screenW, screenH = display.contentWidth, display.contentHeight
local prevTime = 0;
local maxSavedFps = 30;
----------------------------------------------------------------------------- FPS Start
local function createLayout(self)
local group = display.newGroup(); group.x = group.x + 90; group.y = group.y + 15;group:scale(1.5,1.5);
self.memory = display.newText(“0/10”,20,0, Helvetica, 15);
self.framerate = display.newText(“0”, 30, self.memory.height, “Helvetica”, 20);
local background = display.newRect(-50,0, 175, 50);
self.memory:setTextColor(255,255,255);
self.framerate:setTextColor(255,255,255);
background:setFillColor(0,0,0);
group:insert(background);
group:insert(self.memory);
group:insert(self.framerate);
return group;
end
local function minElement(table) local min = 10000;
for i = 1, #table do
if(table[i] < min) then
min = table[i];
end;
end;
return min;
end
local function getLabelUpdater(self)
local lastFps = {};
local lastFpsCounter = 1;
return function(event)
local curTime = system.getTimer(); local dt = curTime - prevTime;
prevTime = curTime; local fps = math.floor(1000/dt);
lastFps[lastFpsCounter] = fps; lastFpsCounter = lastFpsCounter + 1;
if(lastFpsCounter > maxSavedFps) then lastFpsCounter = 1; end
local minLastFps = minElement(lastFps);
self.framerate.text = “FPS: “…fps…”(min: “…minLastFps…”)”;
self.memory.text = “Mem: “…(system.getInfo(“textureMemoryUsed”)/1000000)…” mb”;
end
end
local instance = nil;
function PerformanceOutput.new()
if(instance ~= nil) then return instance; end
local self = {};setmetatable(self, PerformanceOutput.mt);
self.group = createLayout(self);
Runtime:addEventListener(“enterFrame”, getLabelUpdater(self));
instance = self;return self;
end
local maxSavedFps = 60;PerformanceOutput.new();
---------------------------------------------------- end FPS
– Create 2000 nested Display Groups insert 1 obj-------------
local display_main = display.newGroup()
local pos = {}
pos = {x=200, y=200, num=10}
local display_nest ={}
for i=1, 2000 do
display_nest[i] = display.newGroup()
if i==1 then
display_main:insert(display_nest[i])
else
display_nest[i - 1]:insert(display_nest[i])
end
end
print(display.contentWidth)
local myRec = display.newRect(display.screenOriginX + (display.contentWidth/5.5), display.contentHeight/4, 200, 200)
myRec:setFillColor(255, 0, 0,80); myRec:setStrokeColor(255, 255, 255);myRec.strokeWidth =2;
myRec.text = display.newText(“I Have NO Touch Events!”,myRec.x - 160,myRec.y - 140, Helvetica, 27);
myRec.text2 = display.newText(“TOUCH ME”,myRec.x - 95,myRec.y - 30, Helvetica, 32);
display_nest[2000]:insert(myRec)
[import]uid: 7177 topic_id: 15918 reply_id: 315918[/import]
[import]uid: 52491 topic_id: 15918 reply_id: 59463[/import]