Hello all. I’am trying to code a random level generation, so i’ve got a little performance problem with it. A level consists of 500000 blocks (1000 by X and 500 by Y) and it causes low fps. Here is a block class code:
cBlock = { } function cBlock:New( type ) local self = display.newGroup( ) self:insert( display.newImage( "gfx/blocks/"..type..".png" ) ) blockCount = blockCount + 1 camera:insert( self ) self.Type = type function self:Init( x, y ) physics.addBody( self, "static", { bounce = 0 } ) self.x = x self.y = y end return self end
I’ve tried to disable physics body and image drawing for blocks that are not placed in camera space, but it makes more lags because i’ve run a cycle for each block in each game frame. How can this problem be solved?
sorry for my english.