I am using a code that generates slopes just before a man runs onto them. However, after a while the game starts to get really laggy. I used a function to see how much memory is being used and it keeps rising. Is there anyway to stop the memory rising but have the same effect of slopes being generated. The code I am using is:
[code]
slopeshape = { -240,-100, 240,100, -240,100 }
local slope = {}
local function MakeBottom()
mx = man.x
for s = 1,9999 do
if man.x > (s*468) - 468 then
slope[s] = display.newImage(“slope.png”)
physics.addBody(slope[s], “static”, {friction=0.01, density = 1, bounce = 0.1, shape=slopeshape})
slope[s]:setReferencePoint(display.TopLeftReferencePoint)
slope[s].x = (s*468) - 480
slope[s].y = (s*195) - 100
slope[s].material = “ground”
moveGroup:insert(slope[s])
if s > 1 then
slope[s-1]:removeSelf()
end
end
end
end
Runtime:addEventListener (“enterFrame”, MakeBottom)
[/code] [import]uid: 116264 topic_id: 24382 reply_id: 324382[/import]
[import]uid: 21331 topic_id: 24382 reply_id: 98652[/import]