I am using the director class and I am receiving a very strange error message.
Just as a bit of background, when you touch the screen, my game calls a pause function and displays a pause menu. It is pretty straight forward and works great!
Just to test it, I added a director:changeScene method just to make sure I was using the director class correctly. Now when I tap the screen, I get this message:
Runtime error
/Users/Kyle/Desktop/hvsz/game.lua:382: attempt to compare number with nil
I have narrowed it down to this function, which include line 382 as mentioned above:
local function gameLoop()
--===================================================================================
-- Scroll background
--===================================================================================
local yCutoff = 720
if (leftBuilding1.y \>= yCutoff) then
leftBuilding1.y = leftBuilding2.y - leftBuilding2.height
end
if (leftBuilding2.y \>= yCutoff) then
leftBuilding2.y = leftBuilding1.y - leftBuilding1.height
end
if (rightBuilding1.y \>= yCutoff) then
rightBuilding1.y = rightBuilding2.y - rightBuilding2.height
end
if (rightBuilding2.y \>= yCutoff) then
rightBuilding2.y = rightBuilding1.y - rightBuilding1.height
end
end
This basically keeps track of when the images moves off screen and immediately moves it to the top creating a parallax scroll. I use the Runtime:addEventListener and enterFrame to check for this.
I am not sure why this function is causing it to crash once I want to change scenes. Anyone see anything I am doing wrong?
I did attempt removing the event listener before changing the scene, which did nothing, and I have indeed added all of these objects to a main group to be passed to the director class.
If I comment out either the director:changeScene function of the if statements above, the code works with no problems!
Any help would be greatly appreciated! [import]uid: 9968 topic_id: 9547 reply_id: 309547[/import]