Hello
I’m new to corona so i would appreciate some help with some code giving me headaches 
I’m making a space game where i want the player to be able to navigate on a grid quadrant map and then jump to sectors on whose grids enemies and items and what not is placed for the player to interact with.
The attached code works fine when jumping from different sectors but when jumping into a previous visited sector i get the following error :
Runtime error
c:\users\hrj\documents\corona projects\solinvictus\grid.lua:44: attempt to call method ‘translate’ (a nil value)
stack traceback:
c:\users\hrj\documents\corona projects\solinvictus\grid.lua:44: in function ‘drawImage’
c:\users\hrj\documents\corona projects\solinvictus\sector.lua:155: in function <c:\users\hrj\documents\corona projects\solinvictus\sector.lua:92>
?: in function ‘dispatchEvent’
?: in function ‘showOverlay’
c:\users\hrj\documents\corona projects\solinvictus\quadrant.lua:82: in function <c:\users\hrj\documents\corona projects\solinvictus\quadrant.lua:65>
?: in function <?:221>
Does anyone have an idea what is wrong?
Snip from sector:
function scene:create( event )
local stars = starmap.getMap()
params = event.params
print( "params.x: " … params.x )
print( "params.y: " … params.y )
local qtile = stars[params.x][params.y]
--if qtile.isInitalized == nil then
space = qtile.map
qtile.isInitalized = true
local sceneGroup = self.view
– Called when the scene’s view does not exist
–
– INSERT code here to initialize the scene
– e.g. add display objects to ‘sceneGroup’, add touch listeners, etc
local bgPicture = display.newImage( “art/bg.png” )
bgPicture:translate(width/2, height/2)
local button = createButton(“Quadrant”, width/2 - 100, height/2 + 300)
sceneGroup:insert(bgPicture)
sceneGroup:insert(button)
local map = drawGrid(display.newGroup(), tapListener)
map.x = display.contentCenterX – center the grid on the screen
sceneGroup:insert(map)
txt = grid.drawCoordinates()
for key,value in pairs(txt) do
sceneGroup:insert(value)
end
grid.drawFogOfWar()
local compas = display.newImage( “art/Compas.png” )
compas:scale(.5,.5)
compas:setFillColor(0,1,0,.1)
compas:translate(width-100, 100)
sceneGroup:insert(compas)
for x = 1, 10 do
for y = 1, 10 do
local o = space[x][y]
if o.image ~= nil then
local obj = o.image
grid.drawImage(obj, x, y )
sceneGroup:insert(obj)
end
end
end
end
end
Snip from Grid:
local function drawImage(img, tileX, tileY)
c = tileToScreen(tileX, tileY)
if img ~= nil then
img[“gridX”] = tileX
img[“gridY”] = tileY
img:translate( c.x, c.y )
end
end