Skip to content
This repository was archived by the owner on Nov 13, 2022. It is now read-only.
Tor (torbuntu) edited this page Apr 17, 2021 · 6 revisions

Leikr Helper API

Version 1.0.7

API
int getUsedSprites() Returns how many sprite draw calls have been made. The maximum is 128.
void loadSpriteSheet(String name) Loads a spritesheet from another package in the Programs directory.
void loadProgram(String name) Loads another program from the Programs directory, closing the current running program.
void setFont(String path, int spacing, int width, int height) Sets a custom font for your program.
String getProgramPath() Returns the path to the Programs directory.
String getDataPath() Returns the path to the Data directory.
int FPS() Returns the current FPS as an integer.
void pause() Pauses the game
void pause(boolean shouldPause) Pauses running program based on a variable.

Leikr Utilities

Leikr has a number of system utilities which can be passed to other classes to use.

  • System
  • Graphics
  • Audio
  • Data
  • Mouse
  • Keyboard
  • Controller

These are useful in order to more easily do operations in classes in separate files than your main program file. For example, if you have two groovy files:

Programs \
  - MyGame \
    - Code \
      - MyGame.groovy
      - Helper.groovy

If you wanted to use the graphics api to drawString in the Helper file, in your MyGame.groovy you could use getGraphics() and pass that into a method called render(graphics) in Helper.

class MyGame extends leikr.Engine {
    def helper
    void create(){
        helper = new Helper()
    void render(){
        helper.render(getGraphics())
    }
}

Then in Helper.groovy

class Helper {
    void render(graphics){
        graphics.drawString(1, "Helping!", 0, 0)
    }
}
Utility
getSystem()
getGraphics()
getAudio()
getData()
getMouse()
getKeyboard()
getController() Returns the first detected controller as ControllerA
getController(int id) Returns the controller with the given ID. 0 - ControllerA, 1 - ControllerB

Contents

Home

API

under construction for version 1.10.1

Clone this wiki locally