CYOA Tips and Examples

Due to the nature of the CYOA projects, I’ve put together this page which will contain a few extra examples in Corona. Some of the topics here will be things we will cover in the programming lectures over time, but you guys may need to dive into them now in order to be on track for your project submissions. There will also be some extra examples in here which cover topics we won’t get to in our programming classes at all.

I’ve given you guys the tools at this point to go and explore Corona in your own time, so the examples here are definitely not a complete look at what Corona has to offer for your CYOA projects. These are more some basic examples to get you started when looking at certain topics.

Display Groups

One thing which is incredibly useful to be aware of in Corona, for any App, game or project, is Display Groups. Display Groups are a special type of Display Object which act as a group of display objects. You create a Display Group as you would any other Display Object, and then you add other Display Objects to this group(such as images, text, rectangles etc.) You can then change the attributes of this Display Group(Such as x,y,alpha) and these changes will affect everything in the group. The group has its own set of attributes, and doesn’t change the attributes of the individual display objects, it merely affects them all.

For example if I create a Display Group and set its x and y values to 100, this means our Display Group will start 100 pixels in from the left and 100 pixels in from the top of the screen. The same would happen with a rectangle we created and gave values of 100 to x and 100 to y. But if we do create this rectangle and then add it to the display group, the rectangle on screen will appear 200 pixels in from the left and 200 pixels down. This is because once we’ve added a display object to a group, it uses the Display Group’s x and y as its “top left corner” rather than the screen.

Display Group Example:


Another feature in Corona which is helpful for any App or Game, but especially helpful for your CYOA projects is the Storyboard library. This library uses a template “.lua” file which can be found on the Corona website which lets you create multiple “scenes” for your app, each one being a separate lua file. You will have a main.lua file(we always need one for any app) and then a number of other .lua files which will start off as the template I spoke about already. Now the template from the Corona website can be a little daunting, so I’ve made a more basic template to get you started for use with my Storyboard example.

I basically cover the basics of Storyboard in the example here, which is basically switching between scenes and making sure things reset every time you come back to a scene. The example has 4 scenes and can loop around from scene to scene. Remember that the template which I’ve included in this example is never actually used(everything will work the same if you delete it) it’s just for you guys to use as the template for your own scenes. But it is the first thing you should look at and read(it’s full of comments) because each of my 4 scenes are made from it.

Also be sure to check out the main.lua in the example since it is how you transition into the very first scene!

Storyboard Example:

Loading/Saving Files

If any of you want to be able to store data in your apps you’ll need to take a look at Loading a file and Saving a file in Corona. This is quite advanced stuff so I won’t try to explain it here. Instead I’ve just included my lecture slides and examples from a previous course. If you feel confidant enough in your Lua/Corona skills take a look at them.

Loading/Saving Example + Slides:

Horizontal Screen View

This one is an easy one! We’ll cover some other uses of the build.settings file in our programming classes towards the end, but if you want to force your App into being in Landscape mode instead of being in Portrait mode, simply include this example file in the same folder as your main.lua. It basically allows you to select which views are “supported” by your App. If you add more than one in their, your App will auto rotate! The main advantage of doing this is that your top left corner will change to be the top left corner as it would be in Landscape mode, so all your calculations and positioning can be based off that instead.

I haven’t gone into much detail here, so look up other examples of the build.settings file in Corona if you have any questions or issues!

Landscape View Example:

More Examples

If there’s any other topics that you guys need help with, you’re on your own I’m afraid! I’m a busy man! Be sure to check the sites I include at the top of each assignment though. There is a wealth of support and knowledge out there for Corona. Remember: Nobody taught Eoghan how to Corona, he used that exact wealth of information to teach himself! You can do it too! I believe in you!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s