'translate' a nil value on iOS only

Hello,

I’ve got a problem that doesn’t occur in the simulator or on an Android device - it only occurs on iOS.

I have a an “infinite” scrolling background where I place one behind the other every time one goes off the screen.  I create the background like this:

local backgroundOverlay = {}--display.newImageRect(bgOverlayLocation,w,h),display.newImageRect(bgOverlayLocation,w,h)} for i = 1, numThemes + 2 do table.insert(backgroundOverlay,display.newImageRect(bgOverlayLocation,w,h)); backgroundOverlay[i].anchorX = 0; backgroundOverlay[i].anchorY = 0; backgroundOverlay[i].alpha = .7 backgroundOverlay[i].y = 0 ; backgroundOverlay[i].x = (i-1)\*w + screenOriginX; group:insert(backgroundOverlay[i]); end

Then in my Enter Scene function, I run the scrollBackground() function every time which looks like this:

function scrollBackgroun() for i = 1, #backgroundOverlay do backgroundOverlay[i]:translate(-t\*cloudMoveSpeed,0); end end

It works just as it should on Android and both iOS and Android Simulators, but throws an exception in iOS saying ‘Attempt to call method ‘translate’ a nill value’;

I’m sure I did something wrong, but I can’t seem to figure out what.  If you have any pointers as to where to go next, I’d appreciate it.

what is the value of the variable “bgOverlayLocation”?

You might want to put in some prints and check to see what the value of “i” is, make sure that backgroundOverlay[i] is not nil, and perhaps print out the table values of that and see if for some reason the translate method is getting trampled on somwhere.

Rob

I figured it out and will post here in case anyone has a similar issue.

The error actually did occur on the simulator, but not till I had changed a few senes.

I was using storyboard, and for some reason the exitScene method wasn’t being called.  I went ahead and updated the project to use composer and that took care of everything.  Hurray for composer!

what is the value of the variable “bgOverlayLocation”?

You might want to put in some prints and check to see what the value of “i” is, make sure that backgroundOverlay[i] is not nil, and perhaps print out the table values of that and see if for some reason the translate method is getting trampled on somwhere.

Rob

I figured it out and will post here in case anyone has a similar issue.

The error actually did occur on the simulator, but not till I had changed a few senes.

I was using storyboard, and for some reason the exitScene method wasn’t being called.  I went ahead and updated the project to use composer and that took care of everything.  Hurray for composer!