Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to change scenes
Started by helloworld2013d Apr 23 2013 03:34 PM

36 replies to this topic
storyboard books scenes
[TOPIC CONTROLS]
Page 1 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

How to go from the main.lua to another file, like game.lua

I want to write a book. I can do a lot of things in the main.lu file

now I want to go somewhere else, to a scene 2 or page 2 of the book for that matter.

How do I do that?

 

Victor

---------------------------------------------TIME FOR ME TO GIVE BACK A LITTLE-----------------------------------

About one month ago I post this and I did not know how.....thanks to the corona community, to Rob, Saerothir, mourdos,ksan, Brent and many more now I know how to go to other scene, and I will tell you how it works for me in a very simple way. In a way I would have wished someone would have told me the first time I ask about a month ago,

and instead of taking me a month to learn something, it would have taken me no more than 10 minutes.

 

If you are reading this the first time, here is the answer. It works for me, I hope it works for you

-------------------------------------------------------------------------------------------------------------------------------

STEP -- 1

in the main.lua file you need this

 

display.setStatusBar( display.HiddenStatusBar )                 -- hide the status bar
local storyboard = require "storyboard"                               -- you need to have this storyboard thing
storyboard.gotoScene( "working2" )                                    -- Here you are telling the program to go to the scene

                                                                                                 you want to go, or the page, or the view. Here I want

                                                                                                 to go to a scene called "working2"

 

that's it 3 lines of code in the main.lua. If you want to go to a scene call "level1" you put "level1" inside the parenthesis, like this: -- storyboard.gotoScene( "level1" )

and the program will go to level1.

 

It works like a link on a web-site. Now remember that you have to have in a folder on your desktop the two files, main.lua and level1.lua, if you don't have that file, the program will not run.

----------------------------------------------------------------------------------------------------------------------------

STEP -- 2

 

Now, when the program goes to ("working2") then it will create the "first page" of your book, or the first scene, or the first view, it's like when you turn on the TV is the first thing you see.

 

To do this it needs this code

 

local storyboard = require( "storyboard" )                -- it needs the soryboard all the time
local scene = storyboard.newScene()                      -- and it needs this line to create a new scene or new page

 

now, you need to have 4 functions in here.

1 to create the scene

2 to enter the scene

3 to exit the scene

4 to destroy the scene

 

each function is like this:

 

-- --==**************************[ CREATE SCENE ]**********************************++-- --

function scene:createScene( event )
    local group = self.view
    
    local background = display.newImage( "backgroundLevel1Q4.png" )
    
    group:insert ( background )
    
end

 

-- --==***************************[ ENTER SCENE ]**********************************++-- --

function scene:enterScene( event )
    local group = self.view
    
end

-- --==***************************[ EXIT SCENE ]**********************************++-- --

function scene:exitScene( event )
    local group = self.view
    
end

-- --==**************************[ DESTROY SCENE ]*********************************++-- --

function scene:destroyScene( event )
    local group = self.view    
        
end

-------------------------------------------------------------------------------------------------

STEP -- 3

 

In the createScene you need to place the background image, the buttons, or things that you wnat to see in your page, or view. If you have a button or a sprite or something, you add this in here. I just add a background so we can see something. I use this line, and the background image is there.

 

local background = display.newImage( "backgroundLevel1Q4.png" )

 

Now I have to insert that image into a group, so when I go to another scene the group, and everything inside will hide from the view. It's like an eraser.

 

-- so I created a group like this --

 

local group = self.view

 

-- and then I inserted the background in the group like this --

 

group:insert ( background )

 

-- you do all this in the createScene.

-------------------------------------------------------------------------------------

STEP -- 4

 

Now you need to add the event listeners, like this --

 

scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )

 

-- you add one for each scene, and at the end of the program you type this --

 

return scene

 

------------------------------------------THAT'S IT--------------------------------------------

Here's all the code you need in a very simple way.

 

--------------------------------------main.lua-------------------3 lines of code------------------

display.setStatusBar( display.HiddenStatusBar )
local storyboard = require "storyboard"
storyboard.gotoScene( "working2" )

-------------------------------------------------working2-------------------21 lines of code------------------

local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
function scene:createScene( event )
    local group = self.view
    local background = display.newImage( "backgroundLevel1Q4.png" )    
    group:insert ( background )    
end
function scene:enterScene( event )
    local group = self.view    
end
function scene:exitScene( event )
    local group = self.view    
end
function scene:destroyScene( event )
    local group = self.view            
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
return scene

------------------------------------------------------------------------------------END----------------------------

Now that you are in the new scene, actually is the first one that you see, you want to go to another page, or another view right?, to do that you need to have a "button" to touch that button and it will take you to another view, or will change the page or the channel on your TV.

 

First you have to have a widget to create a button -- Remember there are many ways to do the same thing, I'm telling you how I do it, I don't know if it's the "Correct" way, but it works.

 

you need 1 line of code to "require" a widget -- local widget = require "widget" -- you have to add this right after the line -- local storyboard = require( "storyboard" ) --

 

So like this

 

local storyboard = require( "storyboard" )
local widget = require "widget"   -------------------this is the new line to create the button.
local scene = storyboard.newScene()

----------------------------------------------------------------------

STEP -- 5 -- Now create the button. this is the code you need --------------6 lines--------------

 

buttonHome = widget.newButton{
        defaultFile="buttonHome.png",
        onRelease = buttonHome
    }
    buttonHome.x = 522
    buttonHome.y = 655

 

-- now you have to put this code inside the "createScene" function. Right after this line of code

 

local background = display.newImage( "backgroundLevel1Q4.png" )
    buttonHome = widget.newButton{
        defaultFile="buttonHome.png",                                             --------here I just have an image for the button
        onRelease = returnHome                                                       --------and here is when they release the finger
    }                                                                                                             it will perform the function "returnHome"
    buttonHome.x = 522
    buttonHome.y = 655
    group:insert ( background ) 

    group:insert ( buttonHome )                                                       ---------- here I'm inserting the button in the group

 

-- and you have to insert the new button in the group also.

-- when people release the finger it will run the program of a function called "returnHome"

 

You need to have the function at the beginning of the program, so the function is there first, so you write the function like this:

 

local function returnHome()                                                               ------- this is the name of the function
        storyboard.gotoScene( "level1Q3", "crossFade", 1000 )      -----Here you're telling the storyboard to go to

                                                                                                             level1Q3.lua file, to go there it will make a

                                                                                                             special effect like "crossFade" and it will

                                                                                                             take 1 second to go to the new scene
    return true
end

 

---------------------------------------------------------------------------This code looks like this

local storyboard = require( "storyboard" )

local widget = require "widget"
local scene = storyboard.newScene()
local function returnHome()
        storyboard.gotoScene( "level1Q3", "crossFade", 1000 )    
    return true
end
function scene:createScene( event )
    local group = self.view
    local background = display.newImage( "backgroundLevel1Q4.png" )
    buttonHome = widget.newButton{
        defaultFile="buttonHome.png",
        onRelease = returnHome
    }
    buttonHome.x = 522
    buttonHome.y = 655
    group:insert ( background )
    group:insert ( buttonHome )
end
function scene:enterScene( event )
    local group = self.view    
end
function scene:exitScene( event )
    local group = self.view    
end
function scene:destroyScene( event )
    local group = self.view            
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
return scene

---------------------------------------------------------------------We're almost there------------------------

Now because you created a button, you have to destroy that button, before you go to a new scene, if you don't the button will be there forever.

 

In the destroyScene you add this code--

 

if buttonHome then                                  ------- if you use the button, of course you did
        buttonHome:removeSelf()                ------- then button, remove your self
        buttonHome = nil                               ------- and you add this line, that's it button, we're done.
    end

 so the complete code looks like this

 

local storyboard = require( "storyboard" )
local widget = require "widget"
local scene = storyboard.newScene()
local function returnHome()
        storyboard.gotoScene( "level1Q3", "crossFade", 1000 )    
    return true
end
function scene:createScene( event )
    local group = self.view
    local background = display.newImage( "backgroundLevel1Q4.png" )
    buttonHome = widget.newButton{
        defaultFile="buttonHome.png",
        onRelease = returnHome
    }
    buttonHome.x = 522
    buttonHome.y = 655
    group:insert ( background )
    group:insert ( buttonHome )
end
function scene:enterScene( event )
    local group = self.view    
end
function scene:exitScene( event )
    local group = self.view    
end
function scene:destroyScene( event )
    local group = self.view
    if buttonHome then
        buttonHome:removeSelf()
        buttonHome = nil
    end        
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
return scene

----------------------------------------------------------------------------------------------------

With this code you can go from one scene to another, as many as you want.

This works for me really good, I hope I made this very simple. It's long but you read it and copy the paste nad that's it.

The answer I was looking for one month ago, now it's here.

 

I know it's really good, if you did not know how to do this and now this help you...

 

you're welcome.

 

Victor



[TOPIC: post.html]
#2

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

Is anybody there? Hello?



[TOPIC: post.html]
#3

Saerothir

[GLOBAL: userInfoPane.html]
Saerothir
  • Contributor

  • 267 posts
  • Corona SDK

Checkout Corona's sample code.
Everything you need to get started can be found there.
- It's all included in the file you get when you download the SDK -



[TOPIC: post.html]
#4

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

Would you please help me out, I don't really understand the concept, if you know how, would you teach me please?

 

Victor



[TOPIC: post.html]
#5

Mirada Connect

[GLOBAL: userInfoPane.html]
Mirada Connect
  • Enthusiast

  • 47 posts
  • Corona SDK

local storyboard = require "storyboard"
 
storyboard.gotoScene( "game", options )

 

Above is the most basic of scene changes. You would probably want to wrap that goToScene call in a listener attached to something like a button, I suspect. Go and have a look at the storyboard tutorial and try to write a bit of code and do some trial and error.

 

If you don't put in any effort and try to do it yourself, nobody else will. If you end up getting stuck, post the code your having problems with and people will probably be more inclined to help. A general "tell me how to do everything so I don't have to" isn't going to get many responses.

 

Especially since your in the wrong subforum for storyboard :-)



[TOPIC: post.html]
#6

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

Thank you Mourdos: For the time you took to post this...

I AM VERY VERY VERY NEW AT ALL THIS! So

-- local storyboard = require "storyboard"

-- storyboard.gotoScene ("game", options)

it doesn't tell me anything, I just don't get it, and I don't know how to use it or put it in my code.

I just one to change the page, like a book.

 

YOU: "You would probably want to wrap that goToScene call in a listener attached to something like a button, I suspect"

ME: If you mean "goToScene" go to another "Page" yes that it's what I want, BUT I DON'T KNOW HOW.

       When you said "attached to a button", Yes!, but I don't know how.

YOU: "Go and have a look at the storyboard tutorial and try to write a bit of code and do some trial and error."

ME: I don't know where it is...And even If I find it, I go and just read and click, isn't it another way? I would not know what

        I'm looking for, so I don't know what to click.

YOU: "If you don't put in any effort"

ME: Yes I AM putting a lot of effeort, I bought a book from Dr. Burton, I still don't find that answer ( and I read all the book

        already). I download about 20 sample code from github, and nothing, I watch about 100 videos on youtube, and nothing

        all I have is this forum it's the only one I have found that somebody actually talks to me back, so I'm lost. But I AM 

        PUTTING A LOT OF EFFORT, I just don't know what to do.

YOU: "post the code your having problems with"

ME: The problem is that I don't have a code yet! I know how to do a few things, but all of them are in just one page, or one

       view, or one file main.lua, So all those things I can do, and I understand it, but I don't know how to turn a page (gotoScene)

YOU: "A general "tell me how to do everything so I don't have to" isn't going to get many responses"

ME: And I don't want people to tell me how, so I don't have to... I WANT TO LEARN, so I know there is a way to change a view

       or goToScene, I KNOW THAT, but...

       1 .- Either I have not found someone who knows how to do it

       2.- Or they know, and they just don't want to share it, or teach me

       3.- Or because they had SO MUCH trouble learning before, just like me today, now they want me to suffer, jut like they did

YOU: "Especially since your in the wrong subforum for storyboard"

ME: If you KNOW that I am in the "WRONG" place, would you be so kind to tell me how to get to the "RIGHT" place. And it took

       me 3 or 4 days to answer this, because I wanted to find out for myself, but I JUST CAN'T.

       Even if I AM in the WRONG place, this is the ONLY PLACE that at least I get people like you to tell me things, and I'm

       learning like that.

 

By the way my name it's Victor M. Barba, if you Google my name you'll see that I have a lot of books published already by the major music companies in the world. SO I WILL LEARN HOW TO MAKE AN APP, what ever it takes.

 

I hope you still can and want to help me and if you know how to gotoScene or change the page of my book, would you please tell me how in a very EXPLICIT WAY, I would really appreciated it.

 

Thank you Mourdos, and God bless you!

 

Victor



[TOPIC: post.html]
#7

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Hi Victor, have you had a chance to review the sample called Storyboard? It has 4 scenes and transitions between them. You can take this and tweak it to meet your needs. Alternatively, I think I recall seeing an eBook template for sale on the commercial section of this forum. I would think that the template developer would help you get up to speed if you wish to go that way. 

 

PS. No connection to the template developer mentioned and have no clue on the quality of his/her work. Was just an idea. 

 

Best of luck in your endeavor.



[TOPIC: post.html]
#8

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

Thank you Ksan:

 

Where do I get that "Sample called Storyboard?



[TOPIC: post.html]
#9

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

It should be in the following subfolder of your Corona installation : 

 

/CoronaSDK/SampleCode/Interface/Storyboard



[TOPIC: post.html]
#10

Saerothir

[GLOBAL: userInfoPane.html]
Saerothir
  • Contributor

  • 267 posts
  • Corona SDK

"1 .- Either I have not found someone who knows how to do it

  2.- Or they know, and they just don't want to share it, or teach me

  3.- Or because they had SO MUCH trouble learning before, just
like me today, now they want me to suffer, jut like they did"


I can guarantee nobody here wants you to suffer. :)

We just don't want to up and give you the code, not because we don't want to help, but because we would actually be doing you a disservice - I think so anyway.
When it comes to learning to program, I've found that while studying and reading books on the subject can certainly help, actually creating a blank project and typing even just a few lines of code to display an image is far more valuable.


Have you tried looking at/experimenting with the various templates?
Corona Simulator > New Project >  Choose a template:
Blank
App
Game
E-book
Scene


If you did in fact read Burton's book, then you should at least have a
understanding of various basic concepts and be able to experiment with the code included in Corona's templates, and if not then I'd suggest re-reading the book and having a go at implementing some of the concepts he covers.

While it's a good goal to try and challenge yourself, I'd suggest you try and make something very basic so you can get a firm understanding of the code&concepts that go into creating an app.


You can do it!! :D



[TOPIC: post.html]
#11

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

I'm going to move this to the storyboard forum.



[TOPIC: post.html]
#12

eieiosoftware

[GLOBAL: userInfoPane.html]
eieiosoftware
  • Enthusiast

  • 52 posts
  • Corona SDK

OK helloworld2013,

 

You sound a little lost.  Did you download Corona SDK?  If so, that will contain a whole bunch of sample code, along with a Corona Simulator, which will run the codes.  It will not contain a text editor, which you will have to look for and download from the web.  I'm on a Mac and I use TextWrangler, but if your on a pc, just look for a good free code editor.  

 

Now, open the Corona SDK folder and look for Sample Code, then Interface, then Storybook.  Open the main.lua file in the simulator, and ALL of the .lua files in the text editor.  

 

Now start playing with the code.  The best way to learn what the code does and how it works is to mess with it.  Change numbers, save it, and see what it changed in the simulator.  Study every aspect of the code, and learn what it does.  Remember, whenever you change something in the code, save it, and see what it did in the simulator.  You can always undo anything that breaks the app.

 

Hope this is basic enough to get you started.



[TOPIC: post.html]
#13

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

Thank you everyone for helping me, THANK YOU VERY MUCH!

 

I'm learning little by little, but I'm almost there to start making my books.

One more question -- I'm adding a video to try to explaing the question better

 

 

Thank you again for all your help.

I got the sound --

the storyboard --

the animation --

the background --

 

Good!

 

Victor



[TOPIC: post.html]
#14

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Great to hear of your progress!!! 



[TOPIC: post.html]
#15

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

ksan, do you know how to answer the question I have in the video?



[TOPIC: post.html]
#16

Saerothir

[GLOBAL: userInfoPane.html]
Saerothir
  • Contributor

  • 267 posts
  • Corona SDK

Awesome! glad you're making progress! :)

One question though -
On scene one, is that one entire background image or are those icons (what you are wanting to be buttons) individual images?



[TOPIC: post.html]
#17

eieiosoftware

[GLOBAL: userInfoPane.html]
eieiosoftware
  • Enthusiast

  • 52 posts
  • Corona SDK

OK, it's pretty simple.  Before you do anything, you'll need to create images for your buttons as .png files.  Then, here's how I do it.


--here you create the function to go to the new scene, my FUNCTION is called "gotobg"
local function gotobg(e)
   storyboard.gotoScene( "bluegrass" )	
end

--then you need to create the button, and here is how i do it... "bgme" is my object name
--and notice what it points to for the "onRelease"

local bgme = ui.newButton{ default="bgbutton.png", over="bgbuttonover.png", onRelease=gotobg }
bgme.x = display.contentWidth / 2
bgme.y = display.contentHeight / 2

 

That's it.  Notice my image is called "bgbutton.png" and it's .x and .y are set to be the middle of the screen. The scene I'm going to is called "bluegrass.lua"



[TOPIC: post.html]
#18

Saerothir

[GLOBAL: userInfoPane.html]
Saerothir
  • Contributor

  • 267 posts
  • Corona SDK

*Everything* you need for creating a button is right here:
http://docs.coronalabs.com/api/library/widget/newButton.html

If you have a solid background and not individual images for buttons, then you'll just need to create an invisible circle/rectangle and position it over the area where you want the button.
For invisible touch-sensitive buttons/whatever:

.isVisible = false;
.isHitTestable = true;

Also, check out this page: http://docs.coronalabs.com/api/event/touch/phase.html


 



[TOPIC: post.html]
#19

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

I will post a video with all this answers, but first let me ask you this:

 



[TOPIC: post.html]
#20

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

Hi Saerothir, eieiosoftware, ksan...

I have this video trying the code that eieiosoftware, told me, I couldn't make it work WHY?

 

 

programming is hard, I guess you must be really inteligent, to do this. (I think I am)... or I though I was!



[TOPIC: post.html]
#21

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Victor, I am sure you have all the intelligence needed. No need to question that! Learning to program is not much different than learning music. You need time and practice. Why not take a step back, buy a good book (ie Dr. Burton's Corona book) and go through all the practice work? I think you might be trying to bite off too much too fast. Just my humble opinion. Wishing you all the success.



[TOPIC: post.html]
#22

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

I bought the book already! Good book!

-- Chapter I -- the hello world is easy to understand and I got that, no problem

-- Chapter 2 -- Buttons and text, I got this one too, it's okay

-- Chapter 3 -- Animation alpha, I got this too, a button than change the opacity of an object, got it!

-- Chapter 4 -- Simple calculator, -- I don't really need to create a calculator, but I more or less get this concept

-- Chapter 5 - vector graphics, I got this one, no problem

-- Chapter 6 - config.lua, adding sound, the beat-Box, I got this part!

--HERE IS THE PROBLEM--

Now it looks like another book, it goes too fast with many stuff

--Chapter 7 -- The Director ? the modules packages ? ...seeall ? CrawlerSpace?

--Chapter 8 -- Physics, more or less

--Chapter 9 -- that's it! Too much Collision Detection? Game Loop? I just don't really get all these.

-- Cahpter 10 and 11 -- more complicated SQLite? Json?

 

and more and more complicated...

 

Do you think if I hire someone to write the code I need, would I get better results?



[TOPIC: post.html]
#23

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Sounds like you have invested a lot of good time. The book covers Director which is a scene management system developed by a fellow developer on this forum. Now Corona Labs has its own scene management system called the StoryBoard which you have been learning through samples. For your purposes I would skip Physics, collision detection etc since they are more relevant to games. SQLite/Json might be relevant to you depending on how you intend to store and retrieve your lesson content. You're on the right path.



[TOPIC: post.html]
#24

Saerothir

[GLOBAL: userInfoPane.html]
Saerothir
  • Contributor

  • 267 posts
  • Corona SDK

Did you read any of the info in the links I posted?
They will tell you everything you want to know.

This is the format I use for when I create a function to change a scene:

local function onBtn1Release(event)   
    
    -- go to scene
    storyboard.gotoScene( "scene2", "zoomInOutFade", 700 )
    
            return true  -- indicates successful touch
    end


Use the information provided in the link I posted above for creating a widget, button, and just reference the scene change function e.g.
onRelease = onBtn1Release


Now since the icons you want to represent buttons are a part of the background image itself, then just forget these two lines:

default = "default.png",
over = "over.png",


and just define the size&location of the button.
Also, be sure to use
.isVisible = false;
.isHitTestable = true;

You'll just be positioning an invisible rect that will receive touch-events. 



[TOPIC: post.html]
#25

helloworld2013d

[GLOBAL: userInfoPane.html]
helloworld2013d
  • Contributor

  • 664 posts
  • Corona SDK

Thank you Saerothir: but still is not working. Let's start from the VERY BEGINNING.

 

All I have is a main.lua file and 1 scene2.lua file.

 

-- main.lua

---------------------------------------------------------

display.setStatusBar (display.HiddenStatusBar)

local storyboard = require "storyboard"
local widget = require( "widget" )

widget.newButton
{
    left = 12,
    top = 200,
    defaultFile = "button.png",
    overFile = "over.png",
}

local function onBtn1Release(event)
       storyboard.gotoScene( "scene2", "fade", 400 )
    return true
end

onRelease = onBtn1Release

-----------------------------------------------------

-- scene2.lua

-------------------------------------------------

local storyboard = require "storyboard"
local widget = require( "widget" )

local bg = display.newImage ("background1.png")

--------------------------------------------------------------

 

And is not working,

 

ALL THIS LET'S NAT COMPLICATE THINGS

Now since the icons you want to represent buttons are a part of the background image itself, then just forget these two lines:

default = "default.png",
over = "over.png",



and just define the size&location of the button.

Also, be sure to use

.isVisible = false;

.isHitTestable = true;


You'll just be positioning an invisible rect that will receive touch-events.

 

I just want to understand the basic concept of going from one place to the other.

 

All I have is a button, that I created with

 

widget.newButton
{
    left = 12, -- LOCATION
    top = 200, -- THIS IS JUST LOCATION EASY!
    defaultFile = "button.png", -- THIS IS JUST THE IMAGE I WANT FOR THE BUTTON
    overFile = "over.png",  -- I CAN EVEN TAKE THIS OUT, I know what this is for
}

 

Now I have the button...

I created the function to make the button take me to the other scene

 

local function onBtn1Release(event)
       storyboard.gotoScene( "scene2", "fade", 400 )
    return true
end

 

OKAY NOW WHAT? This is my problem

 

onRelease = onBtn1Release -- THIS LINE DOESN'T WORK

 

do I addEventListener ?  - IT DID NOT WORK

 

or am I missing something on the "scene2.lua" file

 

local storyboard = require "storyboard" -- I JUST HAVE THE STORYBOARD REQUIRE
local widget = require( "widget" ) -- THE WIDGET REQUIRE

local bg = display.newImage ("background1.png") -- And I just have a background there, just to make sure I', in the other place.

 

Believe me I'm trying, is it SO HARD TO DO THAT?

 

Victor




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]