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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | -- 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) |