Why does this loop kill the performance of a simple Marmalade Quick app?
Asked Answered
T

0

1
local board=director:createSprite(0,200);

for y = 0, w*15, w do
  for x = 0, w*15, w do
    local space = director:createRectangle({x=x, y=y, w=w-1, h=w-1, strokeWidth=0, color=color.grey})

    board:addChild(space)
  end
end

In addition to the above, I have some tiles which should be able to be dragged smoothly..

I was astonished at the performance degradation by adding these 225 static objects to the scenegraph... I was hoping for better performance than this. Am I missing something? Is there a different approach I should be trying? Or is Marmalade Quick just not that quick?

Tearoom answered 25/11, 2013 at 3:7 Comment(7)
How are you measuring performance, and have you tried scaling down your operation and comparing the differences?Felder
The frame rate drops dramatically and the dragging (which worked at a high frame rate before adding these objects) becomes very laggy. Yes, it's proportional to the number of sprites added.Tearoom
Did you try moving the table construction in your inner most loop to outside the loop?Staff
There wouldn't happen to be anything interacting with these rectangles every frame, would there? Does it become laggier over time, or is the frame rate relatively consistent?Felder
Its not the loop that's slow.. its the effect these 225 rectangles have on the performance.Tearoom
I am just trying to drag another rectangle over them... Its laggy from the startTearoom
Could it be possible that it's because they're all children of board?Felder

© 2022 - 2024 — McMap. All rights reserved.