How to create a new page

Hi,

Please could somebody help me with an app i am currently developing? Basicity i have a background with a piece of text on which i would like to be able to let the user touch the text and it then send them to a new screen with information on and then on that screen with the information on, have a back arrow to take them back to the original screen? I am new to this so if you could say it as simply as possible that would be great! Thanks, Charlie.

Take a look at the Sample Code -> Interface -> Composer.

Basically, you would set up two scenes:  one for the main page (with the text/button), and one for the “new screen with information on it”.   The text on the main page would catch the touch event and issue a call to composer.gotoScene( “scene2” … ).  The code in scene2 would display the information and include a button; that button would have a touch handler that issues a call to composer.gotoScene( “scene1” … ).

Thankyou for the quick reply. I have now made a file in the main folder called scene1.lua and how would i now intergrate that with the main.lua file? Many thanks.

In the sample code, in the main.lua file, you should see:

          composer.gotoScene( “scene1” … )

with some extra arguments (like transition effects and timing).  That’s it.  

The main.lua code can initialize variables, define functions, etc. and then it will send control over to scene1.lua.

Some more info:

          http://docs.coronalabs.com/guide/system/composer/index.html

Thank you again.

I still don’t fully understand it. sorry i know i am a bit of a newbie to apps and the SDK Language.

Attached is the code from my “main.lua” file. could you possibly put in the required code to send the user to “scene1.lua” when they click on the “New School Times” Text. By the way this is a app for my school thats why it has lots of school related stuff on there. I would give credit to you for helping out in coding if you wanted. Thanks, Charlie.

–TRFWIA Timetable app. Developed and made by Charlie Bolland


local composer = require “composer”

–Set Background

local background = display.newImage(“background4.jpg”)

–Set Foreground

–local foreground = display.newImage(“trfwia_logo.png”)

–foreground.x = display.contentWidth/2

–foreground.y = display.contentHeight/2

–Set Header

local header = display.newImage(“trfwia_banner.png”)

header.x = display.contentWidth/1.6

–Text (TRFWIA Timetable)

local trfwiatimetable = display.newText(’ TRFWIA Timetable’, 160, 60, “appleberry”, 30 )

trfwiatimetable:setTextColor( 0,0,0 )

–Text (----------)

local dashes = display.newText(’-----------------------’, 160, 80, “appleberry”, 30)

dashes:setTextColor( 0,0,0 )

–Text (New School Times)

local newschooltimes = display.newText(’ New School Times’, 160, 150, “appleberry”, 30)

newschooltimes:setTextColor( 0,0,0 )

–Text (Your Personal Planner)

local personalplanner = display.newText(’ Your Personal Planner’, 160, 220, “appleberry”, 28)

personalplanner:setTextColor( 0,0,0 )

–Text (By Charlie Bolland.    v1.0)

local charlie = display.newText(‘By Charlie Bolland. V1.0’, 210, 500, “appleberry”, 20)

charlie:setTextColor( 0,0,0 )

–Text (School Email)

local email = display.newText(‘School Email’, 160, 290, “appleberry”, 30)

email:setTextColor( 0,0,0 )

–Text (School Website)

local schoolwebsite = display.newText(‘School Website’, 160, 360, “appleberry”, 30)

schoolwebsite:setTextColor( 0,0,0 )

local composer = require( “composer” )

Take a look at the Sample Code -> Interface -> Composer.

Basically, you would set up two scenes:  one for the main page (with the text/button), and one for the “new screen with information on it”.   The text on the main page would catch the touch event and issue a call to composer.gotoScene( “scene2” … ).  The code in scene2 would display the information and include a button; that button would have a touch handler that issues a call to composer.gotoScene( “scene1” … ).

Thankyou for the quick reply. I have now made a file in the main folder called scene1.lua and how would i now intergrate that with the main.lua file? Many thanks.

In the sample code, in the main.lua file, you should see:

          composer.gotoScene( “scene1” … )

with some extra arguments (like transition effects and timing).  That’s it.  

The main.lua code can initialize variables, define functions, etc. and then it will send control over to scene1.lua.

Some more info:

          http://docs.coronalabs.com/guide/system/composer/index.html

Thank you again.

I still don’t fully understand it. sorry i know i am a bit of a newbie to apps and the SDK Language.

Attached is the code from my “main.lua” file. could you possibly put in the required code to send the user to “scene1.lua” when they click on the “New School Times” Text. By the way this is a app for my school thats why it has lots of school related stuff on there. I would give credit to you for helping out in coding if you wanted. Thanks, Charlie.

–TRFWIA Timetable app. Developed and made by Charlie Bolland


local composer = require “composer”

–Set Background

local background = display.newImage(“background4.jpg”)

–Set Foreground

–local foreground = display.newImage(“trfwia_logo.png”)

–foreground.x = display.contentWidth/2

–foreground.y = display.contentHeight/2

–Set Header

local header = display.newImage(“trfwia_banner.png”)

header.x = display.contentWidth/1.6

–Text (TRFWIA Timetable)

local trfwiatimetable = display.newText(’ TRFWIA Timetable’, 160, 60, “appleberry”, 30 )

trfwiatimetable:setTextColor( 0,0,0 )

–Text (----------)

local dashes = display.newText(’-----------------------’, 160, 80, “appleberry”, 30)

dashes:setTextColor( 0,0,0 )

–Text (New School Times)

local newschooltimes = display.newText(’ New School Times’, 160, 150, “appleberry”, 30)

newschooltimes:setTextColor( 0,0,0 )

–Text (Your Personal Planner)

local personalplanner = display.newText(’ Your Personal Planner’, 160, 220, “appleberry”, 28)

personalplanner:setTextColor( 0,0,0 )

–Text (By Charlie Bolland.    v1.0)

local charlie = display.newText(‘By Charlie Bolland. V1.0’, 210, 500, “appleberry”, 20)

charlie:setTextColor( 0,0,0 )

–Text (School Email)

local email = display.newText(‘School Email’, 160, 290, “appleberry”, 30)

email:setTextColor( 0,0,0 )

–Text (School Website)

local schoolwebsite = display.newText(‘School Website’, 160, 360, “appleberry”, 30)

schoolwebsite:setTextColor( 0,0,0 )

local composer = require( “composer” )