Contents

Careening into Dusk

Here it is! The Careening into Dusk guide! The #1 most requested thing in Dusk is documentation, and, unfortunately, I can't answer that request as fast as I'd like to. Thus, here's an ultra-condensed, super-fast reference guide to Dusk.

I am purposefully leaving out core methods and properties (those that begin with an underscore), because they're just that - core methods and properties. They're not necessary for the average user to know. In addition to underscored names, I've also left out methods and properties that are less relevant. This guide is about having an accessible (if quick and dirty) reference to Dusk, not being absolutely complete.

Library Reference

dusk.buildMap(filename)

Documented

Builds a map object from a JSON- or Lua-encoded file exported from Tiled.

dusk.setPreference(name, value)

Documented

Sets a Dusk preference. See the preferences guide for more information.

dusk.getPreference(name)

Documented

Returns the current value of a Dusk preference.

dusk.setMathVariable(key, value)

Sets a math variable for the !math! property prefix.

dusk.getMathVariable(key, value)

Returns the current value of a math variable.

Map Reference

map.layer

Documented

A table that contains each layer in a map, stored under map.layer[index] and map.layer[name].

map.tilesToPixels(x, y)

Converts base tile coordinates to pixels.

Alias: map.tilesToLocalPixels(x, y)

map.tilesToContentPixels(x, y)

Converts base tile coordinates to content pixels.

map.pixelsToTiles(x, y)

Converts pixel coordinates to tiles.

map.isTileWithinMap(x, y)

Checks if a tile coordinate is within the range of (1, 1) to (map width, map height). Does not check if a tile exists.

map.tileLayers()

Documented

Iterator for each tile layer in a map.

map.objectLayers()

Documented

Iterator for each object layer in a map.

map.imageLayers()

Documented

Iterator for each image layer in a map.

map.destroy()

Documented

Destroys the map. Should be used in place of map:removeSelf().

map.updateView()

Updates a map's camera system and culling. Should be called each frame and directly after you manually move the map.

map.setViewpoint(x, y)

Moves the camera to (x, y)

map.getViewpoint()

Returns the current viewpoint of the camera.

map.positionCamera(x, y)

Moves the camera to (x, y), ignoring tracking level.

map.snapCamera()

Moves the camera to its current viewpoint, ignoring tracking level.

map.enableFocusTracking(t)

Turns focus tracking on or off, based on whether t is true or false.

map.setCameraFocus(obj)

Sets the camera to track an object.

map.setCameraBounds(b)

Sets the bounds the camera is clamped to, in the form of the fields xMin, xMax, yMin, and yMax within the table argument.

map.setTrackingLevel(t)

Sets the "fluidity" of the map's camera system. Values approaching 0 make for more slow and more fluid camera tracking, while values approaching 1 make for more rigid camera tracking

map.setDamping(d)

Sets the "fluidity" of the map's camera system inversely. Simply allows you to set tracking level as 1/t, which is more natural for many people.

map.getTrackingLevel()

Returns the current tracking level of the map.

map.getDamping()

Returns the current tracking level of the map, in the form of 1/t.

Tile Layer Reference

layer.tile(x, y)

Documented

Returns the tile at tile coordinate (x, y).

layer.lockTileDrawn(x, y)

Keeps the tile at tile coordinate (x, y) from being culled and draws it if need be.

layer.lockTileErased(x, y)

Keeps the tile at tile coordinate (x, y) from being drawn and erases it if need be.

layer.unlockTile(x, y)

Turns off any locks on the tile at tile coordinate (x, y).

layer.tilesToPixels(x, y)

Converts tile coordinates to pixels.

layer.pixelsToTiles(x, y)

Converts pixel coordinates to tiles.

layer.tileByPixels(x, y)

Returns the tile at local pixel location (x, y).

layer.tilesInRange(x, y, w, h)

Documented

Iterator for tiles in a range reaching from top-left (x, y) to (x + w, y + h).

layer.tilesInRect(x, y, hw, hh)

Documented

Iterator for tiles in a rectangle centered at (x, y) and extending (x - hw, y - hh) to (x + hw, y + hh).

Object Layer Reference

layer.object

Documented

A table containing each object in a layer, stored under layer.object[index] and layer.object[name].

layer.nameIs(n)

Documented

Iterator for objects whose name is n.

layer.nameMatches(n)

Documented

Iterator for objects whose name matches n with Lua patterns.

layer.typeIs(t)

Documented

Iterator for objects whose type is t.

layer.typeMatches(t)

Documented

Iterator for objects whose type matches t with Lua patterns.

layer.objTypeIs(t)

Documented

Iterator for objects whose object type is t.

layer.objects(n)

Documented

Iterator for all objects in a layer.