[Resolved] Moving Background like "Happy Doodle Sushi Smile"

Hi. I am trying to make a moving background like Peach’s app “Happy Doodle Sushi Smile”. How can i make the background moving so it looks like the character is falling or moving upwards. Thank you. [import]uid: 132369 topic_id: 28502 reply_id: 328502[/import]

Tutorial on that right here, which came from HDSS code; http://corona.techority.com/2011/07/10/how-to-use-a-scrolling-background-portraitup/ (That was my first ever Corona made app :)) [import]uid: 52491 topic_id: 28502 reply_id: 115038[/import]

Thank you peach for your link. I tried it and it works fine. But when i went back to the main menu and clicked start again i get this message in the terminal.

“attempt to perform arithmetic on field ‘y’ (a nil value)”

It also happens when i click “retry” on my game over screen. When i removed the scrolling background code, it worked without errors. Please help. Thank you.
[import]uid: 132369 topic_id: 28502 reply_id: 115529[/import]

You didn’t remove the Runtime listener that scrolls the background, right? Not removing it would cause an error like that. [import]uid: 52491 topic_id: 28502 reply_id: 115581[/import]

If i remove “Runtime:addEventListener( “enterFrame”, move )”, then the background won’t move. What should i do? [import]uid: 132369 topic_id: 28502 reply_id: 115753[/import]

Whenever you change scenes you need to remove any runtime listeners, timers etc that the scene uses.

In this case, the Runtime listener you added doesn’t go away when you go back to the main menu, and it is then trying to perform operations on variables or objects which no longer exist, which will give an error.

If you are using storyboard, place this in the exitScene function, or else just make sure it is called before the code to switch to another screeen or restart the level.

[lua]Runtime:removeEventListener(“enterFrame”,move)[/lua]

[import]uid: 93133 topic_id: 28502 reply_id: 115763[/import]

Very well explained, Nick :slight_smile: [import]uid: 52491 topic_id: 28502 reply_id: 115789[/import]