Reader small image

You're reading from  Gideros Mobile Game Development

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781849696708
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Arturs Sosins
Arturs Sosins
author image
Arturs Sosins

Arturs Sosins is a developer living with his wife Anna and son Tomass. He has a Master's degree in Computer Science and even though he is working as a developer full time, he still loves coding and shares his knowledge with others in his spare time. In his last years at the university, he started chasing the dream of creating his own mobile games for fun and personal satisfaction in his spare time. After trying out lots of different cross-platform frameworks for mobile game development, he found Gideros SDK in January 2012 and liked it so much that he decided to stick with it when developing his games. In the summer of 2012, he founded a group of like-minded developers/designers who go under the indie label Jenots.com (http://jenots.com/). They released Mashballs (http://jenots.com/mashballs), their first game, in September 2012 and are currently working on a couple of bigger game projects. As there was a lack of learning materials and tutorials for Gideros and writing was one of the his favorite hobbies, he started creating different tutorials on how to accomplish simple things in Gideros. This led him to create his new blog http://appcodingeasy.com. Due to popularity of his tutorials and the support he provided on the Gideros community forum, he became the most active community member. In February 2013, the Gideros team offered him the position in the Gideros developers' team, where he has been working since then, while continuing to work on games in his spare time.
Read more about Arturs Sosins

Right arrow

Chapter 2. Managing Scenes and Gideros OOP

Now that we know all the basics, let's create our own game. We will be creating a clone of a Mashballs game, a simple 2D physics puzzler, where the main objective of the game is to drag and launch the main ball in any direction to bounce and hit all other balls on the screen. You can find more information about the game and also download it from: http://jenots.com/mashballs.

We will use Gideros Object Oriented Programming (OOP) and create our own classes, which we will be using throughout the game. As well we will learn to manage multiple scenes and switch between them, and also how to store persistent information for our app.

The following are the topics we will be covering in this chapter:

  • Setting up our project

  • Introduction to Gideros OOP

  • Introduction to scene manager

  • Creating your own scenes with Gideros OOP

  • Creating a start screen for the game

  • Creating an options screen for the game

  • Storing persistent information

Setting up our project


Open up Gideros Studio and create a new project. Let's call it MashballsClone. While we are there, let's create the main.lua file for our initial code and also create the images folder to store our images in.

Just to make our project more maintainable, it is better to copy the files of the Gideros project in the same folders as you add them inside Gideros Studio. For example, create the images folder (and any other folder we will be creating) in your filesystem, and before you add images to Gideros project folder, copy them into the corresponding folder and only then add it in Gideros Studio. That way the structure will be the same for both Gideros project and your filesystem.

Now let's do the necessary settings. Right-click on the MashballsClone folder inside the Project pane and select Properties. Click on the iOS tab and select For iPhone and iPad as value for both Retina Display and Autorotation, which means we will support both iPads and iPhones with Retina display...

Creating scenes


Now we should have the main.lua and test.lua files in our project. The first one is empty, and the second one has our experiments with project settings. But note this, if we add some code to main.lua too, the code from both the files (main.lua and test.lua) will be executed. That is because Gideros automatically executes all added Lua files. This might be something new even to experienced Lua developers, as you won't require every file you want to use; and it provides a much more flexible approach in handling projects. But it also has its own limitations.

For example, if all the code is executed automatically, how should we separate different scenes, we want to use in our game, in a better way? Or in what order are the files executed? What if one file depends on another one?

By default, files are executed in the order they were added, but we can assume that the execution order is random and we should not rely on it. The correct way to manage a project is to divide all your...

Summary


We have successfully created the first working scenes of our game. In this chapter we learned how to create Gideros classes, by creating the Button and Settings class. Then we learned how to manage different scenes using Gideros OOP and scene manager. We also learned to use events and store information persistently.

In the next chapter we will start creating the game logic, including managing packs and level loading and unlocking, as well as adding the logic for running the game itself and creating a physics model for our objects.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Gideros Mobile Game Development
Published in: Nov 2013Publisher: PacktISBN-13: 9781849696708
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Arturs Sosins

Arturs Sosins is a developer living with his wife Anna and son Tomass. He has a Master's degree in Computer Science and even though he is working as a developer full time, he still loves coding and shares his knowledge with others in his spare time. In his last years at the university, he started chasing the dream of creating his own mobile games for fun and personal satisfaction in his spare time. After trying out lots of different cross-platform frameworks for mobile game development, he found Gideros SDK in January 2012 and liked it so much that he decided to stick with it when developing his games. In the summer of 2012, he founded a group of like-minded developers/designers who go under the indie label Jenots.com (http://jenots.com/). They released Mashballs (http://jenots.com/mashballs), their first game, in September 2012 and are currently working on a couple of bigger game projects. As there was a lack of learning materials and tutorials for Gideros and writing was one of the his favorite hobbies, he started creating different tutorials on how to accomplish simple things in Gideros. This led him to create his new blog http://appcodingeasy.com. Due to popularity of his tutorials and the support he provided on the Gideros community forum, he became the most active community member. In February 2013, the Gideros team offered him the position in the Gideros developers' team, where he has been working since then, while continuing to work on games in his spare time.
Read more about Arturs Sosins