Project Outline
 
gbox
addAudio(id, filename, def)
addBundle(call)
addFont(data)
addImage(id, filename)
addObject(data)
addScript(call)
blit(tox, image, data)
blitAll(tox, image, data)
blitClear(image, data)
blitFade(tox, data)
blitRect(tox, data)
blitText(tox, data)
blitTile(tox, data)
blitTilemap(tox, data)
centerCamera(data, viewdata)
collides(o1, o2, t)
createCanvas(id, data)
dataLoad(k, a)
dataSave(k, v, d)
getObject(group, id)
go()
hitAudio(a, data)
log()
pixelcollides(o1, o2, t)
playAudio(a, data)
readBundleData(pack, call)
setCameraX(x, viewdata)
setCameraY(y, viewdata)
setZindex(th, z)
stopAudio(a, permissive)
trashGroup(group)
 
help
asciiArtToMap(map, tra)
copyModel(data, model)
createModel(obj, attrs)
decideFrame(cnt, anim)
decideFrameOnce(cnt, anim)
framestotime(frames)
getArrayIndexed(a, value, field)
getTileInMap(x, y, map, ifout, mapid)
isLastFrameOnce(cnt, anim)
isSquished(th, by)
limit(v, min, max)
mergeWithModel(data, model)
multiplier(v, mul)
postpad(str, len, pad)
prepad(str, len, pad)
random(min, range)
seq(st, ed, skip)
setTileInMap(ctx, map, x, y, tile, The)
upAndDown(counter, max)
xPixelToTile(map, x, gap)
xPixelToTileX(map, x, gap)
yPixelToTile(map, y, gap)
yPixelToTileY(map, y, gap)
controlKeys(th, keys)
fireBullet(gr, id, data)
generateEnemy(gr, id, data, model)
generateScroller(gr, id, data)
hitByBullet(th, by)
initialize(th, data)
spawn(th, data)
after(th, id, frames)
every(th, id, frames)
randomly(th, id, data)
real(th, id, data)
 
tool
makecels(data)
callInColliding(th, data)
collides(fr, to, t)
controlKeys(th, keys)
fireBullet(gr, id, data)
floorCollision(th, data)
getAheadPixel(th, data)
initialize(th, data)
makedoor(gr, id, map, data)
pixelcollides(fr, to, t)
setStaticSpeed(th, speed)
spawn(
  • y {Integer}: (required)The object's y position.">th, data)
  • tileCollision(th, map, tilemap, defaulttile, data)
    wander(th, map, tilemap, defaulttile, data)
    addAngle(a, add)
    getAngle(p1, p2, transl)
    getDistance(p1, p2)
    translate(p1, a, d)
    translateX(x1, a, d)
    translateY(y1, a, d)
    «
    Akihabara Framework

    Namespace gbox

    Gamebox module allows multiple grouped objects to move simultaneously, it helps with collisions, rendering and moving objects. It also provides monospaced pixel-font rendering, keyboard handling, audio, double buffering and eventually FSEs. Gamebox can also store and load data from cookies!

    Defined in: gbox.js.

    Method Summary
    addAudio(id, filename, def)
    addBundle(call)
    addFont(data) Creates a font.
    addImage(id, filename) Adds an image file to the loader, assigning it to an ID. If adding an image to an existing ID, it checks to see if the file you're adding is different than the one currently assigned to the ID.
    addObject(data) Creates a new game object. Generally speaking you pass a fully-defined object as the parameter (including a group, id, tileset, and so on).
    addScript(call)
    addTiles(t) Creates a new Akihabara tileset, adding it to the engine.
    blit(tox, image, data)
    blitAll(tox, image, data) Draws an image to a canvas context
    blitClear(image, data) Clears a rectangular area of a canvas context.
    blitFade(tox, data) Draws a filled rectangle over an entire canvas context.
    blitImageToScreen(image) Draws an image directly to the screen's current canvas context. Used internally in gbox.go().
    blitRect(tox, data) Draws a filled rectangle to a canvas context.
    blitText(tox, data) Draws text to a canvas context
    blitTile(tox, data) Draws a tile to a canvas context
    blitTilemap(tox, data) Draws a tilemap to a canvas context
    canLog()
    centerCamera(data, viewdata) Centers the camera.
    clearGroup(gid) Destroys all objects in a given group.
    collides(o1, o2, t) Calculates a box collision between two collision boxes within a given tolerance. A higher tolerance means less precise collision.
    createCanvas(id, data) Creates a new canvas. By default, the width and height is the current gbox.
    dataClear(k) Clears a value stored in a key-value pair in a browser cookie. Sets value to "".
    dataLoad(k, a) Loads data from a browser cookie. Send it a key and it returns a value (if available).
    dataSave(k, v, d) Saves data to a browser cookie as a key-value pair, which can be restored later using gbox.dataLoad.
    debugGetstats() Displays basic audio, object, and performance statistics in the status bar. Automatically called each frame if the status bar is enabled.
    deleteCanvas(id) Deletes a given canvas.
    deleteImage(id) Deletes an image currently in use. Does not delete the image file, but removes it from Akihabara's image list.
    getAudioVolume(a, vol)
    getBuffer() Gets the buffer canvas (automatically created by gbox.initScreen).
    getBufferContext() Gets the buffer canvas context.
    getCamera() Gets the current camera object.
    getCanvas(id) Gets a given canvas.
    getCanvasContext(id) Gets the two-dimensional canvas context of a given canvas. The object it returns contains all the drawing functions for the canvas.
    getFlag(f) Returns a gbox flag at index f.
    getFont(id) Returns a font object containing data about the font.
    getFps() Get the frames per second rate (default is 25).
    getGroups() Get an array containing the names of each group in the game, in order of rendering.
    getImage(id) Gets information about a loaded image.
    getObject(group, id) Given a group and an id for a particular object instance, this returns the instance requested. NOTE: this does not return a copy of the object you've requested! Any modifications you make to the object returned are directly modifying the object you requested.
    getScreenH() Get the screen height.
    getScreenHH() Get the screen half-height.
    getScreenHW() Get the screen half-width.
    getScreenW() Get the screen width.
    getTiles(t) Gets an Akihabara tileset, adding it to the engine.
    go() This function is called once per frame. This is where the basic rendering and processing of groups occurs.
    groupIsEmpty(gid) Returns whether a given group contains no objets.
    hitAudio(a, data)
    imageIsLoaded(id) Checks to see if an image was successfully loaded.
    initScreen(w, h) Initializes the screen to a certain width and height, applies zoom attributes, populates the body of the HTML document including the canvas element, sets an initial camera, creates a '_buffer' canvas, sets keyboard event listeners, and many other initialization functions.
    keyIsHit(id) Returns true if a given key in this._keymap is pressed.
    keyIsHold(id) Returns true if a given key in this._keymap has been held down for at least one frame.
    keyIsPressed(id) Returns true if a given key in this._keymap is being held down.
    keyIsReleased(id) Returns true if a given key in this._keymap is released.
    loadAll(cb) Loads the initial splash screen and debugging font, then calls gbox._waitforloaded which adds to the game all the previously defined resources.
    log()
    objectIsTrash(o) Returns whether an object is due to be trashed. Useful in cases you want to check if an object is marked as trash before it is actually deleted.
    objectIsVisible(obj) Determines whether an object is visible by seeing if it collides with the camera's viewport.
    pixelcollides(o1, o2, t) Calculates a point-box collision between a point and a collision box within a given tolerance. A higher tolerance means less precise collision.
    playAllGroups() Enables all groups, toggling any groups that are currently disabled.
    playAudio(a, data)
    playGroup(gid) If a group is disabled, this will enable the group.
    playGroups(gid)
    purgeGarbage(obj) Clears the record held in gbox._garbage of what has been deleted.
    readBundleData(pack, call)
    setAudioVolume(a, vol)
    setCallback(cb) Deprecated: gbox._cb is now set by passing it directly into gbox.loadAll().
    setCameraX(x, viewdata) Sets the x value of the current camera object.
    setCameraY(y, viewdata) Sets the y value of the current camera object.
    setDoubleBuffering(db) Sets the gbox._db property.
    setForcedIdle(f) Sets the gbox._forcedidle property.
    setFps(f) Set the frames per second rate.
    setGroups(g) Defines the names of each group in the game along with their rendering order.
    setRenderOrder(g) A method of setting the render order of groups independently of gbox.setGroups.
    setStatBar(txt) Writes text to the status bar, but only if the status bar is enabled.
    setStatusBar(f) Sets the gbox._statbar property.
    setZindex(th, z)
    setZoom(z) Sets the gbox._zoom parameter, only works before gbox.initScreen is called.
    soloGroup(gid) Turns off all groups except for the one specified.
    stopAudio(a, permissive)
    stopGroup(gid) If a group is enabled, this will disable the group.
    stopGroups(gid)
    toggleGroup(gid) Toggles a group between enabled and disabled status.
    trashGroup(group) Deletes every object in a given group.
    trashObject(obj) Deletes an object, keeping a record of its group and id in gbox._garbage.
    Method Detail
    gbox.addAudio(id, filename, def)
    
    										
    									
    Parameters:
    id
    filename
    def
    gbox.addBundle(call)
    
    										
    									
    Parameters:
    call
    gbox.addFont(data)
    Creates a font.
    gbox.addImage('font', 'font.png');
    gbox.addFont({ id: 'small', image: 'font', firstletter: ' ', tileh: 8, tilew: 8, tilerow: 255, gapx: 0, gapy: 0 });
    Parameters:
    {Object} data An object containing:
    • id: the id of the font
    • image: reference to the font image loaded (must contain font character tiles in ASCII order)
    • firstletter: the ASCII character that the font image's first character corresponds to
    • tileh: height in pixels of the character tiles
    • tilew: width in pixels of the character tiles
    • tilerow: width in pixels of each row in the font image
    • gapx: x-coord gap between tile columns, in pixels
    • gapy: y-coord gap between tile rows, in pixels
    gbox.addImage(id, filename)
    Adds an image file to the loader, assigning it to an ID. If adding an image to an existing ID, it checks to see if the file you're adding is different than the one currently assigned to the ID. If it's different, it overwrites the old image. If it's the same, then no action is taken.
    
    										
    									
    Parameters:
    {String} id The identifier of the image.
    {String} filename The file name of the image.
    gbox.addObject(data) : Object
    Creates a new game object. Generally speaking you pass a fully-defined object as the parameter (including a group, id, tileset, and so on). A group must be specified, or the program will crash. If no id is specified, then it will automatically provide an id of 'obj-XXXX' where 'XXXX' is an automatically incrementing integer. This is where the initialize, first, and blit functions are defined, as well.
    data = {
      group: 'player',
      id: 'player_id',
      tileset: 'player_tiles', 
      x: 0,
      y: 0,
      initialize: function() {
          this.x = 10;
          this.y = 10;
          },
    };
    gbox.addObject(data);
    Parameters:
    {Object} data The object you wish to create.
    Returns:
    {Object} The object you created.
    gbox.addScript(call)
    
    										
    									
    Parameters:
    call
    gbox.addTiles(t)
    Creates a new Akihabara tileset, adding it to the engine.
    
    										
    									
    Parameters:
    {Object} t An object containing:
    • id {String}: the new id of the tileset
    • image {String}: reference to the tileset image loaded
    • tileh {Integer}: height in pixels of the tiles
    • tilew {Integer}: width in pixels of the tiles
    • tilerow {Integer}: width in pixels of each row in the font image
    • gapx {Integer}: x-coord gap between tile columns, in pixels
    • gapy {Integer}: y-coord gap between tile rows, in pixels
    gbox.blit(tox, image, data)
    
    										
    									
    Parameters:
    tox
    image
    data
    gbox.blitAll(tox, image, data)
    Draws an image to a canvas context
    // draw an image at (100,100)
    gbox.blitAll(gbox.getBufferContext(),gbox.getImage("image_id"),{dx:100,dy:100});
    Parameters:
    {Object} tox The canvas context to be drawn on.
    {Object} image The image to draw. Must be a DOM Image element, typicallly accessed via gbox.getImage
    {Object} data An object containing data about the tile to be drawn, including:
    • dx {Integer}: (required) x coordinate to draw the image at
    • dy {Integer}: (required) y coordinate to draw the image at
    • fliph {Integer}: horizontal flip, either 1 or -1
    • flipv {Integer}: vertical flip, either 1 or -1
    • alpha {Float}: alpha value (0 is transparent, 1 is opaque)
    gbox.blitClear(image, data)
    Clears a rectangular area of a canvas context.
    
    										
    									
    Parameters:
    {Object} image The canvas context to be drawn on.
    {Object} data An object containing a set of data, including:
    • x {Integer}: (required) the x coordinate of the top-left corner of the rectangle
    • y {Integer}: (required) the y coordinate of the top-left corner of the rectangle
    • w {Integer}: the width of the box; defaults to canvas width
    • h {Integer}: the height the box; defaults to canvas height
    gbox.blitFade(tox, data)
    Draws a filled rectangle over an entire canvas context.
    
    										
    									
    Parameters:
    {Object} tox The canvas context to be filled.
    {Object} data An object containing a set of data, including:
    • alpha {Float}: the alpha value of the rectangle; defaults to 1
    • color {Object}: the color of the box, formatted rgb(rValue, gValue, bValue); default black
    gbox.blitImageToScreen(image)
    Draws an image directly to the screen's current canvas context. Used internally in gbox.go(). Probably shouldn't be used otherwise.
    
    										
    									
    Parameters:
    image
    gbox.blitRect(tox, data)
    Draws a filled rectangle to a canvas context.
    
    										
    									
    Parameters:
    {Object} tox The canvas context to be drawn on.
    {Object} data An object containing a set of data, including:
    • x {Integer}: (required) the x coordinate of the top-left corner of the rectangle
    • y {Integer}: (required) the y coordinate of the top-left corner of the rectangle
    • w {Integer}: (required) the width of the box
    • h {Integer}: (required) the height the box
    • alpha {Float}: the alpha value of the rectangle; defaults to 1
    • color {Object}: the color of the box, formatted rgb(rValue, gValue, bValue); default black
    gbox.blitText(tox, data)
    Draws text to a canvas context
    
    										
    									
    Parameters:
    {Object} tox The canvas context to be drawn on.
    {Object} data An object containing a set of data, including:
    • font {String}: (required) the id of font to draw the text with
    • text {String}: (required) the text to display
    • dx {Integer}: (required) the x coordinate to draw the text at
    • dy {Integer}: (required) the y coordinate to draw the text at
    • dw {Integer}: the width of the text area -- required if you define data.halign
    • dh {Integer}: the height of the text area -- required if you define data.valign
    • valign {Integer}: either gbox.ALIGN_BOTTOM (aligns from the bottom of the text area) or gbox.ALIGN_MIDDLE (vertically centers text in text area)
    • halign {Integer}: either gbox.ALIGN_RIGHT (aligns to the right hand side of text area) or gbox.ALIGN_CENTER (horizontallly centers text in text area)
    • alpha {Float}: alpha value (0 is transparent, 1 is opaque)
    gbox.blitTile(tox, data)
    Draws a tile to a canvas context
    // from capman, draws an current object's tile, called from inside its blit function
    gbox.blitTile(gbox.getBufferContext(),{tileset:this.tileset,tile:this.frame,dx:this.x,dy:this.y,fliph:this.fliph,flipv:this.flipv,camera:this.camera,alpha:1});
    Parameters:
    {Object} tox The canvas context to be drawn on.
    {Object} data An object containing data about the tile to be drawn, including:
    • tileset {String}: the id of the tileset
    • tile {Integer}: the index of the tile within the tileset to be drawn
    • dx {Integer}: x coordinate to draw the tile at
    • dy {Integer}: y coordinate to draw the tile at
    • fliph {Integer}: horizontal flip, either 1 or -1
    • flipv {Integer}: vertical flip, either 1 or -1
    • alpha {Float}: alpha value (0 is transparent, 1 is opaque)
    gbox.blitTilemap(tox, data)
    Draws a tilemap to a canvas context
    
    										
    									
    Parameters:
    {Object} tox The canvas context to be drawn on.
    {Object} data An object containing a set of tilemap data, including:
    • tileset {String}: (required) the id of the tileset the tilemap is based on
    • map {Array}: an array whose x and y coord represent the tilemap coordinates, containing integers that correspond to the index of a given tile (or null for no tile)
    gbox.canLog()
    
    										
    									
    gbox.centerCamera(data, viewdata)
    Centers the camera.
    // Center the camera on the player object
    gbox.centerCamera(gbox.getObject('player', 'player_id'), {w: map.w, h: map.h});
    Parameters:
    {Object} data An object containing x and y parameters -- typically the object you wish to center the camera on.
    {Object} viewdata An object containing parameters h and w, which are a bounding box that the camera is not supposed to leave. For example, to use your map as a bounding area for the camera, pass along {w: map.w, h: map.h}.
    gbox.changeAudioVolume(a, vol)
    
    										
    									
    Parameters:
    a
    vol
    gbox.changeChannelVolume(ch, a)
    
    										
    									
    Parameters:
    ch
    a
    gbox.clearCache()
    
    										
    									
    gbox.clearGroup(gid)
    Destroys all objects in a given group.
    
    										
    									
    Parameters:
    {String} gid The id of the group.
    gbox.collides(o1, o2, t)
    Calculates a box collision between two collision boxes within a given tolerance. A higher tolerance means less precise collision.
    
    										
    									
    Parameters:
    {Object} o1 A collision box you're testing for collision. Must contain:
    • x {Integer}: (required) the x coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • y {Integer}: (required) the y coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • w {Integer}: (required) the width of the box
    • h {Integer}: (required) the height the box
    {Object} o2 A collision box you're testing for collision. Must contain:
    • x {Integer}: (required) the x coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • y {Integer}: (required) the y coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • w {Integer}: (required) the width of the box
    • h {Integer}: (required) the height the box
    {Integer} t The tolerance for the collision, in pixels. A value of 0 means pixel-perfect box collision. A value of 2 would mean that the boxes could overlap by up to 2 pixels without being considered a collision.
    Returns:
    True if the two collision boxes are colliding within the given tolerance.
    gbox.createCanvas(id, data)
    Creates a new canvas. By default, the width and height is the current gbox._screenw and gbox._screenh, but it can also be set by passing in a data object with the appropriate parameters.
    gbox.createCanvas('newCanvas', {w: 640, h: 480});
    Parameters:
    {String} id The id of the new canvas.
    {Object} data (Optional) The height and width of the new canvas, contained in data.h and data.w parameters.
    gbox.dataClear(k)
    Clears a value stored in a key-value pair in a browser cookie. Sets value to "". Only works if user has cookies enabled.
    
    										
    									
    Parameters:
    {String} k The key which identifies the value you are clearing.
    gbox.dataLoad(k, a) : Object
    Loads data from a browser cookie. Send it a key and it returns a value (if available). Only works if user has cookies enabled.
    hiscore = gbox.dataLoad("hiscore");
    Parameters:
    {String} k The key which identifies the value you are loading.
    {String} a A switch to determine whether a string or a number is returned. By default a string is returned.
    Returns:
    {Object} A string or a number loaded from the cookie.
    gbox.dataSave(k, v, d)
    Saves data to a browser cookie as a key-value pair, which can be restored later using gbox.dataLoad. Only works if user has cookies enabled.
    // (from Capman)
    gbox.dataSave("capman-hiscore",maingame.hud.getNumberValue("score","value"));
    Parameters:
    {String} k The key which identifies the value you are storing.
    {String} v The value you wish to store. Needs to be a string!
    {String} d A date offset, to be added to the current date. Defines the cookie's expiration date. By default this is set to 10 years.
    gbox.debugGetstats()
    Displays basic audio, object, and performance statistics in the status bar. Automatically called each frame if the status bar is enabled.
    
    										
    									
    gbox.deleteAudio(id)
    
    										
    									
    Parameters:
    id
    gbox.deleteCanvas(id)
    Deletes a given canvas.
    
    										
    									
    Parameters:
    {String} id The id of the canvas to be deleted.
    gbox.deleteImage(id)
    Deletes an image currently in use. Does not delete the image file, but removes it from Akihabara's image list.
    
    										
    									
    Parameters:
    {String} id The identifier of the image.
    gbox.getAudioDuration(a)
    
    										
    									
    Parameters:
    a
    gbox.getAudioIsSingleChannel()
    
    										
    									
    gbox.getAudioMute(a)
    
    										
    									
    Parameters:
    a
    gbox.getAudioPosition(a)
    
    										
    									
    Parameters:
    a
    gbox.getAudioVolume(a, vol)
    
    										
    									
    Parameters:
    a
    vol
    gbox.getBuffer() : Object
    Gets the buffer canvas (automatically created by gbox.initScreen).
    
    										
    									
    Returns:
    {Object} A DOM Canvas element, including the width and height of the canvas.
    gbox.getBufferContext() : Object
    Gets the buffer canvas context.
    
    										
    									
    Returns:
    {Object} A DOM Canvas context object.
    gbox.getCamera() : Object
    Gets the current camera object.
    
    										
    									
    Returns:
    {Object} The camera object.
    gbox.getCanvas(id) : Object
    Gets a given canvas.
    
    										
    									
    Parameters:
    {Object} id The identifier of the canvas.
    Returns:
    {Object} A DOM Canvas element, including the width and height of the canvas.
    gbox.getCanvasContext(id) : Object
    Gets the two-dimensional canvas context of a given canvas. The object it returns contains all the drawing functions for the canvas. See W3C and Mozilla Developer Center for details.
    
    										
    									
    Parameters:
    {Object} id The identifier of the canvas.
    Returns:
    {Object} A DOM Canvas context object.
    gbox.getChannelDefaultVolume(ch)
    
    										
    									
    Parameters:
    ch
    gbox.getChannelVolume(ch)
    
    										
    									
    Parameters:
    ch
    gbox.getFlag(f)
    Returns a gbox flag at index f.
    
    										
    									
    Parameters:
    {Object} f The index of the flag you want returned.
    gbox.getFont(id)
    Returns a font object containing data about the font.
    
    										
    									
    Parameters:
    {String} id The id of the font, as set in gbox.addFont.
    gbox.getFps() : Integer
    Get the frames per second rate (default is 25).
    
    										
    									
    Returns:
    {Integer} Returns the frames per second.
    gbox.getGroups() : Array
    Get an array containing the names of each group in the game, in order of rendering.
    grouplist = gbox.getGroups();
    grouplist; // => ["background", "player", "enemy", "game"]
    Returns:
    {Array} An array of group names.
    gbox.getImage(id) : Object
    Gets information about a loaded image.
    image = gbox.getImage('logo');
    image; // => ?
    Parameters:
    {String} id The id of the image.
    Returns:
    {Object} A DOM Image element, including the URL and last modified date of the image, its ID, and whether it was loaded successfully.
    gbox.getObject(group, id) : Object
    Given a group and an id for a particular object instance, this returns the instance requested. NOTE: this does not return a copy of the object you've requested! Any modifications you make to the object returned are directly modifying the object you requested.
    // Find the player and reduce health by half.
    playertemp = gbox.getObject('player','player_id');
    player.health = player.health/2;
    Parameters:
    {String} group The id of the group that contains the object.
    {String} id The id of the instance of the object.
    Returns:
    {Object} The object requested.
    gbox.getScreenH() : Integer
    Get the screen height.
    
    										
    									
    Returns:
    {Integer} Screen height in pixels.
    gbox.getScreenHH() : Integer
    Get the screen half-height.
    
    										
    									
    Returns:
    {Integer} Screen half-height in pixels.
    gbox.getScreenHW() : Integer
    Get the screen half-width.
    
    										
    									
    Returns:
    {Integer} Screen half-width in pixels.
    gbox.getScreenW() : Integer
    Get the screen width.
    
    										
    									
    Returns:
    {Integer} Screen width in pixels.
    gbox.getTiles(t)
    Gets an Akihabara tileset, adding it to the engine.
    
    										
    									
    Parameters:
    {String} t The ID of a tileset.
    Returns:
    An object containing:
    • id {String}: the new id of the tileset
    • image {String}: reference to the tileset image loaded
    • tileh {Integer}: height in pixels of the tiles
    • tilew {Integer}: width in pixels of the tiles
    • tilerow {Integer}: width in pixels of each row in the font image
    • gapx {Integer}: x-coord gap between tile columns, in pixels
    • gapy {Integer}: y-coord gap between tile rows, in pixels
    gbox.go()
    This function is called once per frame. This is where the basic rendering and processing of groups occurs.
    
    										
    									
    gbox.groupIsEmpty(gid) : Boolean
    Returns whether a given group contains no objets.
    
    										
    									
    Parameters:
    {String} gid The group you're checking.
    Returns:
    {Boolean} True if the group contains no objects.
    gbox.hitAudio(a, data)
    
    										
    									
    Parameters:
    a
    data
    gbox.imageIsLoaded(id) : Boolean
    Checks to see if an image was successfully loaded.
    
    										
    									
    Parameters:
    {String} id The id of the image.
    Returns:
    {Boolean} True if the image has been loaded.
    gbox.initScreen(w, h)
    Initializes the screen to a certain width and height, applies zoom attributes, populates the body of the HTML document including the canvas element, sets an initial camera, creates a '_buffer' canvas, sets keyboard event listeners, and many other initialization functions.
    
    										
    									
    Parameters:
    {Integer} w The width of the main canvas.
    {Integer} h The height of the main canvas.
    gbox.keyIsHit(id) : Boolean
    Returns true if a given key in this._keymap is pressed. Only returns true on the transition from unpressed to pressed.
    
    										
    									
    Parameters:
    {String} id A key in the keymap. By default, one of: "up" "down" "left" "right" "a" "b" "c"
    Returns:
    {Boolean} True if the given key is transitioning from unpressed to pressed in this frame.
    gbox.keyIsHold(id) : Boolean
    Returns true if a given key in this._keymap has been held down for at least one frame. Will not return true if a key is quickly tapped, only once it has been held down for a frame.
    
    										
    									
    Parameters:
    {String} id A key in the keymap. By default, one of: "up" "down" "left" "right" "a" "b" "c"
    Returns:
    {Boolean} True if the given key has been held down for at least one frame.
    gbox.keyIsPressed(id) : Boolean
    Returns true if a given key in this._keymap is being held down. Returns true as long as the key is held down.
    
    										
    									
    Parameters:
    {String} id A key in the keymap. By default, one of: "up" "down" "left" "right" "a" "b" "c"
    Returns:
    {Boolean} True if the given key is held down.
    gbox.keyIsReleased(id) : Boolean
    Returns true if a given key in this._keymap is released. Only returns true on the transition from pressed to unpressed.
    
    										
    									
    Parameters:
    {String} id A key in the keymap. By default, one of: "up" "down" "left" "right" "a" "b" "c"
    Returns:
    {Boolean} True if the given key is transitioning from pressed to unpressed in this frame.
    gbox.loadAll(cb)
    Loads the initial splash screen and debugging font, then calls gbox._waitforloaded which adds to the game all the previously defined resources. Once gbox._waitforloaded is done, it calls the callback function cb.
    
    										
    									
    Parameters:
    cb
    gbox.log()
    
    										
    									
    gbox.objectIsTrash(o) : Boolean
    Returns whether an object is due to be trashed. Useful in cases you want to check if an object is marked as trash before it is actually deleted.
    
    										
    									
    Parameters:
    {Object} o The object you're checking.
    Returns:
    {Boolean} True if the object is marked as trash.
    gbox.objectIsVisible(obj)
    Determines whether an object is visible by seeing if it collides with the camera's viewport.
    
    										
    									
    Parameters:
    {Object} obj The object you're testing to see if it's visible. Must contain:
    • x {Integer}: (required) the x coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • y {Integer}: (required) the y coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • w {Integer}: (required) the width of the object's collision box
    • h {Integer}: (required) the height the object's box
    Returns:
    True if the object's collision box is within the camera's viewport.
    gbox.pixelcollides(o1, o2, t)
    Calculates a point-box collision between a point and a collision box within a given tolerance. A higher tolerance means less precise collision.
    
    										
    									
    Parameters:
    {Object} o1 A point you're testing for collision. Must contain:
    • x {Integer}: (required) the x coordinate of the point
    • y {Integer}: (required) the y coordinate of the point
    {Object} o2 A collision box you're testing for collision. Must contain:
    • x {Integer}: (required) the x coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • y {Integer}: (required) the y coordinate of the object's origin; assumes the Akihabara default of top-left being the origin
    • w {Integer}: (required) the width of the box
    • h {Integer}: (required) the height the box
    {Integer} t The tolerance for the collision, in pixels. A value of 0 means pixel-perfect collision. A value of 2 would mean that the point could exist within the outermost 2 pixels of the box without being considered a collision.
    Returns:
    True if the point is colliding with the box within the given tolerance.
    gbox.playAllGroups()
    Enables all groups, toggling any groups that are currently disabled.
    
    										
    									
    gbox.playAudio(a, data)
    
    										
    									
    Parameters:
    a
    data
    gbox.playGroup(gid)
    If a group is disabled, this will enable the group.
    
    										
    									
    Parameters:
    {String} gid The id of the group.
    gbox.playGroups(gid)
    
    										
    									
    Parameters:
    gid
    gbox.purgeGarbage(obj)
    Clears the record held in gbox._garbage of what has been deleted.
    
    										
    									
    Parameters:
    {Object} obj The object you wish to delete.
    gbox.readBundleData(pack, call)
    
    										
    									
    Parameters:
    pack
    call
    gbox.resetChannel(ch)
    
    										
    									
    Parameters:
    ch
    gbox.setAudioChannels(a)
    
    										
    									
    Parameters:
    a
    gbox.setAudioCompatMode(m)
    
    										
    									
    Parameters:
    m
    gbox.setAudioCreateMode(m)
    
    										
    									
    Parameters:
    m
    gbox.setAudioDequeueTime(m)
    
    										
    									
    Parameters:
    m
    gbox.setAudioMute(a)
    
    										
    									
    Parameters:
    a
    gbox.setAudioPosition(a, p)
    
    										
    									
    Parameters:
    a
    p
    gbox.setAudioPositionDelay(m)
    
    										
    									
    Parameters:
    m
    gbox.setAudioTeam(a)
    
    										
    									
    Parameters:
    a
    gbox.setAudioUnmute(a)
    
    										
    									
    Parameters:
    a
    gbox.setAudioVolume(a, vol)
    
    										
    									
    Parameters:
    a
    vol
    gbox.setAutoskip(f)
    
    										
    									
    Parameters:
    f
    gbox.setCallback(cb)
    Deprecated: gbox._cb is now set by passing it directly into gbox.loadAll(). Left in for backwards compatibility.
    
    										
    									
    Parameters:
    {String} cb The name of the function to be called once gbox.loadAll is completed.
    gbox.setCameraX(x, viewdata)
    Sets the x value of the current camera object.
    
    										
    									
    Parameters:
    {Integer} x The camera object's new x value.
    {Object} viewdata An object containing parameters h and w, which are a bounding box that the camera is not supposed to leave. For example, to use your map as a bounding area for the camera, pass along {w: map.w, h: map.h}.
    gbox.setCameraY(y, viewdata)
    Sets the y value of the current camera object.
    
    										
    									
    Parameters:
    {Integer} y The camera object's new y value.
    {Object} viewdata An object containing parameters h and w, which are a bounding box that the camera is not supposed to leave. For example, to use your map as a bounding area for the camera, pass along {w: map.w, h: map.h}.
    gbox.setCanAudio(a)
    
    										
    									
    Parameters:
    a
    gbox.setCanLog(c)
    
    										
    									
    Parameters:
    c
    gbox.setChannelVolume(ch, a)
    
    										
    									
    Parameters:
    ch
    a
    gbox.setDoubleBuffering(db)
    Sets the gbox._db property. Turns on an off double buffering.
    
    										
    									
    Parameters:
    {Boolean} db The value to write to gbox._db. True enables double buffering, false disables.
    gbox.setForcedIdle(f)
    Sets the gbox._forcedidle property.
    
    										
    									
    Parameters:
    {Boolean} f The value to write to gbox._forcedidle.
    gbox.setFps(f)
    Set the frames per second rate.
    
    										
    									
    Parameters:
    {Integer} f Total frames per second for the game to run at.
    gbox.setFrameskip(f)
    
    										
    									
    Parameters:
    f
    gbox.setGroups(g)
    Defines the names of each group in the game along with their rendering order.
    
    										
    									
    Parameters:
    {Array} g An array of strings of group names, in the order in which the groups should be rendered. So g[0] will contain the first group to render, g[1] the second group to render, etc.
    gbox.setLowerAudioTeam(a)
    
    										
    									
    Parameters:
    a
    gbox.setRenderOrder(g)
    A method of setting the render order of groups independently of gbox.setGroups. Sets gbox._renderorder, which by default is equivalent to gbox._groups. However, gbox._renderorder is what ultimately determines the rendering order of groups. If you need to change your rendering order on the fly, use this function by passing it a reordered array of group names.
    
    										
    									
    Parameters:
    {Array} g An array of strings of group names, in the order in which the groups should be rendered. So g[0] will contain the first group to render, g[1] the second group to render, etc.
    gbox.setScreenBorder(a)
    
    										
    									
    Parameters:
    a
    gbox.setShowPlayers(m)
    
    										
    									
    Parameters:
    m
    gbox.setSplashSettings(a)
    
    										
    									
    Parameters:
    a
    gbox.setStatBar(txt)
    Writes text to the status bar, but only if the status bar is enabled.
    
    										
    									
    Parameters:
    {String} txt The text to write to the status bar.
    gbox.setStatusBar(f)
    Sets the gbox._statbar property. Only useful if called before gbox.initScreen. Debugging funtionality. Much easier to access if you add '?statusbar=1' to your URL.
    
    										
    									
    Parameters:
    {Boolean} f The value to write to gbox._statbar.
    gbox.setZindex(th, z)
    
    										
    									
    Parameters:
    th
    z
    gbox.setZoom(z)
    Sets the gbox._zoom parameter, only works before gbox.initScreen is called.
    
    										
    									
    Parameters:
    {Integer} z Zoom factor.
    gbox.soloGroup(gid)
    Turns off all groups except for the one specified.
    
    										
    									
    Parameters:
    {String} gid The id of the group.
    gbox.stopAudio(a, permissive)
    
    										
    									
    Parameters:
    a
    permissive
    gbox.stopChannel(ch)
    
    										
    									
    Parameters:
    ch
    gbox.stopGroup(gid)
    If a group is enabled, this will disable the group.
    
    										
    									
    Parameters:
    {String} gid The id of the group.
    gbox.stopGroups(gid)
    
    										
    									
    Parameters:
    gid
    gbox.toggleGroup(gid)
    Toggles a group between enabled and disabled status.
    
    										
    									
    Parameters:
    {String} gid The id of the group.
    gbox.toggleGroups(gid)
    
    										
    									
    Parameters:
    gid
    gbox.trashGroup(group)
    Deletes every object in a given group.
    
    										
    									
    Parameters:
    {String} group The group id.
    gbox.trashObject(obj)
    Deletes an object, keeping a record of its group and id in gbox._garbage.
    
    										
    									
    Parameters:
    {Object} obj The object you wish to delete.
    Documentation generated by JsDoc Toolkit 2.3.2 on Wed Aug 18 2010 15:59:17 GMT-0400 (EDT)