Touch event question please?

Okay so I learned this storyboard thingy using this code.My whole code till now.

local physics = require “physics”

physics.start()

local homescreen = display.newImage( “TVGS.png” )

local play = display.newImage( “play.png”, 25 , 130 )

local gameMusic = audio.loadStream( “BackgroundMusic.mp3” )

local gameMusicChannel = audio.play( gameMusic, { loops = -1 } )

local storyboard = require “storyboard”

storyboard.gotoScene(“level1”)

So what this does is bring up the first scene in which there is a play button.Now what I want is that when a person hits the play button the scene changes.What should I do.
Will keep asking more question as my game idea is tough.Please please please help fast.

http://docs.coronalabs.com/api/library/widget/newButton.html
(for creating a button. using the ‘onRelase’ you can have it call a function where you can do whatever - like go to a new scene)

Unless your code is in main.lua it can’t even be called because you haven’t created an actual scene yet .
I highly recommend looking at the Storyboard documentation as well as the included sample code from Corona - which you get when you download the sdk.

Good-luck!

-Saer
 

Thank you So much Saer.But I would like to know that is there a nested code like in c# for eg.(this one’s just made up)
on touch ("-object-")

if true

local storyboard = require “storyboard”

blablabla

end

Just something like that?

-Regards and gratitudes.

Abhinav

You can attach a touch event-listener to an object that calls a function when said object it touched.
http://docs.coronalabs.com/api/type/EventListener/addEventListener.html

And if you want something to happen at different phases of the touch, check out the event.phase docs:
http://docs.coronalabs.com/api/event/touch/phase.html

If you have any questions let me know.

Cheers!

-Saer

Thanks Saer.Helped me out.Can you stay connected with me,I need LOTS of help.

I’ll do what I can, but ultimately it’s up to you how far you progress.
It’s a tough road learning to program mobile applications; just stick with it. :smiley:

-Saer

http://docs.coronalabs.com/api/library/widget/newButton.html
(for creating a button. using the ‘onRelase’ you can have it call a function where you can do whatever - like go to a new scene)

Unless your code is in main.lua it can’t even be called because you haven’t created an actual scene yet .
I highly recommend looking at the Storyboard documentation as well as the included sample code from Corona - which you get when you download the sdk.

Good-luck!

-Saer
 

Thank you So much Saer.But I would like to know that is there a nested code like in c# for eg.(this one’s just made up)
on touch ("-object-")

if true

local storyboard = require “storyboard”

blablabla

end

Just something like that?

-Regards and gratitudes.

Abhinav

You can attach a touch event-listener to an object that calls a function when said object it touched.
http://docs.coronalabs.com/api/type/EventListener/addEventListener.html

And if you want something to happen at different phases of the touch, check out the event.phase docs:
http://docs.coronalabs.com/api/event/touch/phase.html

If you have any questions let me know.

Cheers!

-Saer

Thanks Saer.Helped me out.Can you stay connected with me,I need LOTS of help.

I’ll do what I can, but ultimately it’s up to you how far you progress.
It’s a tough road learning to program mobile applications; just stick with it. :smiley:

-Saer