BGO (class)

From PGE Wiki
Jump to: navigation, search

This class provides fields/functions for managing BGOs in the current level. (LunaLua ≥v0.7)

Static functions

Static BGO Functions (Level only)
Function Return values Description
BGO.count() number How many BGOs are in the level.
BGO.get() table of BGO Returns all BGOs
BGO.get(number or table ids) table of BGO Returns all BGOs with the matching ids. Only the BGOs with the same id given by ids will be returned.
BGO.getIntersecting(number x1, number y1, number x2, number y2) table of BGO Returns all BGOs which are intersecting with an area from x1/y1 to x2/y2.
BGO(number index) BGO Returns the BGO object at position index in the global BGO table. Use this constructor with caution! Use BGO.get or BGO.getIntersecting instead!! (See above)

Instance functions

These fields and functions are part of BGO Objects and have to be called for that object. Trying to call them from the static BGO class will result in an error. Example (feel free to copy it into your lua file to see how it works):

function onTick()
    for index,myBGO in ipairs(BGO.get()) do
        myBGO.x = myBGO.x + 1
BGO class
Type Function/Field Return values/Value type Description
Field int The BGO-id of the BGO.
Field (ro) BGO.isHidden boolean True, if the BGO item is hidden.
Field BGO.x double The x coordinate of the BGO.
Field BGO.y double The y coordinate of the BGO.
Field BGO.width double The width of the BGO.
Field BGO.height double The height of the BGO.
Field BGO.speedX double The x-speed of the BGO.
Field BGO.speedY double The y-speed of the BGO.
Field BGO.layer Layer The layer of the BGO.
Field BGO.layerName string The layer name of the BGO.