General Game Template

General Game Template

Our general game template gives you pre-coded splash screens, menu screen, settings screen, very crude skeleton of a game screen (just to show you where to build your actual game code), and magical handling of game and setting save files.

Get our General Game Template now from the Corona Labs Marketplace.

Important First Steps

Please follow these IMPORTANT steps before trying to launch:

  1. Edit the plugins section of build.settings to remove any plugins you don't want to use. We're loading in Qiso and Applovin by default.
  2. If removing Applovin, Also remove:
    • The entire Ad Network section of globals.lua.
    • The globals.personalisedAdverts(globals.settings.personalisedAdverts) call from within the loadSettingsFile function of globals.lua.
    • And the globals.personalisedAdverts(globals.settings.personalisedAdverts) call from within the togglePersonalisedAds function of settings.lua (or remove that function and the button that calls it accordingly).
  3. If NOT removing Applovin, populate sdkKey = "" within the Ad Network section of globals.lua with your own Applovin key. Please refer to https://docs.coronalabs.com/plugin/applovin/index.html for details on how to obtain a key and configure your account.

Usage Instructions

To further develop this template for your own game:

  1. globals.lua contains everything that all game scenes need to share.
    • Any settings that you want your players to be able to control should go in the globals.settings table within this file with their default values. The template will automatically handle saving and loading this table to a settings file.
    • Any initial game variables that a new game needs to comprise should go in the globals.gameDefaults table within this file. The New Game trigger creates a new game data table from these values.
    • Any game variables and level data etc should go in the globals.gameData table within this file. The Load Game trigger restores save data to here, and calling globals.writeGameFile() saves this data to file.
    • All button events pass their event as a callback to globals.buttonEffect to create the click animation before the event call. Look here if you want to rework this effect.
  2. main.lua contains an initialScenes table which defines the series of splash screens that show on start-up.
    • Add/remove splash screens as required within this table.
    • Clone/rename the splash-*.lua scenes within the screens folder to match changes made to this table.
    • Each splash scene creates a coloured rectangle or a background image, and overlays with a logo image. Replace these images within the assets folder as needed.
  3. menu.lua (within screens folder)
    • Same as with the splash scenes, this loads in a background image and a logo image from the assets folder. Replace accordingly.
    • We've included editable SVG files for creating/replacing the buttons. Inkscape is a fantastic, free vector editor that'll load these files in just fine.
    • The template looks for a game save file and enables/disables the Load Game button accordingly.
    • New Game populates globals.gameData with whatever you set in globals.gameDefaults and transitions to the game.lua scene within the screens folder.
    • The Load Game button event populates globals.gameData with whatever is saved to the game file and transitions to the game.lua scene within the screens folder.
  4. settings.lua (within screens folder)
    • Same as with the splash scenes, this loads in a background image and a logo image from the assets folder. Replace accordingly.
    • Again we've included editable SVG files for creating/replacing the buttons. Inkscape is a fantastic, free vector editor that'll load these files in just fine.
    • If adding additional settings to the globals.settings table within globals.lua, create toggle buttons here for them. Search this file for instances of buttonAudio to understand how these work.
  5. game.lua (within screens folder)
    • This is where you should build your game, replacing our crude background image and menu return button accordingly.
    • Note that our menu return button first calls globals.writeGameFile() to copy the globals.gameData table to file, ready for the menu Continue Game button to resume it. Do this whenever game data changes or as a user trigger if you want manual save events.
  6. Finishing touches
    • Replace the [GAME NAME] by QWeb Ltd. comment at the top of main.lua.
    • Replace the Icon.png and Icon-*.png files as needed.
    • If you kept the Applovin plugin, simply call globals.showAdvert() to load and show an appLovin interstitial advert whenever you like. In compiance with GDPR this will only show personalised (tracking cookie based) ads if the player consented via the settings scene.
    • Wrap any sound playback functions with if(globals.settings.audio == true) then ... end blocks.