Gideros Basics - Part I
In this article, we shall look at Gideros and understand the basics before we start developing with it. This is for those that are new to development with Lua frameworks or are looking at Gideros after having tried another framework.
What is Gideros?Gideros is a Lua based framework from Gideros Mobile, a company based in Turkey. Gideros Studio, which is the name of the product, creates projects that can be compiled using Eclipse (for Android, Kindle and/or Nook) or xCode (for iOS). Gideros Studio has a community edition which is a Free license for anyone to use it. The advantage of Gideros over another framework like CoronaSDK is the ability to create and add Plug-Ins (native code written in Objective-C, Java or C) that can help extend Gideros Studio and use these extensions/plug-ins via Lua. It is available for both Windows and Mac OSX and can run on a Linux box (using Wine).
Advantage of GiderosThere are a couple of advantages of Gideros over other frameworks. Some of the features of Gideros are
- Object-oriented structure
- Similarity to Actionscript
- Faster than some other frameworks
- Uses Plug-ins
Our first programOf the many frameworks that are available for the Desktop, Gideros Studio is the only one that comes with an IDE. The easiest way to start development is to start Gideros Studio, from the startup screen, select the option "Create New Project" and name it, for example "Project1" and select the default location and select the "Create directory for project" check box which will create a directory for this project.
Next, right click on the Project name and select "Add New File" and name the file
main.lua this is where we shall write our code.
Note: The first thing that a lot of beginners miss out on is how to run the Lua code. The IDE has a blue play button which is disabled, the simple reason for which is that unless Gideros Studio has a connection to the Gideros Player it does not allow for the code to be run. To start the Gideros Player click on the XBox controller looking icon, and the blue play button would get enabled.
We can try our Lua code - our hello world
print("Hello from Lua - Gideros style")
when we press the blue play button, we can see the text Hello from Lua - Gideros style in the output window and the Gideros Player with a blank white screen.
Understanding Gideros GUIGideros is a framework for Mobile development and it relies on GUI elements which are displayed on the Mobile Device. As you like it, In the words of Shakespere; "All the world's a stage" and with Gideros the root object where all of the GUI elements are added and made a part of.
Adding an imageAnother thing to note with Gideros is that for any asset (file, image, sound, etc) to be accessed by Gideros Studio it needs to be added to the project. Like we right-clicked to add a new file, we can use the "Add Existing Files" to locate and add the existing files which can then be used from the code. Say we have an image called image1.png and we add that to the project using the Add Existing Files and let's use that from code
local img = Bitmap.new(Texture.new("image1.png"))
and if we run our code it runs fine but nothing is seen in the Gideros Player. This is another little thing that a lot of beginners miss and wonder why the code did not work. It has everything to do with the fact earlier that everything has to be on the stage to be able to be seen. So we need to add the line
stage:addChild(img)this adds the Image onto the stage and now if we run the code, it is seen. In case you are wondering what the
Bitmap.new and the
Texture.new is all about, for Gideros Studio, a texture is any Image that can be used and the Bitmap image is the way to create an Image object to which we pass the texture object to create the bitmap from.
Positioning the ImageWe have now successfully placed the Image on the Player but it is at the top left corner of the screen, we can position the image anywhere we want by using the member function