Misunderstanding Logic.....

I push my widget (start new game) button and everything gets removed from the main screen as intended. I however want new graphics and other elements to load as now the game would be officially starting. Imagine a game screen that says, NEW GAME, LOAD, EXIT. 

You choose one option and the screen gets “cleared” and new elements load in depending on what option you choose. This is the point i am at. Now for my question… :slight_smile:

im not sure if i have the logic right, but my code after I choose NEW GAME looks like this;

– after start button is tapped game starts

if startButton:true then

    local bgLand = display.newImage ( " farmGround.jpg " )

bgLand.x  = centerX

bgLand.y = centerY

end

I get errors at the starting line of the code above (after the comment, of course). I was reading where some people use groups, as well as functions to achieve what I am attempting. I don’t think i am understanding the logic…

Most tutorials show how to create a game, which is great, but i havent found any that show you how to take a game from intro screen or NEW GAME screen to where the game actually starts. This is my current hurdle.

I bought the iskills tutorials for hundred bucks and they are good but they put me to sleep…no offense to the trainer… >_>

Anyhow, thank you again. Much appreciated.  :)

Hi,

Even though it might take some time to fully understand the ins and outs around the storyboard library, I still would suggest this path. The tutorials together with the sample code should at least get you up and running. The fine details is after all possible to attack later.

Best regards and good luck.  

My ‘Angry Birds’ menu template uses Storyboard and contains fully commented code so you can see how it all works.

http://forums.coronalabs.com/topic/29558-angry-birds-menu-and-levels-database-template/

Thank you but I would like to stay away from using director or storyboard as I am not creating levels. Just one main level. Thats it. Plus I don’t want to have to buy a bunch of third party plugins as this is my first app. All it is going to do is go from START GAME screen to the game itself. Thats it.

After I actually create a finished product then I will be willing to look into buying plugins, as for now I am “in training” and don’t want to invest in something that I am still a beginner at. If things end up getting too hairy then I may quit and move on…Hope that dont happen as I really like corona so far.

So, if anyone has any other suggestions on how to accomplish this feat, I would appreciate it a lot. At the moment, Im stuck trying to get this chunk of code to work properly. Thank you very much.

I hear what you’re saying - however Storyboard is a built-in Corona library and free. It really would make things a whole lot easier, storyboard is for all kinds of apps - not just multi-level games.

If I get time tonight I will knock up a simple example of a start screen > button press > game screen scenario.

Thanks Nick. To be honest, I have tried storyboard, and it just confuses the H outta me. I come from a 3D CG art background. As far as programming languages are concerned, even in college, has always been my cryponite…Lua is the only language I have ever gotten to work, that is to say a graphic on the screen. That is why it has kept my interest so far.

Okay. I tried a few things and came up with the following;

I have a button widget called startButton (respectively). The event listener code in this post works with and without the TRANSITION.TO keyword. However, even though it doesn’t cause an error, it doesn’t work either lol…At least t doesn’t do anything visually.

Tried -

startButton:addEventListener( “tap”, startButton, transition.to ( {onComplete = gameStart} ) )

and

startButton:addEventListener( “tap”, startButton, transition.to ( onComplete = gameStart ) )

and

startButton:addEventListener( “tap”, startButton)

I get the same results for every sample (no visual result). My app works fine as I intend it too, but their is no visual change as I said.

I was hoping one of the examples above would load in new graphics as per the function I have above this code, which is;

function startButton:tap( e )
startButton:removeSelf()
startButton = nil
startLogo:removeSelf()
startButton = nil
titleBackground:removeSelf()
titleBackground = nil
end

function gameStart()
    local gameLevel = display.newImage ( " farmLand.jpg " )
    gameLevel.x = centerX
    gameLevel.y = centerY
end

So bottom line, when user pushes START BUTTON the app nils out everything, but I was hoping it would also load in the new graphic ( the farmLand.jpg file).

Anyone know what I am doing wrong.

Thanks all. I’ve been on many forums and this one is by far the most kindest, helpful and professional i have ever been on. Great community. Thanks again for any suggestions/help! :slight_smile:

GAMELEVEL by the way is a display object. I forgot to mention that.

Ok, in the zip file is a simple storyboard example of what you want to achieve.

Main.lua loads, sets up a few things we need throughout the app such as sounds and global functions, and then immediately loads the scene start.lua (in line 140).

At the top of each scene we load the libraries we need, initialise our main display group (localGroup), and define our objects and variables. This way everything we insert into localGroup, or attach to a local variable will automatically be cleaned by storyboard when we leave the scene.

Then we set up our functions that the scene will use - in this case, ‘touchButton’ will handle touch events on the startButton we’ll create.

Next come all the storyboard functions. Within createScene we load and position all the display objects we need, remembering to add them to localGroup and assign them to a local variable that we defined at the top. We can then reference these objects from anywhere in the code. I haven’t used widget buttons as I prefer to make them myself out of regular display objects.

When the ‘play’ button is touched, the touchButton function is fired, plays a sound, animates the button (by calling the global ‘doing’ function that was defined in main.lua) and then after a short delay, takes us to game.lua, which is just a background picture at present.

http://www.otterstudios.co.uk/storyboard_example.zip

Taking a gander at in now. Thanks in advance, Nick. I appreciate any and all help. :slight_smile:

Hi,

Even though it might take some time to fully understand the ins and outs around the storyboard library, I still would suggest this path. The tutorials together with the sample code should at least get you up and running. The fine details is after all possible to attack later.

Best regards and good luck.  

My ‘Angry Birds’ menu template uses Storyboard and contains fully commented code so you can see how it all works.

http://forums.coronalabs.com/topic/29558-angry-birds-menu-and-levels-database-template/

Thank you but I would like to stay away from using director or storyboard as I am not creating levels. Just one main level. Thats it. Plus I don’t want to have to buy a bunch of third party plugins as this is my first app. All it is going to do is go from START GAME screen to the game itself. Thats it.

After I actually create a finished product then I will be willing to look into buying plugins, as for now I am “in training” and don’t want to invest in something that I am still a beginner at. If things end up getting too hairy then I may quit and move on…Hope that dont happen as I really like corona so far.

So, if anyone has any other suggestions on how to accomplish this feat, I would appreciate it a lot. At the moment, Im stuck trying to get this chunk of code to work properly. Thank you very much.

I hear what you’re saying - however Storyboard is a built-in Corona library and free. It really would make things a whole lot easier, storyboard is for all kinds of apps - not just multi-level games.

If I get time tonight I will knock up a simple example of a start screen > button press > game screen scenario.

Thanks Nick. To be honest, I have tried storyboard, and it just confuses the H outta me. I come from a 3D CG art background. As far as programming languages are concerned, even in college, has always been my cryponite…Lua is the only language I have ever gotten to work, that is to say a graphic on the screen. That is why it has kept my interest so far.

Okay. I tried a few things and came up with the following;

I have a button widget called startButton (respectively). The event listener code in this post works with and without the TRANSITION.TO keyword. However, even though it doesn’t cause an error, it doesn’t work either lol…At least t doesn’t do anything visually.

Tried -

startButton:addEventListener( “tap”, startButton, transition.to ( {onComplete = gameStart} ) )

and

startButton:addEventListener( “tap”, startButton, transition.to ( onComplete = gameStart ) )

and

startButton:addEventListener( “tap”, startButton)

I get the same results for every sample (no visual result). My app works fine as I intend it too, but their is no visual change as I said.

I was hoping one of the examples above would load in new graphics as per the function I have above this code, which is;

function startButton:tap( e )
startButton:removeSelf()
startButton = nil
startLogo:removeSelf()
startButton = nil
titleBackground:removeSelf()
titleBackground = nil
end

function gameStart()
    local gameLevel = display.newImage ( " farmLand.jpg " )
    gameLevel.x = centerX
    gameLevel.y = centerY
end

So bottom line, when user pushes START BUTTON the app nils out everything, but I was hoping it would also load in the new graphic ( the farmLand.jpg file).

Anyone know what I am doing wrong.

Thanks all. I’ve been on many forums and this one is by far the most kindest, helpful and professional i have ever been on. Great community. Thanks again for any suggestions/help! :slight_smile:

GAMELEVEL by the way is a display object. I forgot to mention that.

Ok, in the zip file is a simple storyboard example of what you want to achieve.

Main.lua loads, sets up a few things we need throughout the app such as sounds and global functions, and then immediately loads the scene start.lua (in line 140).

At the top of each scene we load the libraries we need, initialise our main display group (localGroup), and define our objects and variables. This way everything we insert into localGroup, or attach to a local variable will automatically be cleaned by storyboard when we leave the scene.

Then we set up our functions that the scene will use - in this case, ‘touchButton’ will handle touch events on the startButton we’ll create.

Next come all the storyboard functions. Within createScene we load and position all the display objects we need, remembering to add them to localGroup and assign them to a local variable that we defined at the top. We can then reference these objects from anywhere in the code. I haven’t used widget buttons as I prefer to make them myself out of regular display objects.

When the ‘play’ button is touched, the touchButton function is fired, plays a sound, animates the button (by calling the global ‘doing’ function that was defined in main.lua) and then after a short delay, takes us to game.lua, which is just a background picture at present.

http://www.otterstudios.co.uk/storyboard_example.zip

Taking a gander at in now. Thanks in advance, Nick. I appreciate any and all help. :slight_smile: