From what i have tracked down display groups are bad and nested display groups are nasty. In the code below if you run it on the itouch/iphone g3s the fps will drop too 0/1 from touch/swipe. The strange thing is that there are no touch events. I would like to know if there is a way to register a display group to ignore touch.
**Nested Displays kill the render?
Nested Displays register touch events?
Any help is welcome
-Darkmod
[lua]
– Physics Settings --------------------------------
physics = require “physics”
physics.start()
physics.setGravity (0, 15)
physics.setScale( 32 )
physics.setVelocityIterations( 16 )
physics.setPositionIterations( 16 )
– FPS ---------------------------------------------
PerformanceOutput = {};
PerformanceOutput.mt = {};
PerformanceOutput.mt.__index = PerformanceOutput;
– LOCAL VARS ---------------------------------------
local screenW, screenH = display.contentWidth, display.contentHeight
local prevTime = 0;
local maxSavedFps = 30;
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;
– Singleton
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();
local myRec = display.newRect(screenW/2 - 90, screenH/2 - 60, 180, 10)
myRec:setFillColor(0, 0, 255,255)
physics.addBody( myRec, “dynamic” ,{ density=0, friction=0, bounce=0, filter = { categoryBits = 4, maskBits = 7 }} )
local anchor = display.newCircle( 0,0,1 )
physics.addBody( anchor, “static”, { friction=0, bounce=0, density=0 } )
myRec.axisB = physics.newJoint( “pivot”, anchor, myRec,myRec.x,myRec.y)
myRec.axisB.isMotorEnabled = true
myRec.axisB.maxMotorForce = 500
myRec.axisB.maxMotorTorque = 500
myRec.axisB.motorSpeed =250
–
local pos = {}
pos = {x=40, y=80, num=10}
for i=1, 208 do
local display_nest0 = display.newGroup()
local display_nest1 = display.newGroup()
local display_nest2 = display.newGroup()
display_nest0:insert(display_nest1)
display_nest1:insert(display_nest2)
local myRec = display.newRect(pos.x, pos.y, 25, 25)
myRec:setFillColor(255, 0, 0,80)
myRec:setStrokeColor(255, 255, 255)
myRec.strokeWidth =2
pos.x = pos.x + 25
if i==pos.num then pos.y = pos.y + 25; pos.x = 40; pos.num=pos.num + 10; end
display_nest2:insert(myRec)
end
[import]uid: 7177 topic_id: 14666 reply_id: 314666[/import]**