Class: World

rune.raycast.World(map, layeropt)

Owns world objects through the normal display container lifecycle. Add each world to one update hierarchy; several viewports may observe it. The caller owns the tilemap. Rays, movement and paths share isBlocked().

Constructor

new World(map, layeropt)

Creates a new World object.
Parameters:
Name Type Attributes Description
map rune.tilemap.Tilemap Caller-owned tilemap.
layer rune.tilemap.TilemapDataLayer <optional>
Wall layer; defaults to map.back.
Source:

Extends

Members

active :boolean

Whether the object should be automatically updated by its parent object. Inactive objects are still rendered. the default value is true.
Type:
  • boolean
Inherited From:
Default Value:
  • true
Source:

allowCollisions :number

Describes the type of collision to which the object responds.
Type:
  • number
Inherited From:
Default Value:
  • rune.physics.Space.ANY
Source:

alpha :number

Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible.
Type:
  • number
Inherited From:
Default Value:
  • 1.0
Source:

(readonly) application :rune.system.Application

Reference to the application's entry point class, ie. the main class of the application. Useful for accessing the application's subsystem.
Type:
Inherited From:
Source:

autoSize :boolean

Fits the buffer to direct child bounds and the local origin. Defaults to false. Includes hidden children, rotation, reflection and scale; rounds outwards to whole pixels. Empty containers become zero-sized. The container's own background and drawing commands do not contribute to the size. Recalculates on enable, child insertion/removal, update and before compositing. Disabling retains the last size and buffer origin for subsequent manual sizing.
Type:
  • boolean
Inherited From:
Default Value:
  • false
Source:

backgroundColor :DOMString

The color of the display object background. The default value is "" (0x00000000).
Type:
  • DOMString
Inherited From:
Source:

bottom :number

The sum of the y and height properties.
Type:
  • number
Inherited From:
Source:

bottomLeft :rune.geom.Rectangle

The location of the Rectangle object's bottom-left corner, determined by the values of the left and bottom properties.
Type:
Inherited From:
Source:

bottomRight :rune.geom.Rectangle

The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties.
Type:
Inherited From:
Source:

(readonly) cached :boolean

Whether or not a cached version of the object's graphic state exists. If there is no cache, the object must be rendered.
Type:
  • boolean
Inherited From:
Source:

(readonly) canvas :rune.display.Canvas

Used to draw and store the graphical representation (ie bitmap data) for display objects.
Type:
Inherited From:
Source:

ceilingEnabled :boolean

Whether to project a flat ceiling instead of the sky.
Type:
  • boolean
Source:

(readonly, nullable) ceilingTexture :HTMLImageElement

Ceiling image selected by the map.
Type:
  • HTMLImageElement
Source:

center :rune.geom.Point

The center point of the rectangle object.
Type:
Inherited From:
Source:

centerX :number

The x coordinate of the center of the object.
Type:
  • number
Inherited From:
Source:

centerY :number

The y coordinate of the center of the object.
Type:
  • number
Inherited From:
Source:

debug :boolean

Whether the display object should be in debug mode (true) or not (false).
Type:
  • boolean
Inherited From:
Source:

debugColor :string

Color used to visualize the entire display object's bounds in debug mode. Changing the color invalidates parent buffers containing the debug outline.
Type:
  • string
Inherited From:
Default Value:
  • rune.util.Palette.WHITE
Source:

(readonly) flicker :rune.display.Flicker

A subsystem for flicker effects. Use this reference to start and stop flicker effects on the current display object.
Type:
Inherited From:
Source:

flippedX :boolean

Whether the object is flipped on the x axis.
Type:
  • boolean
Inherited From:
Source:

flippedY :boolean

Whether the object is flipped on the y axis.
Type:
  • boolean
Inherited From:
Source:

(readonly, nullable) floorTexture :HTMLImageElement

Floor image selected by the map.
Type:
  • HTMLImageElement
Source:

(readonly) gamepads :rune.input.Gamepads

Reference to the application's subsystem for connected gamepad devices.
Type:
Inherited From:
Source:

(readonly) glitch :rune.display.Glitch

Optional glitch effect. Created on first access and managed by this object. Displacements are measured in local pixels before scale and rotation.
Type:
Inherited From:
Source:

(readonly) globalX :number

Returns the object's absolute x position, ie coordinates that are relative to the stage's coordinate system and not the object's parent. Useful when you want to know the position of an object regardless of its place in the display list.
Type:
  • number
Inherited From:
Source:

(readonly) globalY :number

Returns the object's absolute y position, ie coordinates that are relative to the stage's coordinate system and not the object's parent. Useful when you want to know the position of an object regardless of its place in the display list.
Type:
  • number
Inherited From:
Source:

(readonly) graphics :rune.display.Graphics

Reference to the object's drawing API. This reference can be used to draw raster graphics for the object.
Type:
Inherited From:
Source:

(readonly) group :number

Reference to possible display group. The reference is null if the object is not part of a group.
Type:
  • number
Inherited From:
Source:

height :number

Indicates the height of the object, in pixels.
Type:
  • number
Inherited From:
Source:

(readonly) hidden :boolean

Indicates whether the display object is rendered or not. A visible object may still be invisible due to other factors such as flicker effects.
Type:
  • boolean
Inherited From:
Source:

(readonly) hitbox :rune.display.Hitbox

Represents a boundary box used for collision detection. Use the object's set() method to specify position and size. By default, it is positioned at 0, 0 and has the same size as the interactive object.
Type:
Inherited From:
Source:

immovable :boolean

Whether the object may change position when it collides with another object.
Type:
  • boolean
Inherited From:
Source:

(readonly) keyboard :rune.input.Keyboard

Reference to the keyboard manager. Use this reference to read the state of any keyboard key.
Type:
Inherited From:
Source:

layer :rune.tilemap.TilemapDataLayer

Tilemap layer supplying wall values and collision flags.
Type:
Source:

left :number

The x coordinate of the top-left corner of the rectangle.
Type:
  • number
Inherited From:
Source:

map :rune.tilemap.Tilemap

Tilemap supplying wall graphics, geometry and map properties.
Type:
Source:

(readonly) numChildren :number

Returns the number of children of this object.
Type:
  • number
Inherited From:
Source:

(readonly) parent :rune.display.DisplayObjectContainer

Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify a relative path to display objects that are above the current display object in the display list hierarchy.
Type:
Inherited From:
Source:

pivotX :number

The local x coordinate of the object's pivot point.
Type:
  • number
Inherited From:
Source:

pivotY :number

The local y coordinate of the object's pivot point.
Type:
  • number
Inherited From:
Source:
The sum of the x and width properties.
Type:
  • number
Inherited From:
Source:

rotation :number

Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation.
Type:
  • number
Inherited From:
Source:

scaleX :number

Indicates the horizontal scale (percentage) of the object as applied from the registration point (0,0).
Type:
  • number
Inherited From:
Source:

scaleY :number

Indicates the vertical scale (percentage) of an object as applied from the registration point of the object (0,0).
Type:
  • number
Inherited From:
Source:

size :rune.geom.Point

The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
Type:
Inherited From:
Source:

(readonly, nullable) skyTexture :HTMLImageElement

Panorama image selected by the map.
Type:
  • HTMLImageElement
Source:

sort :function

Refers to a function object that forms the basis for sorting child objects. When set, all children are sorted for each tick (update). Note that automatic sorting can be problematic when you want to preserve a specific display list structure.
Type:
  • function
Inherited From:
Default Value:
  • null
Source:

(readonly) stage :rune.display.Stage

Returns the current stage. This reference returns null if the object is not part of the display list, ie has not been added with addChild.
Type:
Inherited From:
Source:

(readonly) states :rune.state.States

A finite-state machine. Use this reference to apply isolated behavioral states to the object.
Type:
Inherited From:
Source:

sticky :boolean

Used in collision handling. If an object is sticky, other objects placed on top of the object may follow its movement. This is useful when developing platform games as a player can, for example, ride on moving platforms or other objects.
Type:
  • boolean
Inherited From:
Default Value:
  • false
Source:

timeScale :number

Scale for how time is calculated within the DisplayObjectContainer object.
Type:
  • number
Inherited From:
Default Value:
  • 1.0
Source:

top :number

The y coordinate of the top-left corner of the rectangle.
Type:
  • number
Inherited From:
Source:

topLeft :rune.geom.Point

The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point.
Type:
Inherited From:
Source:

topRight :rune.geom.Point

The location of the Rectangle object's top-right corner, determined by the x and y coordinates of the point.
Type:
Inherited From:
Source:

(readonly) touched :number

Whether the object touched another object in the previous update. See touching for more information.
Type:
  • number
Inherited From:
Source:
See:

touching :number

Whether the object touches another object and in such cases in which directions. The value is represented by a bit field and thus several directions can be true at the same time.
Type:
  • number
Inherited From:
Source:
See:

unscaledHeight :number

The height of the display object regardless of scale.
Type:
  • number
Inherited From:
Source:

unscaledWidth :number

The width of the display object regardless of scale.
Type:
  • number
Inherited From:
Source:

(readonly) velocity :rune.physics.Velocity

The velocity of the object. This object is used to calculate the object's direction of travel, as well as its speed. Note that the object is only used when the movable property is set to true.
Type:
Inherited From:
Source:

visible :boolean

Whether or not the display object is visible.
Type:
  • boolean
Overrides:
Default Value:
  • true
Source:

width :number

Indicates the width of the object, in pixels.
Type:
  • number
Inherited From:
Source:

x :number

Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent DisplayObjectContainer.
Type:
  • number
Inherited From:
Source:

y :number

Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent DisplayObjectContainer.
Type:
  • number
Inherited From:
Source:

Methods

addChild(child) → {rune.display.DisplayObject}

Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front (top) of all other children in this DisplayObjectContainer instance. To add a child to a specific index position, use the addChildAt() method.
Parameters:
Name Type Description
child rune.display.DisplayObject The DisplayObject instance to add as a child of this DisplayObjectContainer instance.
Inherited From:
Source:
Throws:
  • Throws if the child is the same as the parent.
    Type
    Error
  • Throws if the child is not of type DisplayObject.
    Type
    TypeError
Returns:
The DisplayObject instance that you pass in the child parameter.
Type
rune.display.DisplayObject

addChildAt(child, index) → {rune.display.DisplayObject}

Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object.
Parameters:
Name Type Description
child rune.display.DisplayObject The DisplayObject instance to add as a child of this DisplayObjectContainer instance.
index number The index position to which the child is added. If you specify a currently occupied index position, the child object that exists at that position and all higher positions are moved up one position in the child list.
Overrides:
Source:
Throws:
  • Throws if the child is the same as the parent.
    Type
    Error
  • Throws if the index position does not exist in the child list.
    Type
    RangeError
  • Throws if the child is not of type DisplayObject.
    Type
    TypeError
Returns:
The DisplayObject instance that you pass in the child parameter.
Type
rune.display.DisplayObject

angleTo(target) → {number}

Returns the direction from this point to a target in radians, between -pi and pi. Zero points along positive x. With screen coordinates, positive angles turn toward positive y. Neither point is modified. Returns zero when both points have the same coordinates.
Parameters:
Name Type Description
target rune.geom.Point Target point.
Inherited From:
Source:
Returns:
Direction to the target in radians.
Type
number

applyImpulse(x, y) → {undefined}

Adds an impulse to the object's velocity without changing its position. Positive values push right and down; negative values push left and up. The velocity change is independent of mass. Drag, speed limits and collisions are handled by the normal movement update.
Parameters:
Name Type Description
x number Horizontal velocity change.
y number Vertical velocity change.
Inherited From:
Source:
Returns:
Type
undefined

bringChildToFront(child) → {rune.display.DisplayObject}

Moves a child DisplayObject to the top of this DisplayObjectContainer's child list.
Parameters:
Name Type Description
child rune.display.DisplayObject The child DisplayObject to move.
Inherited From:
Source:
Returns:
Type
rune.display.DisplayObject

canOccupy(actor, position) → {boolean}

Checks whether an actor fits at a position without moving it. Uses the actor's radius (default 0.2 tiles) and the same circle/cell collision as move(). Walls, closed or partly open doors, solid surfaces, map bounds and custom isBlocked() rules apply. Other actors, activity, visibility, elevation and visual size are ignored. Only the destination is tested; this does not check the route to that position.
Parameters:
Name Type Description
actor Object Actor supplying an optional collision radius in tiles.
position Object Destination point with x and y in tiles.
Source:
Throws:
If the actor is missing, position is invalid or radius is invalid.
Type
RangeError
Returns:
Whether the destination can accommodate the actor.
Type
boolean

cast(x, y, dx, dy, rangeopt, outputopt) → {Object}

Casts against blocking wall and door cells using grid traversal. Every documented field is overwritten when reusing the output object. Rays touching a blocked grid corner are stopped by either adjacent cell.
Parameters:
Name Type Attributes Default Description
x number Ray origin in tile units.
y number Ray origin in tile units.
dx number Ray direction x.
dy number Ray direction y.
range number <optional>
64 Maximum ray parameter; use a unit direction for tile distances.
output Object <optional>
Reusable hit result.
Source:
Throws:
Ray arguments must be finite.
Type
RangeError
Returns:
Type
Object

centerIn(bounds, horizontalopt, verticalopt) → {rune.display.DisplayObject}

Centers the rendered rectangle within bounds, once, without resizing it. Accounts for scale, pivot, rotation, reflection and container buffer offsets. Transparent pixels inside the rendered rectangle are included. Bounds must use the same coordinate system as this object's position, normally its parent's local coordinates. For a child centered inside its own parent, pass a rectangle at (0, 0) with the parent's local width and height. Passing a sibling uses that sibling's x, y, width and height without its rotation. Larger objects extend equally beyond opposite edges. Disabled axes retain their positions. Call again after changes that should affect the placement.
Parameters:
Name Type Attributes Default Description
bounds rune.geom.Rectangle Area in parent coordinates.
horizontal boolean <optional>
true Whether to center horizontally.
vertical boolean <optional>
true Whether to center vertically.
Inherited From:
Source:
Returns:
This object.
Type
rune.display.DisplayObject

contains(child) → {boolean}

Checks whether a display object exists in this container.
Parameters:
Name Type Description
child rune.display.DisplayObject Child object to check.
Inherited From:
Source:
Returns:
Type
boolean

containsPoint(point) → {boolean}

Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.
Parameters:
Name Type Description
point rune.geom.Point The point, as represented by its x and y coordinates.
Inherited From:
Source:
Returns:
A value of true if the Rectangle object contains the specified point; otherwise false.
Type
boolean

containsRectangle(rect) → {boolean}

Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
Parameters:
Name Type Description
rect rune.geom.Rectangle The Rectangle object being checked.
Inherited From:
Source:
Returns:
A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false.
Type
boolean

copyFrom(point) → {rune.geom.Point}

Copies the coordinates of the specified point to this point.
Parameters:
Name Type Description
point rune.geom.Point The point to copy coordinates from.
Inherited From:
Source:
Returns:
This point.
Type
rune.geom.Point

dispose() → {undefined}

Process that prepares the object for removal. All internal processes are stopped and allocated memory will be cleared by the garbage collector at the next sweep.
Overrides:
Source:
Returns:
Type
undefined

distance(point) → {number}

Returns the distance between the current and specified point.
Parameters:
Name Type Description
point rune.geom.Point The specified point.
Inherited From:
Source:
Returns:
Type
number

distanceSquared(point) → {number}

Returns the squared distance between the current and specified point without calculating a square root. Compare the result against a squared distance.
Parameters:
Name Type Description
point rune.geom.Point The specified point.
Inherited From:
Source:
Returns:
The squared distance between the points.
Type
number

fini() → {undefined}

Method that is called automatically when the object is removed from the current display list hierarchy, ie. then its parent becomes null. The method should never perform, or activate any deallocation process (use the DISPOSE method for that purpose). This method should never be called manually.
Inherited From:
Source:
Returns:
Type
undefined

forEachChild(callback, scope) → {undefined}

Calls a function for each child in the display object container.
Parameters:
Name Type Description
callback function Call function.
scope Object Scope of execution.
Inherited From:
Source:
Returns:
Type
undefined

getCenter(outputopt) → {rune.geom.Point}

Returns the exact geometric center of this rectangle without rounding. Supply an output point to reuse an existing object instead of creating one. Unlike the center property, fractional coordinates are preserved.
Parameters:
Name Type Attributes Description
output rune.geom.Point <optional>
The point to store the center coordinates in.
Inherited From:
Source:
Returns:
The point containing the center coordinates.
Type
rune.geom.Point

getChildAt(index) → {rune.display.DisplayObject}

Returns the child display object instance that exists at the specified index.
Parameters:
Name Type Description
index number The index position of the child object.
Inherited From:
Source:
Throws:
Throws if the index does not exist in the child list.
Type
RangeError
Returns:
The child display object at the specified index position.
Type
rune.display.DisplayObject

getChildIndex(child) → {number}

Returns the index position of a child DisplayObject instance.
Parameters:
Name Type Description
child rune.display.DisplayObject The DisplayObject instance to identify.
Inherited From:
Source:
Returns:
The index position of the child display object to identify.
Type
number

getChildren() → {Array.<rune.display.DisplayObject>}

Returns a list of all child objects. Note that this method is primarily intended for internal use.
Inherited From:
Source:
Returns:
Type
Array.<rune.display.DisplayObject>

getContentBounds(rectopt) → {rune.geom.Rectangle}

Returns the bounds of direct children's rendered rectangles in local pixels. Includes hidden children and accounts for their scale, pivot, rotation and reflection. The container's own transform, background and drawing commands are excluded. Descendants are represented by their direct parent's buffer. Does not resize the container or reposition children. Empty containers return a zero rectangle. Results are calculated on each call and are not shared.
Parameters:
Name Type Attributes Description
rect rune.geom.Rectangle <optional>
Rectangle to overwrite instead of allocating.
Inherited From:
Source:
Returns:
Content bounds, or the supplied rectangle.
Type
rune.geom.Rectangle

getDoorAt(column, row) → (nullable) {rune.raycast.Door}

Finds a door placed at the specified cell, regardless of its opening state.
Parameters:
Name Type Description
column number Cell column.
row number Cell row.
Source:
Returns:
Type
rune.raycast.Door

getFirstChild() → {rune.display.DisplayObject}

Returns the child display object instance at the back (bottom) of the child list.
Inherited From:
Source:
Throws:
Throws if the child list is empty.
Type
RangeError
Returns:
Type
rune.display.DisplayObject

getGlobalRect(rectopt) → {rune.geom.Rectangle}

Creates a Rectangle object that represents the display object with absolute coordinates, ie coordinates that are relative to the stage and not the parent of the display object. This is useful if, for example, you want to collision test two display objects that exist in different branches of the display list. Note that this method is based on the visual representation of the display object and not the size of its hitbox.
Parameters:
Name Type Attributes Description
rect rune.geom.Rectangle <optional>
Rectangle to overwrite, if none is specified, a new Rectangle object is created.
Inherited From:
Source:
Returns:
Type
rune.geom.Rectangle

getLastChild() → {rune.display.DisplayObject}

Returns the child display object instance at the front (top) of the child list.
Inherited From:
Source:
Throws:
Throws if the child list is empty.
Type
RangeError
Returns:
Type
rune.display.DisplayObject

getNearestObject(position, range, filteropt, scopeopt) → (nullable) {rune.display.DisplayObject}

Returns the nearest active direct child within range, or null when none match. Uses center positions in tiles and includes the range boundary. The position object itself is excluded. Equal distances retain the first child in order. Visibility, interaction flags, object radii, elevation and walls are ignored.
Parameters:
Name Type Attributes Description
position Object Query point or actor with x and y in tiles.
range number Maximum distance in tiles.
filter function <optional>
Eligibility callback receiving each object in range.
scope Object <optional>
Callback scope.
Source:
Throws:
If position or range is invalid.
Type
RangeError
Returns:
Original world object, not a copy.
Type
rune.display.DisplayObject

getObjectsInRadius(x, y, radius, filteropt, scopeopt, outputopt) → {Array.<rune.display.DisplayObject>}

Returns active direct children whose x/y positions lie within a tile radius. The boundary is included. Visibility, interaction flags, object size and walls do not affect the query. Results retain child order and contain original objects. Also accepts (position, radius, filter, scope, output), where position is a point or actor. Like the coordinate form, this includes the query actor itself; use a filter when it should be excluded.
Parameters:
Name Type Attributes Description
x number | Object Query center X, or point/actor in tiles.
y number Query center y in tiles.
radius number Non-negative radius in tiles.
filter function <optional>
Optional eligibility callback receiving each object in range.
scope Object <optional>
Callback scope.
output Array.<rune.display.DisplayObject> <optional>
Caller-owned array to clear and reuse.
Source:
Throws:
If coordinates or radius are non-finite, or radius is negative.
Type
RangeError
Returns:
Type
Array.<rune.display.DisplayObject>
Example
var nearby = world.getObjectsInRadius(player, 3, function(object) {
    return object !== player && object instanceof Enemy;
});

getOverlappingObjects(actor, filteropt, scopeopt, outputopt) → {Array.<rune.display.DisplayObject>}

Returns active direct children whose floor-plane circles touch the actor. The actor itself and doors are excluded. Uses overlaps() for contact rules. Results retain child order; the query never applies damage or separation. Filter, scope and reusable output work like getObjectsInRadius().
Parameters:
Name Type Attributes Description
actor Object Actor with x, y and radius in tile units.
filter function <optional>
Optional eligibility callback receiving each overlapping object.
scope Object <optional>
Callback scope.
output Array.<rune.display.DisplayObject> <optional>
Caller-owned array to clear and reuse.
Source:
Returns:
Type
Array.<rune.display.DisplayObject>

getPath(startX, startY, goalX, goalY, diagonalopt) → (nullable) {rune.util.Path}

Uses the tilemap layer search and returns cell centers in tile units. The query uses isBlocked() without changing the layer collision data.
Parameters:
Name Type Attributes Default Description
startX number Start x in tiles.
startY number Start y in tiles.
goalX number Goal x in tiles.
goalY number Goal y in tiles.
diagonal boolean <optional>
false Whether diagonal steps are allowed.
Source:
Returns:
Type
rune.util.Path

getPathBetweenPoints(start, goal, diagonalopt) → (nullable) {rune.util.Path}

Finds a path between actors or points without extracting their coordinates. Uses the same blocking rules and tile-unit cell centers as getPath().
Parameters:
Name Type Attributes Default Description
start Object Starting actor or point with x and y in tiles.
goal Object Target actor or point with x and y in tiles.
diagonal boolean <optional>
false Whether diagonal steps are allowed.
Source:
Returns:
Path, or null when no route is available.
Type
rune.util.Path

hasChild(child) → {boolean}

Checks whether a display object is a child of the DisplayObjectContainer instance.
Parameters:
Name Type Description
child rune.display.DisplayObject Child objects to check.
Inherited From:
Source:
Returns:
Type
boolean

hasLineOfSight(source, target, filteropt, scopeopt, fovopt) → {boolean}

Checks the map-plane segment between two actors or points. Walls, closed and partly open doors, out-of-map cells and custom isBlocked() rules obstruct it. An optional field of view checks facing before casting. Omitting it retains an unrestricted sight query. Elevation and visual transparency are ignored. An optional filter selects active direct-child Billboards that also obstruct sight, using the same circle/Surface intersection hook as trace(). Source and target are always excluded. Visibility and interactive flags do not affect blockers. Without a filter, Billboards never obstruct this query.
Parameters:
Name Type Attributes Description
source Object Observer or point with x and y in tiles.
target Object Target actor or point with x and y in tiles.
filter function | number <optional>
Object blocker callback, or field of view in radians.
scope Object <optional>
Callback scope when filter is a function.
fov number <optional>
Full cone width in radians, greater than zero and at most 2*PI. Uses source.angle (radians) when present, otherwise source.direction (x/y). A full circle or coincident points do not require a heading. Camera.fov is never applied implicitly; pass it explicitly to opt in.
Source:
Throws:
If positions, field of view or a required heading are invalid.
Type
RangeError
Returns:
Whether the complete segment, including endpoints, is clear.
Type
boolean

hitTest(obj, callbackopt, scopeopt) → {boolean}

Evaluates whether the object's hitbox overlaps or intersects with the parameter object's hitbox.
Parameters:
Name Type Attributes Description
obj rune.display.Stage | rune.display.InteractiveObject | rune.display.DisplayGroup | rune.display.TileGraphic | rune.tilemap.TilemapLayer | rune.geom.Point | Array The object to be evaluated.
callback function <optional>
Executed for each detected collision.
scope Object <optional>
Scope of execution for the callback method.
Inherited From:
Source:
Returns:
Type
boolean

hitTestAndSeparate(obj, callbackopt, scopeopt) → {boolean}

Evaluates and resolves collision between the object's hitbox and the given argument object.
Parameters:
Name Type Attributes Description
obj rune.display.Stage | rune.display.InteractiveObject | rune.display.DisplayGroup | rune.display.TileGraphic | rune.tilemap.TilemapLayer | Array The object to be evaluated.
callback function <optional>
Executed automatically in case of overlap.
scope Object <optional>
Scope within the callback method must be executed.
Inherited From:
Source:
Returns:
Type
boolean

hitTestAndSeparateChildrenOf(parent, callbackopt, scopeopt) → {boolean}

Evaluates and resolves collision between this object's hitbox and the hitbox of all children of the specified argument object. Note that this method does not include the actual argument object, only its children.
Parameters:
Name Type Attributes Description
parent rune.display.DisplayObjectContainer The container object to be evaluated.
callback function <optional>
Executed automatically in case of overlap.
scope Object <optional>
Scope within the callback method must be executed.
Inherited From:
Source:
Returns:
Type
boolean

hitTestAndSeparateContentOf(array, callbackopt, scopeopt) → {boolean}

Evaluates and resolves hitbox-based collision between the object and other objects in a list structure (array).
Parameters:
Name Type Attributes Description
array Array The array object to be evaluated.
callback function <optional>
Executed automatically in case of overlap.
scope Object <optional>
Scope within the callback method must be executed.
Inherited From:
Source:
Returns:
Type
boolean

hitTestAndSeparateGroup(group, callbackopt, scopeopt) → {boolean}

Evaluates whether this object's hitbox overlaps or intersects any hitbox of the members of the specified group object.
Parameters:
Name Type Attributes Default Description
group rune.display.DisplayGroup Group to evaluate.
callback function <optional>
null Executed in case of collision.
scope Object <optional>
this Scope of execution for callback method.
Inherited From:
Source:
Returns:
True if there was a collision, otherwise false.
Type
boolean

hitTestAndSeparateObject(obj, callbackopt, scopeopt) → {boolean}

Evaluates whether the object's bounding box overlaps a bounding box of another object and in the event of a collision, the objects are separated in order to resolve the collision.
Parameters:
Name Type Attributes Default Description
obj rune.display.InteractiveObject The interactive object to test against.
callback function <optional>
null Executed in case of collision.
scope Object <optional>
this Scope of execution for callback method.
Inherited From:
Source:
Returns:
True if there was a collision, otherwise false.
Type
boolean

hitTestAndSeparateTilemapLayer(layer, callbackopt, scopeopt) → {boolean}

Evaluates, and resolves, collision between this object's hitbox and any solid tile within the specified tilemap layer.
Parameters:
Name Type Attributes Default Description
layer rune.tilemap.TilemapLayer Layer to evaluate.
callback function <optional>
null Executed in case of collision.
scope Object <optional>
this Scope of execution for callback method.
Inherited From:
Source:
Returns:
True if there was a collision, otherwise false.
Type
boolean

hitTestChildrenOf(parent, callbackopt, scopeopt) → {boolean}

Evaluates the bounding box of the interactive object to see if it overlaps or intersects the bounding box of any of the container object's children. The method returns true if this happens to any of the children. The callback method is activated for each child that is overlapped.
Parameters:
Name Type Attributes Description
parent rune.display.DisplayObjectContainer Container object whose children are to be checked.
callback function <optional>
Executed for each detected collision.
scope Object <optional>
Scope of execution for the callback method.
Inherited From:
Source:
Throws:
If the specified argument is not of type DisplayObjectContainer.
Type
Error
Returns:
If any of the container object's children are overlapped by this object, true is returned, otherwise false.
Type
boolean

hitTestContentOf(array, callbackopt, scopeopt) → {boolean}

Evaluates whether the object's hitbox overlaps or intersects the hitbox of any other object in the specified list. The list can contain a mixture of data types, provided that each data type is supported by the hitTest method.
Parameters:
Name Type Attributes Description
array Array Container object whose children are to be checked.
callback function <optional>
Executed for each detected collision.
scope Object <optional>
Scope of execution for the callback method.
Inherited From:
Source:
Throws:
If the specified argument is not of type DisplayObjectContainer.
Type
Error
Returns:
If any of the container object's children are overlapped by this object, true is returned, otherwise false.
Type
boolean

hitTestGroup(group, callbackopt, scopeopt) → {boolean}

Evaluates whether the object's hitbox overlaps or intersects the hitbox of any member of a group. The evaluation is carried out against all members of the group. The method returns true if there was an overlap, false otherwise.
Parameters:
Name Type Attributes Description
group rune.display.DisplayGroup Group to evaluate.
callback function <optional>
Executed automatically in case of overlap.
scope Object <optional>
Scope within the callback method must be executed.
Inherited From:
Source:
Returns:
Type
boolean

hitTestObject(obj, callbackopt, scopeopt) → {boolean}

Evaluates the bounding box of the interactive object to see if it overlaps or intersects with the bounding box of the obj interactive object.
Parameters:
Name Type Attributes Description
obj rune.display.InteractiveObject The interactive object to test against.
callback function <optional>
Executed in case of collision.
scope Object <optional>
Scope of execution for callback method.
Inherited From:
Source:
Returns:
true if the bounding boxes of the interactive objects intersect; false if not.
Type
boolean

hitTestPoint(point, callbackopt, scopeopt) → {boolean}

Evaluates the bounding box of the interactive object to see if it overlaps or intersects with a point object.
Parameters:
Name Type Attributes Description
point rune.geom.Point The point object to test against.
callback function <optional>
Executed in case of collision.
scope Object <optional>
Scope of execution for callback method.
Inherited From:
Source:
Returns:
true if the display object overlaps or intersects with the specified point; false otherwise.
Type
boolean

hitTestTilemapLayer(layer, callbackopt, scopeopt) → {boolean}

Evaluates whether the object's hitbox overlaps or intersects a solid tile within a tilemap layer.
Parameters:
Name Type Attributes Description
layer rune.tilemap.TilemapLayer Layer to evaluate.
callback function <optional>
Executed automatically in case of overlap.
scope Object <optional>
Scope within the callback method must be executed.
Inherited From:
Source:
Returns:
Type
boolean

inflate(dx, dy) → {rune.geom.Rectangle}

Expands this rectangle by dx on both horizontal sides and dy on both vertical sides, preserving its geometric center. Negative values shrink the rectangle. Width and height are not clamped and may become negative if the rectangle is shrunk beyond its current size.
Parameters:
Name Type Description
dx number The amount to add to each horizontal side.
dy number The amount to add to each vertical side.
Inherited From:
Source:
Returns:
This rectangle.
Type
rune.geom.Rectangle

init() → {undefined}

Method that is called automatically when the display object is added to the display list hierarchy, ie. when the object becomes a child of a parent object. This method should never be called manually.
Inherited From:
Source:
Returns:
Type
undefined

interpolate(point, fractionopt, outputopt) → {rune.geom.Point}

Determines a point between two specified points. The parameter fraction determines where the new interpolated point is located relative to the two end points.
Parameters:
Name Type Attributes Description
point rune.geom.Point The second point.
fraction number <optional>
The level of interpolation between the two points.
output rune.geom.Point <optional>
Save results to this object.
Inherited From:
Source:
Returns:
The new, interpolated point.
Type
rune.geom.Point

intersection(toIntersect, outputopt) → {rune.geom.Rectangle}

If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
Parameters:
Name Type Attributes Description
toIntersect rune.geom.Rectangle The Rectangle object to compare against to see if it intersects with this Rectangle object.
output rune.geom.Rectangle <optional>
A Rectangle object to store the intersection results in.
Inherited From:
Source:
Returns:
A Rectangle object that equals the area of intersection.
Type
rune.geom.Rectangle

intersects(toIntersect) → {boolean}

Determines whether the specified rectangle overlaps this rectangle with positive area. Edge and corner contact and empty rectangles return false.
Parameters:
Name Type Description
toIntersect rune.geom.Rectangle The Rectangle object to compare against this Rectangle object.
Inherited From:
Source:
Returns:
A value of true if the specified object intersects with this Rectangle object; otherwise false.
Type
boolean

isBlocked(column, row) → {boolean}

Checks whether a cell blocks rays, movement and pathfinding. Any tile collision flags block the entire cell. Out-of-bounds cells block.
Parameters:
Name Type Description
column number Cell column.
row number Cell row.
Source:
Returns:
Type
boolean

isTouching(direction) → {boolean}

Test whether the object touches another object in one or more directions. The test does not tell what the object touches, only whether it does so (true) or not (false).
Parameters:
Name Type Description
direction number Bit field with directions to check.
Inherited From:
Source:
Returns:
Type
boolean

isWithinDistance(a, b, range) → {boolean}

Checks center-to-center distance on the map, including the range boundary. Ignores object radii, elevation, activity and walls. Points do not need to be world children, so caller-owned player cameras can be queried directly.
Parameters:
Name Type Description
a Object First actor or point with x and y in tiles.
b Object Second actor or point with x and y in tiles.
range number Maximum distance in tiles.
Source:
Throws:
If positions or range are invalid.
Type
RangeError
Returns:
Type
boolean

justTouched(direction) → {boolean}

Tests if the object touched other objects during the previous update.
Parameters:
Name Type Description
direction number Bit field with directions to check.
Inherited From:
Source:
Returns:
Type
boolean

move(object, dx, dy, radiusopt) → {Object}

Moves an object with circular wall/surface collision and axis sliding. Small displacement steps prevent tunneling through blocked cells.
Parameters:
Name Type Attributes Description
object Object Actor whose x and y coordinates are updated.
dx number Horizontal displacement in tiles.
dy number Vertical displacement in tiles.
radius number <optional>
Collision radius; defaults to object.radius, otherwise 0.2.
Source:
Throws:
Position, displacement and radius must be finite.
Type
RangeError
Returns:
The moved actor.
Type
Object

moveTo(x, y) → {undefined}

Moves an object to the specified position (x and y coordinates). This method can be used when an object needs to be moved without physical limitations.
Parameters:
Name Type Description
x number X coordinate to move to.
y number Y coordinate to move to.
Inherited From:
Source:
Returns:
Type
undefined

moveTowards(actor, destination, distance, radiusopt) → {boolean}

Moves an actor toward a point by at most distance tiles, without overshooting. Uses normal wall and door collision and the actor's radius. This method does not find a path; use Navigator to travel around obstacles.
Parameters:
Name Type Attributes Description
actor Object Actor whose x and y coordinates are updated.
destination Object Point or actor with x and y in tile units.
distance number Maximum travel distance in tiles.
radius number <optional>
Optional collision radius override.
Overrides:
Source:
Throws:
If positions or distance are invalid.
Type
RangeError
Returns:
Whether the actor changed position.
Type
boolean

overlaps(a, b) → {boolean}

Checks floor-plane circle contact without moving or separating the objects. Objects need finite x/y positions and non-negative finite radii in tile units. Self-contact, inactive objects, invalid circles and doors return false. Visibility, interactive flags, elevation and walls do not affect the test. Objects do not need to belong to this world; caller-owned players also work.
Parameters:
Name Type Description
a Object First actor with x, y and radius.
b Object Second actor with x, y and radius.
Source:
Returns:
Type
boolean

overlapsCell(actor, column, row) → {boolean}

Checks an actor's circular footprint against a unit cell, including contact with its edges or corners. Uses x, y and radius in tile units without moving the actor. Activity, visibility, elevation, cell contents and map bounds are ignored, making the query suitable for door occupancy and trigger cells.
Parameters:
Name Type Description
actor Object Actor or point with finite x/y and non-negative radius.
column number Integer cell column.
row number Integer cell row.
Source:
Returns:
False for invalid actor geometry or cell coordinates.
Type
boolean

pick(x, y, dx, dy, rangeopt) → (nullable) {rune.raycast.Billboard|rune.raycast.Door}

Picks a visible interactive billboard or doorway, respecting wall occlusion.
Parameters:
Name Type Attributes Default Description
x number Ray origin in tile units.
y number Ray origin in tile units.
dx number Ray direction x.
dy number Ray direction y.
range number <optional>
64 Maximum ray parameter; use a unit direction for tile distances.
Source:
Returns:
Type
rune.raycast.Billboard | rune.raycast.Door

postUpdate(step) → {undefined}

This method is activated immediately after the object's main update loop is completed. The method performs certain processes that sum up the current update, but also has the purpose of protecting these processes from being deactivated when the update method is overridden.
Parameters:
Name Type Description
step number Fixed time step.
Inherited From:
Source:
Returns:
Type
undefined

preUpdate(step) → {undefined}

This method is activated before the object's main update loop and ensures that the object is ready for the update. The purpose is to protect certain processes from being disabled when overriding the main update loop. This method can also be overridden, but it should be done with caution.
Parameters:
Name Type Description
step number Fixed time step.
Inherited From:
Source:
Returns:
Type
undefined

removeChild(child, disposeopt) → {rune.display.DisplayObject}

Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. The parent property of the removed child is set to null , and the object is garbage collected if no other references to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1.
Parameters:
Name Type Attributes Default Description
child rune.display.DisplayObject The DisplayObject instance to remove.
dispose boolean <optional>
false If the child object is to be destroyed when it is removed.
Inherited From:
Source:
Returns:
Type
rune.display.DisplayObject

removeChildAt(index, disposeopt) → {rune.display.DisplayObject}

Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer.
Parameters:
Name Type Attributes Default Description
index number The child index of the DisplayObject to remove.
dispose boolean <optional>
false If the child object is to be destroyed when it is removed.
Inherited From:
Source:
Returns:
Type
rune.display.DisplayObject

removeChildren(disposeopt) → {undefined}

Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent property of the removed children is set to null.
Parameters:
Name Type Attributes Default Description
dispose boolean <optional>
false Whether the children's dispose process should be activated when they are removed.
Inherited From:
Source:
Returns:
Type
undefined

removeFromParent(disposeopt) → {rune.display.DisplayObject}

Removes this object from its current parent display object container.
Parameters:
Name Type Attributes Default Description
dispose boolean <optional>
false Whether this object should be destroyed when it is removed.
Inherited From:
Source:
Returns:
Type
rune.display.DisplayObject

sendChildToBack(child) → {rune.display.DisplayObject}

Moves a child DisplayObject to the bottom of this DisplayObjectContainer's child list.
Parameters:
Name Type Description
child rune.display.DisplayObject The child DisplayObject to move.
Inherited From:
Source:
Returns:
Type
rune.display.DisplayObject

set(x, y) → {rune.geom.Point}

Sets the horizontal and vertical coordinates of this point.
Parameters:
Name Type Description
x number The horizontal coordinate.
y number The vertical coordinate.
Inherited From:
Source:
Returns:
This point.
Type
rune.geom.Point

setChildIndex(child, index) → {boolean}

Changes the position of an existing child in the display object container. This affects the layering of child objects.
Parameters:
Name Type Description
child rune.display.DisplayObject The child DisplayObject instance for which you want to change the index number.
index number The resulting index number for the child display object.
Inherited From:
Source:
Throws:
  • Throws if the index does not exist in the child list.
    Type
    RangeError
  • Throws if the child parameter is not a child of this object.
    Type
    Error
Returns:
Type
boolean

sortChildren(func) → {undefined}

Sorts the instance's child objects based on the specified function. Invalidates the pixel cache only when the child order changes.
Parameters:
Name Type Description
func function Sort function
Inherited From:
Source:
Throws:
if the specified argument is not of type Function.
Type
TypeError
Returns:
Type
undefined

swapChildren(a, b) → {boolean}

Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the display object container remain in the same index positions.
Parameters:
Name Type Description
a rune.display.DisplayObject The first child object.
b rune.display.DisplayObject The second child object.
Inherited From:
Source:
Returns:
Type
boolean

toString() → {string}

Returns a string representation of the hitbox. Useful for troubleshooting.
Inherited From:
Source:
Returns:
Type
string

trace(x, y, dx, dy, rangeopt, outputopt, filteropt, scopeopt) → {Object}

Returns the nearest blocking cell or active billboard hit. Cells win distance ties. Billboards use floor-plane radii; Surfaces use their fixed plane segments. Both are independent of visual size along Y, elevation and image transparency.
Parameters:
Name Type Attributes Default Description
x number Ray origin in tile units.
y number Ray origin in tile units.
dx number Ray direction x.
dy number Ray direction y.
range number <optional>
64 Maximum ray parameter; use a unit direction for tile distances.
output Object <optional>
Reusable hit result.
filter function <optional>
Object eligibility callback.
scope Object <optional>
Callback scope.
Source:
Returns:
Type
Object

union(rect, outputopt) → {rune.geom.Rectangle}

Returns the smallest rectangle that contains this rectangle and the specified rectangle, including any space between them. The original rectangles remain unchanged unless one is supplied as output. Zero-sized rectangles contribute their coordinates to the bounds.
Parameters:
Name Type Attributes Description
rect rune.geom.Rectangle The rectangle to combine with this rectangle.
output rune.geom.Rectangle <optional>
Store results in this object. May be either input rectangle.
Inherited From:
Source:
Returns:
The rectangle enclosing both rectangles.
Type
rune.geom.Rectangle

update(step) → {undefined}

Override this method to update your interactive object's position and appearance.
Parameters:
Name Type Description
step number Fixed time step.
Inherited From:
Source:
Returns:
Type
undefined