I have a function called CreateGround, it creates a surface under the player and if it already exists on the site of the land, it moves along the x-axis to x + the width of the surface, but for some reason it refuses to work, I hope that you will help me.
Here’s the code:
local function createGround () local ground = display.newImageRect( mainGroup, objectSheet, 3, 390, 265 ) ground.x = 195 ground.y = yc+(yc\*0.9) table.insert( groundTable, ground ) for i = #groundTable, 1, -1 do local thisGround = groundTable[i] if (thisGround.x == (thisGround-1).x) then (thisGround-1).x = (thisGround-1).x + 390 end if (thisGround.x \< 500 or thisGround.x \> width+500) then display.remove( thisGround ) table.remove( groundTable, i ) end end end
Error screen attached