How to change scenes

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.

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?

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.

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:
[lua]
local function onBtn1Release(event)   
    
    – go to scene
    storyboard.gotoScene( “scene2”, “zoomInOutFade”, 700 )
    
            return true  – indicates successful touch
    end

[/lua]

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

[/lua]

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. 

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

Well first, if you read the docs, you’d notice how the 'onRelease = onBtn1Release’ should go inside the function (I was just referencing that line to explain what it does)

Also, you forgot to name your button.

it should look something like this:
[lua]
local storyboard = require( “storyboard” )

local scene = storyboard.newScene()
local widget = require “widget”

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

local Btn1 = widget.newButton{
 
    left = 12,
    top = 200,
    defaultFile = “bottom.png”,
    overFile = “over.png”,
    onRelease = onBtn1Release
}
[/lua]

Okay Saer: Thnak you.

I think that the main.lua file code is working (I’m not sure)maybe…

but when the program tryies to go to scene2 THERE IS A PROBLEM

-----------------------------------------I have the same code as you do---------------------in MAIN.LUA-----------

display.setStatusBar (display.HiddenStatusBar)

local storyboard = require “storyboard”
local scene = storyboard.newScene()
local widget = require( “widget” )

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

local Btn1 = widget.newButton
{
    left = 12,
    top = 200,
    defaultFile = “button.png”,
    overFile = “over.png”,
    onRelease = onBtn1Release
}

on scene2 I have this ----------------------------------------------

storyboard = require “storyboard”
widget = require( “widget” )
scene = storyboard.newScene()

bg = display.newImage (“background1.png”)


I don’t know waht is wrong yet!

once I get it to work in the very basic concept I can expand more from there, but it needs to work first RIGHT?

I’m putting a video so you see the problem I have. I’m in Murrieta Ca. at 3:48 p.m.

here is the video

http://www.youtube.com/watch?v=w88yhbpIElg&feature=youtu.be

thanks for all your help

Victor

Yeah, the maze thing was my bad. You were correct to remove it.

Well, I hadn’t intended the code I posted to be used by itself in a blank project.
I thought you would just pull out the button and scene function and use it in your project.

I learned how to use storyboard via Corona’s Game template:
Corona Simulator > New Project > Choose a template: Game

It is very clear how it uses storyboard to change scenes.
If you want, you can delete the code relating to physics, the box, and grass.

Okay we’re doing good! but still it doesn’t work…

---------------- scene2 ----------------------

local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

widget = require( “widget” )

– Called when the scene’s view does not exist:
function scene:createScene( event )
    local group = self.view

    – create a grey rectangle as the backdrop
    local background = display.newRect( 0, 0, screenW, screenH )
    background:setFillColor( 128 )
    
    – all display objects must be inserted into group
    group:insert( background )

end

thanks

Just ignor all the code you saw (as you can see if you refresh the page it’s all gone)
So you can just edit your reply and remove the code so someone else who might see this won’t get confused.

Corona Simulator a.k.a the app that installs on your computer (the program you run)
Here is the game template totally stripped down to the essential code:
https://www.dropbox.com/s/agv6nqquh5g1o9m/SceneChange.zip

That’s all I can really suggest.

EDIT: To edit your comment/post just click the little button that says “Edit” then remove the code bit and click “Save Changes”

THANK YOU VERY MUCH!!!

Now it works!!!  THANKS…YES!!!


Now it’s my turn to learn…

I’m going to read all this code and understand it. Then try to apply this to my own app, It’s late now

maybe by tomorrow I will have questions. But for now it looks great!

But now I got it, it needed a lot more code, than just the little pieces I had before, to make it work

believe me it’s a lot of code, I would have never been able to figure it out by myself ever!

Thnaks for the .zip file this is great!

And if somebody else is reading this, download the file it’s GREAT!

now I will go to work!

thank you again Saer

Victor

looks like you forgot to call the ui.  Place this on line 1 in your code, prior to anything else.

local ui = require("ui")

I’ve never used that or seen it for that matter? Where is the documentation for this “ui”?

Thanks for ALL YOUR HELP!

I got the STORYBOARD WORKING NOW!!!  – I think.

Now it’s time to star making my book, I’m sure I will have more questions.

THE FIRST ONE

how can I make the .png background fit the view of the iPad?

I have a .png file 1024 X 768 Landscape for iPad

but when I see that in the Corona simulator iPad, it;s only 3/4 of the screen it does not fill all the screen?

Any Help?

Bro, that is a very basic question easily answered in the corona documentation:
http://docs.coronalabs.com/api/index.html

Programming takes a lot of time to learn, I’m going on one year and haven’t even finished my first app - I had absolutely zero coding experience when I started.

When someone replies to a post with either a link to something or actual code, don’t just go straight for the code, read the definition on how it works.

Look in the Corona API docs and look for display.newImage.

This is my last post I’m going to make because everything you are wanting help with you can easily find/figure out on your own, if you’re willing to take the time.
** In my opinion **

I wish you the best of luck with your project! :smiley:

Hi Saer!

I did not want to bother you, I’m so sorry. I understand that you have no obligation to take time to answer any of my questions.

And you are right, I can probably read “stuff” in the link you sent me and with trial and error and experimenting I will probably learn…

but that will take me just like you… 1 year and still no app!

I may take … 5 years, or 10, (I’m 52) I don’t have a lot of years left!

and I don’t want to make the next “angry Birds” game

I want something very simple and basic, I’m almost there.

You did help me a lot with the zip file and for that I will always be gratful with you, Thank you.

If yu don’t answer any more, it’s okay, I really say thanks for all your help.

But I will keep asking a few questions,… someone will answer those questions, just like you did before.

Just imagine, how much time would have taking me to do the storyboard thing, if it wasn’t for your help…

another 2 or 3 months maybe? or maybe more 7 months?

So thanks to you, I know now in just one month, what most people would take 5 or 6 months to learn.

So thank you for everything, and if someone reads this I want to say thaks to all of you for your help.

Victor

Is anybody there? Hello?

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 -

Hi Brent, Dr. Burton, Saer, And all my friends at Corona Forum

I am working now on my book finally!!!

See, I told you, I did not needed a lot of things to start working, it’s a simple book for children.

I have the storyboard working, I have so far 4 pages, the home and the main.

I can add pages, make simple animation, and I can add sound to the buttons.

So I’m really happy because now I can keep learning more, but start making my app now

Thank you for all your help, thanks Dr. Burton for your book.


One question, I think it’s very important…

Once I finish my book which it’s for the iPad ONLY, and I can see the final book in the Corona Simulator in my Mac…

what I see in my computer will be the same, and it will look and behave exactly the same as in a REAL iPAD?


And one more…

About money – I have to pay $99.00 per year to Apple for the developer program to upload my app to the app store

to see if they accept it, right?

And how much money do I have to pay to Corona for using the program?

Is there any more fees or money involved?


Thank you for everything.

Let’s see how long it takes me to write my book

Victor

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

Victor