Button Problem

Hi

I am trying a simple project which allows me to move on to the next screen using a button.

I have managed to get my splash screen (with a button), use the button to take me to screen 2, but can’t then get the button on screen 2 to take me to screen 3. When I try the same piece of code but inserting the new image, it either doesn’t work at all or skips to the last screen. Here is the first part which is working. Hope someone can help. Thanks
local background = display.newImage(“images/screen1.jpg”)

local myButton = display.newImage(“images/buttonGreen.png”)
myButton.x = display.stageWidth/2
myButton.y = display.stageHeight -75

function myButton: tap (event)
display.newImage(“images/about.jpg”)
myButton = display.newImage(“images/buttonGreen.png”)
myButton.x = display.stageWidth/2
myButton.y = display.stageHeight -75
end

myButton: addEventListener(“tap”, myButton)
[import]uid: 45029 topic_id: 9406 reply_id: 309406[/import]

You shouldn’t switch between “scenes” in this manner. The best way is to use something called a Director. If you ever worked with Cocos2d, you should be familiar with it.

Anyway, Ricardo wrote a Lua implementation that you can find in the Code Exchange section. [import]uid: 51516 topic_id: 9406 reply_id: 34375[/import]

Hi

Thanks for your response. I have no knowledge of any programming language. I will check out the link.

Bob [import]uid: 45029 topic_id: 9406 reply_id: 34376[/import]

Once you pick up Director Class sample code from the code exchange, you can find a really great tutorial from the creator of director class Ricardo on youtube which may help you a lot if you are not familiar with programming.

He takes you through some of the implementation and how to use it.

By following along and typing the code yourself in your own lua file, it will really help you in understanding how it works

Here’s the link

http://www.youtube.com/watch?v=RAktnj7nwos

Cheers [import]uid: 50045 topic_id: 9406 reply_id: 34497[/import]

Thanks for the advice, I appreciate you taking the time to respond. I am on the case (slowly!).

Regards
Bob [import]uid: 45029 topic_id: 9406 reply_id: 34510[/import]

Hi seth.dev.ios

If I only want to move from page to page with a button, Is it possible? If it is, can you provide a simple solution to the problem above.

Thanks

Bob [import]uid: 45029 topic_id: 9406 reply_id: 34528[/import]

Hey Bob,

http://techority.com/2010/11/19/how-to-use-scenesscreens-in-corona/

That link is for a tutorial that’s aimed at people who are VERY new to Lua and Corona.

The sample project you can download should be useful, I hope - it’s all commented and you can see pages being switched with a button press, which seems to be what you’re after :slight_smile:

Peach [import]uid: 52491 topic_id: 9406 reply_id: 34531[/import]

Hi Peach

Thanks for the link to the tutorial, I am now feeling even more de-skilled than before! Despite several attempts, I am still not getting it! I have created the new splash.lua file as per your step 4 and inserted this code
module(…, package.seeall)

function new()
local localGroup = display.newGroup()
return localGroup
end
The screens I want to load are “screen1” - “screen5” and I understand that each of these screens needs to be a .lua file but I am unable to load the First one (splash.lua).

Emergency Surgery required!!! [import]uid: 45029 topic_id: 9406 reply_id: 34541[/import]

Is splash.lua something you are using rather than Default.png to show a splash screen?

If you’re at all interested I do run a 1 on 1 training service with a discount for new Corona users; email me if so. (It’s not affiliated with Corona in any way, it’s just something I do myself.)

Anyway - why isn’t the first one loading? That’s what you need to figure out.

Have you /told/ it to load? [import]uid: 52491 topic_id: 9406 reply_id: 34554[/import]