Game Development Reference
In-Depth Information
The Gideros Engine
The Gideros engine is the framework that is facilitated by the Lua language for development. This
contains all the specific commands that grant access to the Gideros API. This is what a developer
can use to code and display an application to the device.
Gideros is object oriented, but do not let that sentence scare you. This just means that the Gideros
API uses colon notation rather than dot notation—for example, it would use image:setX(100) instead
of image.x = 100 .
new file or an existing file.
bird.png in our application, we need to add that to the project.
bird.png , and then creates a bitmap image
using that texture. This image instance is the sprite , or the object that we display on the screen; we
can reposition it as we like using the setPosition function.
In Gideros, when an object is created, it is stored in memory but not made visible to the user. We need
to add the display object that we create to the stage to be able to see it on the device screen.
local image = Bitmap.new(Texture.new("bird.png"))
To make things easier, we can also create our own shortcut methods or library:
function newImage (imageName, posX, posY)
local image = Bitmap.new(Texture.new(imageName))
stage:addChild(image)
image:setPosition(posX, posY)
return image
end
Now, all we need to do is call this function, as follows:
local birdie = newImage("bird.png", 100, 100)
Another point to note about Gideros Studio is that it loads multiple Lua files without having to use
the require function. We can use this to our advantage by having a separate file that houses all of
the utility functions for our projects. Let's create a file, myutils.lua , add the newImage function to it,
and include it in our projects.
 
Search WWH ::




Custom Search