[lua]local function controlBG1()
if gameover == 0 and ship.y > 0 and bgcheck == 0 then
bgcheck = bgcheck + 1
bg1 = display.newImageRect(“Background_1.png”,720,500)
game:insert(bg1)
bg1.x = 120; bg1.y = 240
bg1:toBack()
elseif gameover == 1 and ship.y < -100 then
game:remove(bg1)
end
end[/lua]
When the elseif is true it crashes, any idea why. [import]uid: 11465 topic_id: 6845 reply_id: 306845[/import]
this is the error, bad argument #-2 to ‘remove’ (Proxy expected, got nil) [import]uid: 11465 topic_id: 6845 reply_id: 23885[/import]
Got it, had to do with my use of the Director Class. [import]uid: 11465 topic_id: 6845 reply_id: 23909[/import]
was “bg1” definitely already inserted into “game” by that point? [import]uid: 6645 topic_id: 6845 reply_id: 23908[/import]