Module components_boxcollider

Axis-aligned box collider attached to a game object.

Info:

  • Author: Sharper Dev

Functions

BoxCollider:new (gameObject) Creates a collider with a default size of 10×10 and registers it with the collision system.
BoxCollider:setLayer (layer) Moves this collider to a collision-system layer.
BoxCollider:setMetaLayer (layer) Sets the meta collision layer used to filter collisions.
BoxCollider:insertIgnoreMetaLayer (metaLayer) Adds a meta collision layer to this collider's ignore list.
BoxCollider:removeIgnoreMetaLayer (metaLayer) Removes the first matching meta collision layer from the ignore list.
BoxCollider:render () Draws the collider outline when the debugger is enabled.
BoxCollider:destroy () Unregisters the collider and its render task.
BoxCollider:setSize (width, height) Sets the collider's width and height.
BoxCollider:setOffset (x, y) Sets the collider's offset from the game object's position.
BoxCollider:onCollisionEnter (collider) Collision-enter callback; override to react when a collision begins.
BoxCollider:onCollisionStay (collider) Collision-stay callback; override to react while a collision continues.
BoxCollider:onCollisionExit (collider) Collision-exit callback; override to react when a collision ends.
BoxCollider:onTouchDown () Touch-down callback; override to react when a touch begins on this collider.
BoxCollider:onTouchStay () Touch-stay callback; override to react while this collider remains touched.
BoxCollider:onTouchClick () Touch-click callback; override to react when this collider is clicked.
BoxCollider:onTouchUp () Touch-up callback; override to react when a touch on this collider ends.


Functions

BoxCollider:new (gameObject)
Creates a collider with a default size of 10×10 and registers it with the collision system.

Parameters:

  • gameObject table Game object that owns this collider.

Returns:

    table The new BoxCollider component.

Usage:

    local collider = gameObject:addComponent("BoxCollider")
BoxCollider:setLayer (layer)
Moves this collider to a collision-system layer.

Parameters:

  • layer number Collision layer to register under.

Usage:

    collider:setLayer(2)
BoxCollider:setMetaLayer (layer)
Sets the meta collision layer used to filter collisions.

Parameters:

  • layer number Meta collision layer.

Usage:

    collider:setMetaLayer(2)
BoxCollider:insertIgnoreMetaLayer (metaLayer)
Adds a meta collision layer to this collider's ignore list.

Parameters:

  • metaLayer number Meta collision layer to ignore.

Usage:

    collider:insertIgnoreMetaLayer(1)
BoxCollider:removeIgnoreMetaLayer (metaLayer)
Removes the first matching meta collision layer from the ignore list.

Parameters:

  • metaLayer number Meta collision layer to stop ignoring.

Usage:

    collider:removeIgnoreMetaLayer(1)
BoxCollider:render ()
Draws the collider outline when the debugger is enabled.
BoxCollider:destroy ()
Unregisters the collider and its render task.
BoxCollider:setSize (width, height)
Sets the collider's width and height.

Parameters:

  • width number Collider width.
  • height number Collider height.

Usage:

    collider:setSize(32, 24)
BoxCollider:setOffset (x, y)
Sets the collider's offset from the game object's position.

Parameters:

  • x number Horizontal offset.
  • y number Vertical offset.

Usage:

    collider:setOffset(4, 0)
BoxCollider:onCollisionEnter (collider)
Collision-enter callback; override to react when a collision begins.

Parameters:

  • collider table The other collider involved in the collision.

Usage:

    function collider:onCollisionEnter(other)
        -- Code here
    end
BoxCollider:onCollisionStay (collider)
Collision-stay callback; override to react while a collision continues.

Parameters:

  • collider table The other collider involved in the collision.

Usage:

    function collider:onCollisionStay(other)
        -- Code here
    end
BoxCollider:onCollisionExit (collider)
Collision-exit callback; override to react when a collision ends.

Parameters:

  • collider table The other collider involved in the collision.

Usage:

    function collider:onCollisionExit(other)
        -- Code here
    end
BoxCollider:onTouchDown ()
Touch-down callback; override to react when a touch begins on this collider.

Usage:

    function collider:onTouchDown()
        -- Code here
    end
BoxCollider:onTouchStay ()
Touch-stay callback; override to react while this collider remains touched.

Usage:

    function collider:onTouchStay()
        -- Code here
    end
BoxCollider:onTouchClick ()
Touch-click callback; override to react when this collider is clicked.

Usage:

    function collider:onTouchClick()
        -- Code here
    end
BoxCollider:onTouchUp ()
Touch-up callback; override to react when a touch on this collider ends.

Usage:

    function collider:onTouchUp()
        -- Code here
    end
generated by LDoc 1.5.0 Last updated 2026-10-04 12:53:32