Gideros Project Template for your Indie Games

Game configuration

Gideros Project Properties
  • Settings tab: current version of the game, build version, retina display and autorotation.
  • Window tab: scale mode (recommended letterbox), logical dimensions, window size, orientation (Portrait or Landscape) and FPS (30 or 60).
  • Input tab: behaviour of mouse and touch events.

Starting point file

application:setKeepAwake(true)
application:setOrientation(Application.PORTRAIT)
application:setBackgroundColor(0xffffff)
Gideros Main File

Game assets

  • The images folder where all your game graphics are placed.
  • The sounds folder where music and sounds of your game are set.
  • The fonts folder where all your game fonts are localized.

Loading game

-- Loading function
local function draw_loading()
loading = Sprite.new()

local font = TTFont.new("fonts/firstfun.ttf", 50)
local text = TextField.new(font, "Loading")
local posX = (application:getLogicalWidth() - text:getWidth()) * 0.5
text:setPosition(posX, 280)
text:setTextColor(0x00ff11)
loading.text = text
loading:addChild(text)

stage:addChild(loading)
end
  • Creates a loading Sprite object which must contain the Loading text message.
  • Defines a local font variable which uses the TTFont Gideros class to load firstfun TrueType font with size 50.
  • Creates a local text variable which is a TextField object with Loading string text.
  • Sets the X position and the text color of the text variable.
  • Adds the text variable to the loading Sprite object
  • We wish to render loading text in screen, so adds the loading Sprite object to stage.

Detecting Platform

local iOS = application:getDeviceInfo() == "iOS"
local android = application:getDeviceInfo() == "Android"

Scene Manager plugin

Gideros SceneManager Plugin
require "scenemanager"
require "easing"

Game scenes

Menu Scene

  • First a scenes folder is created within Files, this folder is where all game scenes are placed.
  • Second the menu.lua file is created within scenes folder with the following Lua code:
MenuScene = Core.class(Sprite)-- Static setup
function MenuScene.setup()
end-- Constructor
function MenuScene:init()
end

Game Scene

GameScene = Core.class(Sprite)-- Static setup
function GameScene.setup()

end
-- Constructor
function GameScene:init()
end
Gideros Menu Scene

Using scenes

draw_loading()
stage:addEventListener(Event.ENTER_FRAME, preloader)
  • Invoke the local draw_loading function.
  • Add ENTER_FRAME event listener to call the preloader function the first time screen must be rendered. Click on ENTER_FRAME event for specific info about this event.
local function preloader()
stage:removeEventListener(Event.ENTER_FRAME, preloader)
-- Load all your assets here
MenuScene.setup()
GameScene.setup()
-- List of scenes
scenes = {"menu", "game"}
sceneManager = SceneManager.new({
["menu"] = MenuScene,
["game"] = GameScene
})
stage:addChild(sceneManager)

-- MenuScene is the first scene to show
local currentScene = scenes[1]

local timer = Timer.new(2000, 1)
timer:addEventListener(Event.TIMER,
function()
-- Remove loading scene
stage:removeChild(loading)
loading = nil
sceneManager:changeScene(currentScene)
end)
timer:start()
end
  • Remove the ENTER_FRAME event listener. We only need to call the preloader function once.
  • Invoke MenuScene.setup and GameScene.setup functions to load the scenes assets.
  • Define the game scene list that will be used by sceneManager variable.
  • The variable currentScene defines the MenuScene as the default game scene.
  • Use Gideros Timer class to wait 2000 miliseconds until the Menu scene is shown by sceneManager variable.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store