Libraries.Interface.Views.LabelBoxView Documentation

Inherits from: Libraries.Interface.Item, Libraries.Interface.Item2D, Libraries.Language.Object, Libraries.Interface.Views.View2D, Libraries.Interface.Views.ControlView

Variables Table

VariablesDescription
integer BOTTOM
integer TOP
integer ALLBitmask representing which sides of the box have borders.
integer RIGHT
integer NONE
integer LEFT

Actions Documentation

Add(integer index, Libraries.Interface.Item2D newItem)

This action adds a different Item2D into this one, storing the added Item2D at a specific index in the internal array.

Parameters

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
parentItem:Add(0, child)

Add(Libraries.Interface.Item2D newItem)

This action adds a different Item2D into this one. This makes a few things happen. 1. The added item will get this item as its parent. 2. The added item's x and y coordinates will become relative to this Item. 3. Most actions on this Item will also affect the added Item.

Parameters

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
parentItem:Add(child)

AddBehavior(Libraries.Interface.Behaviors.Behavior behavior)

This action adds a new Behavior to this Item.

Parameters

AddFocusListener(Libraries.Interface.Events.FocusListener listener)

This action adds a FocusListener to the Item. When the Item receives a FocusEvent due to either gaining or losing the focus, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.FocusListener
Item myItem
FocusListener listener
myItem:AddFocusListener(listener)

AddGestureListener(Libraries.Interface.Events.GestureListener listener)

This action adds a GestureListener to the Item. If the Item ever receives a GestureEvent, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.GestureListener
Item myItem
GestureListener listener
myItem:AddGestureListener(listener)

AddMouseListener(Libraries.Interface.Events.MouseListener listener)

This action adds a MouseListener to the Item. If the Item ever receives a MouseEvent due to a mouse click, the mouse listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseListener
Item myItem
MouseListener listener
myItem:AddMouseListener(listener)

AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action adds a MouseMovementListener to the Item. If the Item ever receives a MouseEvent due to mouse movement, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseMovementListener
Item myItem
MouseMovementListener listener
myItem:AddMouseMovementListener(listener)

AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action adds a MouseWheelListener to the Item. If the Item ever receives a MouseEvent due to the mouse wheel being scrolled, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseWheelListener
Item myItem
MouseWheelListener listener
myItem:AddMouseWheelListener(listener)

AddTouchListener(Libraries.Interface.Events.TouchListener listener)

This action adds a TouchListener to the Item. If the Item ever receives a TouchEvent, the listener will be notified.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.TouchListener
Item myItem
TouchListener listener
myItem:AddTouchListener(listener)

Advance(number time)

This action is used to advance the item forward in time in physics space to synchronize it for time of impact solving. This action is used internally and users should not need to use this action. Attribute Parameter time The amount of seconds to advance the item forward in time

Parameters

  • number time

ApplyAngularImpulse(number impulse)

This action applies an angular impulse to this item. The units are in kilogram units squared per second. This modifies the angular velocity of this item. Physics must be enabled on this item before using this action.

Parameters

  • number impulse: The angular impulse in kilogram units squared per second

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:ApplyAngularImpulse(80)

ApplyForce(Libraries.Compute.Vector2 force, Libraries.Compute.Vector2 point)

This action applies a force to this item at the passed point. The force is in kilogram units per second per second. The point is the screen coordinates where the point will be applied. If the point is not on the center of the item, then a torque will be introduced causing the item to rotate. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Compute.Vector2
use Libraries.Interface.Item2D

Item2D item
Vector2 force
Vector2 point

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

force:Set(300, 350)
point:Set(100, 100)    // apply the force to the top right corner of the item

item:ApplyForce(force, point)

ApplyForceToCenter(Libraries.Compute.Vector2 force)

This action applies a force to this item at the center of the item. The force is in kilogram units per second per second. No torque is introduced to the item when using this action. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Compute.Vector2
use Libraries.Interface.Item2D

Item2D item
Vector2 force

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

force:Set(300, 350)

item:ApplyForce(force)

ApplyLinearImpulse(Libraries.Compute.Vector2 impulse, Libraries.Compute.Vector2 point)

This action applies a linear impulse to this item at the passed point. The impulse is in kilogram units per second. This immeadietly modifies the linear velocity of this item. The point is the screen coordinates where the impulse will be applied. If the point is not the center of the item, then the angular velocity of this item will also be modified. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 impulse
Vector2 point

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

impulse:Set(100)
point:Set(100, 100)     // apply the impulse to the top right corner

item:ApplyLinearImpulse(impulse, point)

ApplyTorque(number torque)

This action applies a torque to this item. The units are kilogram units squared per second per second. Physics must be enabled on this item before using this action.

Parameters

  • number torque: The torque to apply to this item in kilogram units squared per second per second

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:ApplyTorque(350)

AreChildrenProcessingMouseEvents()

This action returns whether or not this Item is allowing its children to receive mouse events if the Item is custom drawing. If the Item isn't using custom drawing, this value is irrelevant -- children objects always receive mouse events before the parent if the parent isn't performing custom drawing.

Return

boolean:

BeginCollision(Libraries.Interface.Item item)

This action is used to indicate that two items have just begun colliding. When two Items collide, the BeginCollision action should be called on both of them, with the other item passed as a parameter to the action. Note that this action does nothing by default, but classes that inherit from Item may override it.

Parameters

Example

use Libraries.Interface.Item

Item collider1
Item collider2
collider1:BeginCollision(collider2)
collider2:BeginCollision(collider1)

BeginMouseOver()

CanRotate(boolean flag)

This action gets the position of the center of this item in global (world) coordinates.

Parameters

  • boolean flag

CancelBehaviors()

This action stops all behaviors this Item is following without finishing them.

ClickedMouse()

CollideWithChildren()

This action sets the mass, mass moment of inertia, and how the 2D item should move (via linear velocity) to be at the desired location.

Return

boolean:

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

ComputeDistance(Libraries.Compute.Vector2 point, integer childIndex, Libraries.Compute.Vector2 normalOut)

This action computes the distance of the passed point from the collision shape attached to this item. This action is used internally and users should not need to use this action.

Parameters

  • Libraries.Compute.Vector2: The vector representing the point to compute the distance from
  • integer childIndex: The index of the collision shape attached to this item we want the bounding box of
  • Libraries.Compute.Vector2: The direction of the point from the shape

Return

number: The distance of the point from the collision shape of this item

Contains(number containsX, number containsY)

This action tests if a point in global x,y coordinates is contained inside this Item2D. The global coordinates are considered to be the x and y coordinates of this Item plus its offsetX and offsetY values.

Parameters

  • number containsX
  • number containsY

Return

boolean: Whether or not the point is contained in this Item.

Example

use Libraries.Interface.Item2D

Item2D item
item:SetPosition(50, 50)
item:SetWidth(100)
item:SetHeight(50)
boolean value = item:Contains(125, 70)

CreateNodes(Libraries.Game.Collision.BroadphaseCollision2D broadphase, Libraries.Game.Collision.PhysicsPosition2D transform)

This action creates the nodes for this item for the broadphase collision. This action is needed in order to add the item to the collision detection system. This action is used internally and users should not need to use this action.

Parameters

DestroyNodes(Libraries.Game.Collision.BroadphaseCollision2D broadphase)

This action destroys the nodes for this item for the broadphase collision, essentially removing it from the collision detection system. This action is used internally and users should not need to use this action.

Parameters

Dispose()

This action is used to free up any additional memory that is being used by this Item for purposes such as graphics. Note that the Item class doesn't have any extra memory that needs to be released with this action, but some classes which inherit from Item, such as Libraries.Game.Graphics.Drawable, do.

DisposeAll()

This action is used to call Dispose on this Item and on the entire children hierarchy of this Item.

DisposeChildren()

This action is used to call Dispose on the entire children hierarchy of this Item. This will not call Dispose on this Item.

Draw(Libraries.Game.Graphics.Painter2D painter)

The Draw action is used to perform custom drawing on this Item and its children. This is only called during the Game engine's draw phase if this Item has enabled custom drawing via the SetCustomDrawing action. This is an advanced feature, and shouldn't be used by most users. If custom drawing is enabled, this action should be overriden -- if it isn't, the Item will attempt to provide default rendering for itself, its view, and its children, without regard to depth buffering. This action is responsible for instructing the provided Painter on how to draw this item, the view, and its children, and in what order to do so.

Parameters

Empty()

This action will remove all items from this item's children hierarchy. Note that this will not empty the hierarchies of the contained Items.

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child1
Item2D child2
Item2D grandchild
parentItem:Add(child1)
parentItem:Add(child2)
child1:Add(grandChild)
parentItem:Empty()

EmptyAll()

This action will call Empty on the entire children hierarchy of this item, and then empty this item as well.

EmptyChildren()

This action is used to call Empty on all children contained in this item's children hierarchy. This will not empty the children of this item.

EnablePhysics(boolean flag)

This action enables physics for this item. Passing true turns on physics for this item while passing false turns off physics for this item.

Parameters

  • boolean flag: Whether or not to enable physics for this item

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:EnablePhysics(true)

EndMouseOver()

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

FastMoving(boolean flag)

This action gets the linear velocity of this item in units per second. Physics must be enabled on this item before using this action.

Parameters

  • boolean flag

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 velocity

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
velocity:Set(100, 0)
item:SetLinearVelocity(velocity)

Vector2 currentVelocity = item:GetLinearVelocity()

FinishCollision(Libraries.Interface.Item item)

This action is used to indicate that two items that were previously colliding no longer are. The FinishCollision action should be called on both Items involved, with the other item passed as a parameter to the action. Note that this action does nothing by default, but classes that inherit from Item may override it.

Parameters

Example

use Libraries.Interface.Item

Item collider1
Item collider2
collider1:FinishCollision(collider2)
collider2:FinishCollision(collider1)

FlipX()

This action will flip the Item2D across the X-axis. This flip is represented by the internal vertices of the Item2D. For classes that inherit from Item and can draw on the screen, this will flip the drawn image on the screen.

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:FlipX()

FlipY()

This action will flip the Item2D across the Y-axis. This flip is represented by the internal vertices of the Item2D. For classes that inherit from Item and can draw on the screen, this will flip the drawn image on the screen.

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:FlipY()

Focus()

This action sets focus on this Item. If the Item is not focusable, it will instead look through the parent hierarchy and set focus on the first focusable ancestor. If no focusable Item can be found, this action will have no effect.

GainedFocus()

GainedFocus(Libraries.Interface.Events.FocusEvent event)

This action is fired if the item received the focus.

Parameters

GainedSelection()

GetAccessibilityCode()

This action returns the current accessiblity code for this Item

Return

integer:

GetAccessibilityRoleDescription()

This action returns the custom accessibility role description for this item, if any.

Return

text:

GetAccessibilityType()

This action returns the name of the accessiblity code for this Item as Text

Return

text:

GetAccessibleParent()

This action returns the parent of this Item2D. An Item2D gets a parent when it is added to another Item using the Add action.

Return

Libraries.Interface.Item:

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
parentItem:Add(child)
Item2D item = child:GetParent()

GetAngularDamping()

This action gets the inverse inertia of this item (i.e., one divided by the inertia of this item). Physics must be enabled on this item before using this action.

Return

number: The inverse inertia of this item

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number inverseInertia = item:GetInverseInertia()

GetAngularVelocity()

This action gets this item's angular velocity in radians per second. Physics must be enabled in this item before using this action.

Return

number: The angular velocity of this item in radians per second

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetAngularVelocity(0.1)
number angularVelocity = item:GetAngularVelocity()

GetBackgroundColor()

GetBorderStyle()

Return

integer

GetBorderThickness()

Return

integer

GetBoundingBox(integer childIndex)

This action is used to get the bounding box of the item. A bounding box is an axis-alligned rectangle containing the shape used for broadphase collision. This action is used internally and users should not need to use this action.

Parameters

  • integer childIndex: The index of the collision shape attached to this item we want the bounding box of

Return

Libraries.Game.Collision.BoundingBox2D: The bounding box of the collision shape attached to this item

GetBoundingRectangle()

This action returns a rectangle that fully encloses the four corners of the Item as it is represented by its internal vertices array. Note that the rectangle produced by this action will be larger than the actual box formed by this Item's vertices if the Item is rotated.

Return

Libraries.Game.Shapes.Rectangle:

Example

use Libraries.Interface.Item2D
use Libraries.Game.Shapes.Rectangle

Item2D myItem
myItem:SetBoundingBox(20, 80, 100, 100)
Rectangle box = myItem:GetBoundingRectangle()

GetCenterX()

This action returns the x coordinate of the center of this Item2D.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetWidth(20)
myItem:SetX(100)
number x = myItem:GetCenterX()

GetCenterY()

This action returns the y coordinate of the center of this Item2D.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetHeight(20)
myItem:SetY(100)
number y = myItem:GetCenterY()

GetChildren()

This action gets the children of this item in an array.

Return

Libraries.Containers.Array: The children of this item in an array

Example

use Libraries.Interface.Item2D

Item2D parent
Item2D child1
Item2D child2

parent:Add(child1)
parent:Add(child2)

Array<Item2D> children = parent:GetChildren()

GetClipCoordinates(Libraries.Compute.Vector2 xCoords, Libraries.Compute.Vector2 yCoords)

This action gets the clipping coordinates of this Item2D. The coordinates are returned via the two provided Vector2 parameters, the first vector storing the x values of the left and right sides of the clipping coordinates and the second vector storing the y values of the bottom and top sides. The returned boolean value indicates if this Item uses these clipping coordinates (i.e. if this Item or one of its parent Items has clipping enabled). If the clipping is valid, the action returns true. Otherwise, it returns false.

Parameters

Return

boolean:

GetCollisionGroupFlag()

This action gets the total force on this item. The units are kilogram units per second per second. Physics must be enabled on this item before using this action.

Return

boolean: The total force in kilogram units per second per second

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 force

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
force:Set(300, 350)
item:SetForce(force)
Vector2 totalForce = item:GetForce()

GetCollisionGroupIndex()

This action gets this item's angular velocity in radians per second. Physics must be enabled in this item before using this action.

Return

integer: The angular velocity of this item in radians per second

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetAngularVelocity(0.1)
number angularVelocity = item:GetAngularVelocity()

GetCollisionList()

This is an action used internally to retrieve the head of the linked list of collisions with this item. This action is used internally and users should not need to use this action.

Return

Libraries.Game.Collision.CollisionEdge2D: The head of the doubly linked list of collisions

GetDensity()

This action applies a linear impulse to this item at the passed point. The impulse is in kilogram units per second. This immeadietly modifies the linear velocity of this item. The point is the screen coordinates where the impulse will be applied. If the point is not the center of the item, then the angular velocity of this item will also be modified. Physics must be enabled on this item before using this action.

Return

number:

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 impulse
Vector2 point

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

impulse:Set(100)
point:Set(100, 100)     // apply the impulse to the top right corner

item:ApplyLinearImpulse(impulse, point)

GetDescription()

This action returns the current internal description of the Item.

Return

text:

Example

use Libraries.Interface.Item

Item item
item:SetDescription("Used for demo purposes.")
output "My item's description is : " + item:GetDescription()

GetDrawableShape()

This action returns the DrawableShape attached to this Item, if it has one. For a default Item2D, this action will return undefined, but Drawables will have an associated shape if they've been loaded. Attributes: Returns The DrawableShape attached to this Item, or undefined if there isn't one.

Return

Libraries.Game.Graphics.DrawableShape:

GetFocusListeners()

This action returns an Iterator containing all of the FocusListeners that have been added to this Item using the AddFocusListener action.

Return

Libraries.Containers.Iterator: An iterator containing all of the registered FocusListeners.

GetForce()

This action gets the total force on this item. The units are kilogram units per second per second. Physics must be enabled on this item before using this action.

Return

Libraries.Compute.Vector2: The total force in kilogram units per second per second

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 force

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
force:Set(300, 350)
item:SetForce(force)
Vector2 totalForce = item:GetForce()

GetFriction()

This action applies a force to this item at the center of the item. The force is in kilogram units per second per second. No torque is introduced to the item when using this action. Physics must be enabled on this item before using this action.

Return

number:

Example

use Libraries.Compute.Vector2
use Libraries.Interface.Item2D

Item2D item
Vector2 force

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

force:Set(300, 350)

item:ApplyForce(force)

GetGestureListeners()

This action returns an Iterator containing all of the GestureListeners that have been added to this Item using the AddGestureListener action.

Return

Libraries.Containers.Iterator: An iterator containing all of the registered GestureListeners.

GetGlobalX()

This action returns the Item's global x coordinate. This is the actual world coordinate that the item exists at after it has been offset by its parent's position. If this Item doesn't have a parent, and the offset hasn't been set manually, this is the same as GetX().

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetX(100)
myItem:SetX(30)
number globalX = myItem:GetGlobalX()

GetGlobalY()

This action returns the Item's global y coordinate. This is the actual world coordinate that the item exists at after it has been offset by its parent's position. If this Item doesn't have a parent, and the offset hasn't been set manually, this is the same as GetY().

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetY(60)
myItem:SetX(90)
number globalY = myItem:GetGlobalY()

GetGlobalZ()

This action returns the Item's global z value. For an Item2D, this simply returns the Item2D's current z value.

Return

number:

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetHeight()

This action will return the currently set height of the Item2D.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
number height = myItem:GetHeight()

GetInertia()

This action gets the rotational inertia of this item. The inertia is in kilogram units squared.

Return

number: The inertia of this item in kilogram units squared

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number inertia = item:GetInertia()

GetInputGroup()

This action returns the input group for this Item. When used with the Game libraries, this tag describes what InputTable (if any) can interact with this Item due to input.

Return

text: The input group tag being used by this Item.

Example

use Libraries.Interface.Item

Item item
item:SetInputGroup("arrowKeys")
output "My item's input group is : " + item:GetInputGroup()

GetInputTable()

GetInverseInertia()

This action gets the inverse inertia of this item (i.e., one divided by the inertia of this item). Physics must be enabled on this item before using this action.

Return

number: The inverse inertia of this item

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number inverseInertia = item:GetInverseInertia()

GetInverseMass()

This action gets the inverse mass of the item (i.e., one divided by the mass of this item). Physics must be enabled on this item before using this action.

Return

number: The inverse mass of this item

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number inverseMass = item:GetInverseMass()

GetItem(integer index)

This action returns an Item2D that was previously added to this Item2D by finding it at the given index in the internal array of children Items.

Parameters

  • integer index

Return

Libraries.Interface.Item2D:

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child1
Item2D child2
parentItem:Add(child1)
parentItem:Add(child2)
Item temp = parentItem:GetItem(0)

GetItemAt(number x, number y)

This action searches through all Items stored in this Item2D and finds the deepest Item which contains the given point in global coordinates.

Parameters

  • number x
  • number y

Return

Libraries.Interface.Item2D: The deepest item in the children hierarchy at the given point.

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
Item2D grandchild
parentItem:Add(child)
child:Add(grandchild)
grandchild:SetHeight(100)
grandchild:SetWidth(100)
Item2D temp = parentItem:GetItemAt(75, 75)

GetItemCount()

This action returns the number of items contained in this Item2D.

Return

integer:

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child1
Item2D child2
parentItem:Add(child1)
parentItem:Add(child2)
integer size = parentItem:GetItemCount()

GetItems()

This action returns an iterator containing all the items contained in this Item2D.

Return

Libraries.Containers.Iterator:

Example

use Libraries.Interface.Item2D
use Libraries.Containers.Iterator

Item2D parentItem
Item2D child1
Item2D child2
parentItem:Add(child1)
parentItem:Add(child2)
Iterator<Item2D> iterator = parentItem:GetItems()

GetJointList()

This is an action used internally to retrieve the head of the liked list of joints connected to this item. This action is used internally and users should not need to use this action.

Return

Libraries.Game.Physics.Joints.JointEdge2D: The head of the linked list of connected joints

GetLayer()

This action returns the current Layer2Dthat this Item2D is a part of in the Game libraries.

Return

Libraries.Game.Layer2D:

GetLinearDamping()

Given the local coordinates of a vector, this action computes the screen coordinates of the corresponding vector.

Return

number: The coordinates of the corresponding global vector Attribute Example use Libraries.Interface.Item2D use Libraries.Compute.Vector2 Item2D item Vector2 localVector item:SetWidth(100) item:SetHeight(100) item:SetPosition(400, 250) localVector:Set(0, 0) // Get the coordinates of the center of the item Vector2 worldVector = item:GetWorldVector(localVector)

GetLinearVelocity()

This action gets the linear velocity of this item in units per second. Physics must be enabled on this item before using this action.

Return

Libraries.Compute.Vector2: The vector representing the linear velocity of this item in units per second

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 velocity

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
velocity:Set(100, 0)
item:SetLinearVelocity(velocity)

Vector2 currentVelocity = item:GetLinearVelocity()

GetLinearVelocityFromLocalPoint(Libraries.Compute.Vector2 localPoint)

Given a global point (i.e., the screen coordinates of the point), this action computes the corresponding point relative to the center of this item.

Parameters

Return

Libraries.Compute.Vector2: The coordinates of the point relative to the center of this item

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 worldPoint

item:SetWidth(100)
item:SetHeight(100)
item:SetPosition(400, 350)

worldPoint:Set(400, 350)    // the lower left corner of the item

Vector2 localPoint = item:GetLocalPoint(worldPoint)

GetLinearVelocityFromWorldPoint(Libraries.Compute.Vector2 worldPoint)

Given the screen coordinates of a vector, this action computes the local coordinates of the vector (i.e., the coordinates of the vector relative to the center of this item)

Parameters

Return

Libraries.Compute.Vector2: The local coordinates of the corresponding vector

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 worldVector

item:SetWidth(100)
item:SetHeight(100)
item:SetPosition(400, 350)

worldVector:Set(400, 350)    // the lower left corner of the item

Vector2 localVector = item:GetLocalVector(worldVector)

GetLocalCenter()

This action gets the position of the center of this item in local coordinates (i.e., with respect to itself).

Return

Libraries.Compute.Vector2: The vector representing the center of this item in local coordinates

GetLocalPoint(Libraries.Compute.Vector2 worldPoint)

Given a global point (i.e., the screen coordinates of the point), this action computes the corresponding point relative to the center of this item.

Parameters

Return

Libraries.Compute.Vector2: The coordinates of the point relative to the center of this item

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 worldPoint

item:SetWidth(100)
item:SetHeight(100)
item:SetPosition(400, 350)

worldPoint:Set(400, 350)    // the lower left corner of the item

Vector2 localPoint = item:GetLocalPoint(worldPoint)

GetLocalVector(Libraries.Compute.Vector2 worldVector)

Given the screen coordinates of a vector, this action computes the local coordinates of the vector (i.e., the coordinates of the vector relative to the center of this item)

Parameters

Return

Libraries.Compute.Vector2: The local coordinates of the corresponding vector

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 worldVector

item:SetWidth(100)
item:SetHeight(100)
item:SetPosition(400, 350)

worldVector:Set(400, 350)    // the lower left corner of the item

Vector2 localVector = item:GetLocalVector(worldVector)

GetMass()

This action returns the mass of the item in kilograms. Physics must be enabled on this item before using this action. If the item is non-responsive or unmovable, the mass is zero.

Return

number: The mass in kilograms

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number mass = item:GetMass()

GetMass(Libraries.Game.Physics.Mass2D mass)

This action is used to advance the item forward in time in physics space to synchronize it for time of impact solving. This action is used internally and users should not need to use this action. Attribute Parameter time The amount of seconds to advance the item forward in time

Parameters

GetMouseListeners()

This action returns an Iterator containing all of the MouseListeners that have been added to this Item using the AddMouseListener action.

Return

Libraries.Containers.Iterator: An iterator containing all of the registered MouseListeners.

GetMouseMovementListeners()

This action returns an Iterator containing all of the MouseMovementListeners that have been added to this Item using the AddMouseMovementListener action.

Return

Libraries.Containers.Iterator: An iterator containing all of the registered MouseMovementListeners.

GetMouseWheelListeners()

This action returns an Iterator containing all of the MouseWheelListeners that have been added to this Item using the AddMouseWheelListener action.

Return

Libraries.Containers.Iterator: An iterator containing all of the registered MouseWheelListeners.

GetName()

This action returns the current internal name of the Item.

Return

text:

Example

use Libraries.Interface.Item

Item item
item:SetName("My Item")
output "My item's name is " + item:GetName()

GetNextFocus()

This action returns the next focus item. When this Item has the focus and the user requests the focus to advance (e.g. by pressing the tab key), the returned value is the next item to receive that focus, if it is defined. If it isn't defined, the focus can not advance from this Item.

Return

Libraries.Interface.Item: The next Item to receive focus after this one.

GetNodeCount()

This action gets the number of broadphase nodes this item has. This action is used internally and users should not need to use this action.

Return

integer: The number of broadphase nodes attached to this item

GetNodes()

This action returns all of the broadphase nodes attached to this item in an array. This action is used internally and users should not need to use this action.

Return

Libraries.Containers.Array: The broadphase nodes attached to this item in an array

GetOffsetX()

This action returns the X offset of the Item. The offset tells the Item where to relate its X position to. In other words, the X offset is where an X coordinate of 0 is for this Item. This is automatically set when using an action to add an Item to another Item.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetX(100)
number offset = myItem:GetOffsetX()

GetOffsetY()

This action returns the Y offset of the item. The offset tells the Item where to relate its Y position to. In other words, the Y offset is where a Y coordinate of 0 is for this item. This is automatically set when using an action to add an Item to another Item.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetY(75)
number offset = myItem:GetOffsetY()

GetOffsetZ()

This action returns the Z offset of the item. The offset tells the Item where to relate its Z position to. In other words, the Z offset is where a Z coordinate of 0 is for this item. This is automatically set when using an action to add an Item to another Item.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetZ(75)
number offset = myItem:GetOffsetZ()

GetOriginX()

This action will return the current X origin of this Item2D. By default, the origin is at the coordinates 0, 0.

Return

number:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetOriginCenter()
number xOrigin = myItem:GetOriginX()

GetOriginY()

This action will return the current Y origin of this Item2D. By default, the origin is at the coordinates 0, 0.

Return

number:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetOriginCenter()
number yOrigin = myItem:GetOriginY()

GetParent()

This action returns the parent of this Item2D. An Item2D gets a parent when it is added to another Item using the Add action.

Return

Libraries.Interface.Item2D:

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
parentItem:Add(child)
Item2D item = child:GetParent()

GetPhysicsProperties()

This action computes the distance of the passed point from the collision shape attached to this item. This action is used internally and users should not need to use this action.

Return

Libraries.Game.Physics.PhysicsProperties2D: The distance of the point from the collision shape of this item

GetPreviousFocus()

This action returns the previous focus item. When this Item has the focus and the user requests the focus to move backwards (e.g. by pressing shift & tab), the returned value is the previous item to receive that focus, if it is defined. If it isn't defined, the focus can not move backwards from this Item.

Return

Libraries.Interface.Item: The previous Item to receive focus before this one.

GetPropertiesSize()

Return

integer

GetProperty(text key)

GetPropertyKeyIterator()

GetRawInertia()

This action is used to update this items position in physics space after physics solving is finished for this item. This action is used internally and users should not need to use this action.

Return

number:

GetResponsiveness()

This action gets the inverse mass of the item (i.e., one divided by the mass of this item). Physics must be enabled on this item before using this action.

Return

integer: The inverse mass of this item

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number inverseMass = item:GetInverseMass()

GetRestitution()

This action gets the total torque on this item. The units are kilogram units squared per second per second. Physics must be enabled on this item before using this action.

Return

number: The total torque in kilogram units squared per second per second

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetTorque(200)
number totalTorque = item:GetTorque()

GetRotation()

Gets the current degree of rotation of this Item.

Return

number:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetRotation(90)
number rotation = myItem:GetRotation()

GetRotationInRadians()

Gets the current rotation of this Item in radians.

Return

number:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetRotation(90)
number rotation = myItem:GetRotationInRadians()

GetScaleX()

This action will return the current x-scaling value of this Item2D. By default, the x-scaling value of an Item is 1.

Return

number:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:Scale(1.25)
number scaleX = myItem:GetScaleX()

GetScaleY()

This action will return the current y-scaling value of this Item2D. By default, the y-scaling value of an Item is 1.

Return

number:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:Scale(1.25)
number scaleY = myItem:GetScaleY()

GetScreenX()

This action returns the x coordinate of the Item on the screen. If the Item hasn't been attached to a Layer, this will return a "Not a Number" value instead.

Return

number:

GetScreenY()

This action returns the y coordinate of the Item on the screen. If the Item hasn't been attached to a Layer, this will return a "Not a Number" value instead.

Return

number:

GetShape()

This item returns the collision shape of this item. The collision shape is the shape the collision system will use to test for collisions with this item. Note that this may be different from the shape drawn on the screen.

Return

Libraries.Game.Collision.Shapes.CollisionShape2D: The collision shape for this item

Example

use Libraries.Game.Drawable
use Libraries.Game.Collision.Shapes.Circle

Drawable ball
ball:Load("ball.png")
Circle circle
circle:SetRadius(30)
ball:SetShape(circle)
CollisionShape2D shape = ball:GetShape()

GetShapeType()

This action returns an integer representing the type of collision shape currently attached to this item.

Return

integer: The integer representing the type of collision shape for this item

GetSleepTime()

This action gets the children of this item in an array.

Return

number: The children of this item in an array

Example

use Libraries.Interface.Item2D

Item2D parent
Item2D child1
Item2D child2

parent:Add(child1)
parent:Add(child2)

Array<Item2D> children = parent:GetChildren()

GetSweep()

This action returns the swept movement of this item used for time of impact solving for the physics system. This action is used internally and users should not need to call this action.

Return

Libraries.Game.Collision.Sweep2D: The swept motion of this item

GetText()

Return

text

GetTorque()

This action gets the total torque on this item. The units are kilogram units squared per second per second. Physics must be enabled on this item before using this action.

Return

number: The total torque in kilogram units squared per second per second

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetTorque(200)
number totalTorque = item:GetTorque()

GetTouchListeners()

This action returns an Iterator containing all of the TouchListeners that have been added to this Item using the AddTouchListener action.

Return

Libraries.Containers.Iterator: An iterator containing all of the registered TouchListeners.

GetTransform()

This action returns the position of the item in physical space. This acction is used internally and should not be used by users to get the position of this item on the screen.

Return

Libraries.Game.Collision.PhysicsPosition2D: The position and angle of this item in physics space

GetTransform0()

This action gets the position of the item in physics space from the previous frame. This action is used internally and users should not need to use this action

Return

Libraries.Game.Collision.PhysicsPosition2D: The position and angle of the item in physics space in the previous frame

GetView2D()

The SetClipping action is used to enable or disable clipping. If it is enabled, when the Item and its children are drawn as part of the QueueForDrawing action, any pixels that would be drawn outside of the unrotated dimensions of the Item are not rendered. In other words, the Item will only draw inside the exact rectangle formed by its x, y position and its width and height.

Return

Libraries.Interface.Views.View2D:

GetVisibleItemAt(number x, number y)

This action searches through all Items stored in this Item2D and finds the deepest Item which contains the given point in global coordinates. This action will only return items which are visible (that is, IsShowing() returns true).

Parameters

  • number x
  • number y

Return

Libraries.Interface.Item2D: The deepest visible item in the children hierarchy at the given point.

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child
Item2D grandchild
parentItem:Add(child)
child:Add(grandchild)
grandchild:SetHeight(100)
grandchild:SetWidth(100)
Item2D temp = parentItem:GetVisibleItemAt(75, 75)

GetWidth()

This action will return the currently set width of the Item2D.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
number width = myItem:GetWidth()

GetWorldCenter()

This action gets the position of the center of this item in global (world) coordinates.

Return

Libraries.Compute.Vector2: The vector representing the center of this item in global coordinates

GetWorldPoint(Libraries.Compute.Vector2 localPoint)

Given a point relative to the center of this item, this action computes and returns that point in screen coordinates.

Parameters

Return

Libraries.Compute.Vector2: The screen coordinates of the passed local point

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 localPoint

item:SetWidth(100)
item:SetHeight(100)
item:SetPosition(400, 250)

localPoint:Set(0, 0)    // Get the coordinates of the center of the item

Vector2 worldPoint = item:GetWorldPoint(localPoint)

GetWorldVector(Libraries.Compute.Vector2 localVector)

Given the local coordinates of a vector, this action computes the screen coordinates of the corresponding vector.

Parameters

Return

Libraries.Compute.Vector2: The coordinates of the corresponding global vector Attribute Example use Libraries.Interface.Item2D use Libraries.Compute.Vector2 Item2D item Vector2 localVector item:SetWidth(100) item:SetHeight(100) item:SetPosition(400, 250) localVector:Set(0, 0) // Get the coordinates of the center of the item Vector2 worldVector = item:GetWorldVector(localVector)

GetX()

This action returns the currently set X coordinate of the Item.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
number value = myItem:GetX()

GetY()

This action returns the currently set Y coordinate of the Item.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
number value = myItem:GetY()

GetZ()

This action returns the currently set Z value of this Item2D.

Return

number:

Example

use Libraries.Interface.Item2D
Item2D myItem
number value = myItem:GetZ()

HasBottomBorder()

Return

boolean

HasLeftBorder()

Return

boolean

HasMoved()

This action returns an integer representing the type of collision shape currently attached to this item.

Return

boolean: The integer representing the type of collision shape for this item

HasProperties()

Return

boolean

HasProperty(text key)

Parameters

  • text key

Return

boolean

HasRightBorder()

Return

boolean

HasTopBorder()

Return

boolean

Hide()

This action is used to indicate that an Item and all Items that were added to it should not be visible on the screen. Note that the Item class on its own cannot be drawn on the screen, but classes that inherit from it such as Libraries.Game.Graphics.Drawable can be. By default, Items are considered visible.

Example

use Libraries.Interface.Item

Item item
item:Hide()

Initialize(Libraries.Game.Graphics.ColorGroup backgroundColor, Libraries.Game.Graphics.ColorGroup borderColor)

Initialize(Libraries.Game.Graphics.ColorGroup backgroundColor, Libraries.Game.Graphics.ColorGroup borderColor, text labelText)

IsAcceptingMouseInput()

This action returns whether or not this Item accepts mouse input. If the value is true, this will intercept incoming mouse events, triggering any related MouseListeners and InputSets and preventing the mouse event from propagating to other Items on the Layer. The default value is true.

Return

boolean: True if this Item can receive mouse events, or false otherwise.

IsAccessibleParent()

This action returns the nearest parent object that is accessible. This can be anything that the programmer wants to be accessible, from user interface components in a 2D interface to 3D components relative in 3-space on screen. By default, items have no accessible parent and are self-contained, but user interface components normally override the behavior so that controls can be logically nested within each other. attribute: returns Item

Return

boolean:

IsApplyingEffectsOnClick()

Return

boolean

IsClipping()

The IsClipping action returns true if pixel clipping is enabled, or false if it is disabled. If it is enabled, when the Item and its children are drawn as part of the QueueForDrawing action, any pixels that would be drawn outside of the unrotated dimensions of the Item are not rendered. In other words, the Item will only draw inside the exact rectangle formed by its x, y position and its width and height.

Return

boolean: Whether or not pixel clipping is enabled for this Item.

IsCollidable()

This action determines whether this item is collidable.

Return

boolean: True if this item is collidable, false otherwise

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:SetCollidable(true)
boolean result = circle:IsCollidable

IsCustomDrawing()

The IsCustomDrawing action returns whether or not this Item is directly managing how itself and its children are drawn. When this value is true, the Item is responsible for determining its rendering via the Draw(Painter2D) action -- if this action isn't overridden, the Item and its children won't be drawn. This is an advanced feature only necessary for complex custom components, and most users will not need to use this functionality.

Return

boolean: Whether or not this Item is currently using custom drawing rules.

IsEmpty()

This action returns whether or not any items are contained in this Item.

Return

boolean:

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child1
parentItem:Add(child1)
boolean wasEmpty = parentItem:IsEmpty()

IsFastMoving()

This action sets this item's angular velocity in radians per second. Physics must be enabled in this item before using this action.

Return

boolean:

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetAngularVelocity(0.1)

IsFlippedX()

This action will return if the Item2D is currently flipped across the x-axis.

Return

boolean:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:FlipX()
boolean flip = myItem:IsFlippedX()

IsFlippedY()

This action will return if the Item2D is currently flipped across the y-axis.

Return

boolean:

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:FlipY()
boolean flip = myItem:IsFlippedY()

IsFocusable()

This action returns whether or not the Item can currently receive focus. This property can be set with SetFocusable().

Return

boolean:

IsFocused()

The IsFocused action determines if this Item is currently focused, returning true if it is, or false if it is not.

Return

boolean:

IsNonResponsive()

This action gets the number of broadphase nodes this item has. This action is used internally and users should not need to use this action.

Return

boolean: The number of broadphase nodes attached to this item

IsOnLayer()

This action returns true if the item has been added to a Layer, or false otherwise.

Return

boolean: True if the item is on a Layer, or false otherwise.

IsPhysicsEnabled()

This action determines whether physics is currently enabled for this item.

Return

boolean: True if physics is enabled for this item, false otherwise

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:EnablePhysics(true)
boolean result = circle:IsPhysicsEnabled()

IsResponsive()

This action sets this item to be collidable. Passing true turns on collision for this item while passing false turns off collision for this item.

Return

boolean:

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:SetCollidable(true)

IsRotationAllowed()

This action determines whether physics is currently enabled for this item.

Return

boolean: True if physics is enabled for this item, false otherwise

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:EnablePhysics(true)
boolean result = circle:IsPhysicsEnabled()

IsShowing()

This action returns whether the Item is currently set to be visible on the screen.

Return

boolean: A boolean representing whether or not the Item is currently visible.

Example

use Libraries.Interface.Item

Item item
item:Hide()
boolean visible = item:IsShowing()

IsSimulated()

This action gets the position of the center of this item in local coordinates (i.e., with respect to itself).

Return

boolean: The vector representing the center of this item in local coordinates

IsSimulationRequired()

This action sets the x-component of this item's linear velocity in units per second. Physics must be enabled on this item before using this action.

Return

boolean:

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetLinearVelocityX(100)

IsUnmovable()

This action creates the nodes for this item for the broadphase collision. This action is needed in order to add the item to the collision detection system. This action is used internally and users should not need to use this action.

Return

boolean:

LostFocus()

LostFocus(Libraries.Interface.Events.FocusEvent event)

This action is fired if the item lost the focus.

Parameters

LostSelection()

Move(Libraries.Compute.Vector2 movement)

This action will increase the x and y coordinates of this Item by the values stored in the provided Vector2.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D myItem
myItem:SetX(50)
myItem:SetY(80)
Vector2 vector
vector:Set(25, -20)
myItem:Move(vector)

Move(number xAmount, number yAmount)

This action will increase the x and y coordinates of this Item by the given amounts.

Parameters

  • number xAmount
  • number yAmount

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetX(50)
myItem:SetY(80)
myItem:Move(25, -20)

MoveX(number xAmount)

This action will increase the x-coordinate of this Item by the given amount.

Parameters

  • number xAmount

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetX(50)
myItem:MoveX(25)

MoveY(number yAmount)

This action will increase the y-coordinate of this Item by the given amount.

Parameters

  • number yAmount

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetY(50)
myItem:MoveY(25)

MoveZ(number zAmount)

This action will increase the z-coordinate of this Item by the given amount.

Parameters

  • number zAmount

Example

use Libraries.Interface.Item@D

Item2D myItem
myItem:SetZ(5)
myItem:MoveZ(2)

PrepareVertices()

Checks to see if the Item2D's internal vertices are up to date, and updates them if they are not. This is used primarily internally to ensure that the item's vertices are properly aligned before use, e.g. to project an image on the screen at the coordinates of the vertices. Most users will never need to use this action directly.

ProcessGestureEvent(Libraries.Interface.Events.GestureEvent event)

This action takes a gesture event and handles it. It will first test to see if the gesture event took place within the bounds of this Item. If so, it will notify any GestureListeners of the event. If the event was not contained within this Item, or if there are no GestureListeners on this Item, the Item will ask its parent Item to process the event, if there is a parent.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Interface.Events.GestureEvent
use Libraries.Interface.Events.GestureListener
Item2D myItem
GestureListener listener
myItem:AddGestureListener(listener)
GestureEvent event
event:eventType = event:DOUBLE_TAP
myItem:ProcessGestureEvent(event)

ProcessMouseEvent(Libraries.Interface.Events.MouseEvent event)

This action takes a mouse event and handles it. It will first test to see if the mouse event took place within the bounds of this Item. If so, it will notify any MouseListeners of the event. If the event was not contained within this Item, or if there are no MouseListeners on this Item, the Item will ask its parent Item to process the mouse event, if there is a parent.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Interface.Events.MouseEvent
use Libraries.Interface.Events.MouseListener
Item2D myItem
MouseListener listener
myItem:AddMouseListener(listener)
MouseEvent event
event:eventType = event:CLICKED_MOUSE
myItem:ProcessMouseEvent(event)

ProcessTouchEvent(Libraries.Interface.Events.TouchEvent event)

This action takes a touch event and handles it. It will first test to see if the touch event took place within the bounds of this Item. If so, it will notify any TouchListeners of the event. If the event was not contained within this Item, or if there are no TouchListeners on this Item, the Item will ask its parent Item to process the touch event, if there is a parent.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Interface.Events.TouchEvent
use Libraries.Interface.Events.TouchListener
Item2D myItem
TouchListener listener
myItem:AddTouchListener(listener)
TouchEvent event
event:eventType = event:BEGAN
myItem:ProcessTouchEvent(event)

QueueForDrawing(Libraries.Game.Graphics.Painter2D painter)

ReleasedMouse()

Remove(integer index)

This action removes an Item that was previously added to this Item by finding it at the given index in the internal array of children Items.

Parameters

  • integer index

Return

Libraries.Interface.Item2D: The Item that was removed.

Example

use Libraries.Interface.Item

Item parentItem
Item child1
Item child2
parentItem:Add(child1)
parentItem:Add(child2)
parentItem:Remove(0)

Remove(Libraries.Interface.Item2D removed)

This action removes an Item2D that was previously added to this Item2D.

Parameters

Return

boolean: Whether or not the Item was found and removed.

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child1
Item2D child2
parentItem:Add(child1)
parentItem:Add(child2)
parentItem:Remove(child1)

RemoveFocusListener(Libraries.Interface.Events.FocusListener listener)

This action removes a FocusListener from the Item. The listener will no longer receive notification if the Item gets a FocusEvent.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.FocusListener
Item myItem
FocusListener listener
myItem:AddFocusListener(listener)
myItem:RemoveFocusListener(listener)

RemoveGestureListener(Libraries.Interface.Events.GestureListener listener)

This action removes a GestureListener from the Item. The listener will no longer receive notification if the Item gets a GestureEvent.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.GestureListener
Item myItem
GestureListener listener
myItem:AddGestureListener(listener)
myItem:RemoveGestureListener(listener)

RemoveMouseListener(Libraries.Interface.Events.MouseListener listener)

This action removes a MouseListener from the Item. The listener will no longer receive notification if the Item gets a mouse click event.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseListener
Item myItem
MouseListener listener
myItem:AddMouseListener(listener)
myItem:RemoveMouseListener(listener)

RemoveMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action removes a MouseMovementListener from the Item. The listener will no longer receive notification if the Item gets a mouse movement event.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseMovementListener
Item myItem
MouseMovementListener listener
myItem:AddMouseMovementListener(listener)
myItem:RemoveMouseMovementListener(listener)

RemoveMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action removes a MouseWheelListener from the Item. The listener will no longer receive notification if the Item gets a mouse wheel event.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.MouseWheelListener
Item myItem
MouseWheelListener listener
myItem:AddMouseWheelListener(listener)
myItem:RemoveMouseWheelListener(listener)

RemoveTouchListener(Libraries.Interface.Events.TouchListener listener)

This action removes a TouchListener from the Item. The listener will no longer receive notification if the Item gets a TouchEvent.

Parameters

Example

use Libraries.Interface.Item
use Libraries.Interface.Events.TouchListener
Item myItem
TouchListener listener
myItem:AddTouchListener(listener)
myItem:RemoveTouchListener(listener)

RequestVerticesUpdate()

This action informs the engine that this Item needs to recalculate its vertex values before they can be used (most commonly, to be drawn to the screen). Most users will never need to call this directly. If you are using a custom ShaderProgram with this Item, you can use this action to indicate that the shader mapping should reset the vertex values for this Item before its drawn again.

RequireSimulation(boolean flag)

This action sets the y-component of this item's linear velocity in units per second. Physics must be enabled on this item before using this action.

Parameters

  • boolean flag

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetLinearVelocityY(100)

ResetMass()

This action sets the mass, mass moment of inertia, and how the 2D item should move (via linear velocity) to be at the desired location.

Resize()

The Resize action is used to recalculate the size and position of Controls that are being controlled by a Layout. Calling Resize on an Item2D won't have a direct effect on it, but if the Item's children hierarchy contains any Controls, those Controls will be resized.

Rotate(number degrees)

Rotates this Item2D by the given number of degrees. This will also rotate all Items in the children hierarchy of this Item.

Parameters

  • number degrees

Example

use Libraries.Interface.Item

Item myItem
myItem:Rotate(65)

Scale(number amount)

This action will multiply the current scaling value by the given number. A parameter of 0 or less will be ignored.

Parameters

  • number amount

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScale(1.5)
myItem:Scale(1.1)

Scale(number xAmount, number yAmount)

This action will multiply the x scaling and y scaling values, respectively, by the given numbers. A parameter of 0 or less will be ignored.

Parameters

  • number xAmount
  • number yAmount

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScale(1.5)
myItem:Scale(1.1, 0.9)

ScaleFromCenter(number amount)

This action will multiply the current scaling value by the given number. A parameter of 0 or less will be ignored. This action will increase or decrease the scale of the object from the center, and update the Item's x,y coordinates to reflect the new bottom-left corner of the Item.

Parameters

  • number amount

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScale(1.5)
myItem:ScaleFromCenter(1.1)

ScaleFromCenter(number xAmount, number yAmount)

This action will multiply the current scaling values of the x and y planes by the given number. A parameter of 0 or less will be ignored. This action will increase or decrease the scale of the object from the center, and update the Item's x,y coordinates to reflect the new bottom-left corner of the Item.

Parameters

  • number xAmount
  • number yAmount

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScale(1.5)
myItem:ScaleFromCenter(1.1, 0.9)

SetAcceptsMouseInput(boolean accepts)

This action sets whether or not this Item accepts mouse input. If set to true, this will intercept incoming mouse events, triggering any related MouseListeners and InputSets and preventing the mouse event from propagating to other Items on the Layer. The default value is true.

Parameters

  • boolean accepts: True to set this Item to receive mouse events, or false to ignore them.

SetAccessibilityCode(integer newAccessibilityCode)

This action changes the accessibility code for this Item. This should be done with care because setting the accessiblity code to the incorrect type can cause accessibility to stop functioning or, in some cases, cause the program to crash.

Parameters

  • integer newAccessibilityCode: the new accessibility code for this Item.

SetAccessibilityRoleDescription(text newRoleDescription)

This action sets a custom accessibility role description for this item. This should only be done if there is not a standard accessibility code for the type of item being implemented. If the item behaves very similarly to a standard control type, then set the accessibility code to that standard type while also setting the role description. For example, if implementing an item that extends Control, is keyboard focusable, and responds to activation via both mouse clicks and the Space key, like a button, but it shouldn't be described as a button, then set the accessibility code to BUTTON and the custom role description to whatever is appropriate. If there isn't a suitable accessibility code, or if in doubt, set the accessibility code to CUSTOM.

Parameters

  • text newRoleDescription: the new custom role description for this Item.

SetAngularDamping(number angularDamping)

This action gets the rotational inertia of this item. The inertia is in kilogram units squared.

Parameters

  • number angularDamping

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number inertia = item:GetInertia()

SetAngularVelocity(number angularVelocity)

This action sets this item's angular velocity in radians per second. Physics must be enabled in this item before using this action.

Parameters

  • number angularVelocity: The angular velocity of this item in radians per second

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetAngularVelocity(0.1)

SetApplyEffectsOnClick(boolean apply)

Parameters

  • boolean apply

SetBackgroundColor(Libraries.Game.Graphics.ColorGroup color)

SetBorderStyle(integer style)

Parameters

  • integer style

SetBorderThickness(integer thickness)

return label:GetFont()

Parameters

  • integer thickness

SetBottomBorder(boolean value)

Parameters

  • boolean value

SetBoundingBox(number newX, number newY, number newWidth, number newHeight)

This action will set the x coordinate, y coordinate, width, and height of the Item2D, respectively.

Parameters

  • number newX
  • number newY
  • number newWidth
  • number newHeight

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetBoundingBox(50, 200, 100, 75)

SetCenter(number setX, number setY)

This action will set the X and Y coordinates of the Item so that the center of the Item is located at the given X, Y coordinates.

Parameters

  • number setX
  • number setY

Example

use Libraries.Interface.Item
Item myItem
myItem:SetCenter(70, 40)

SetCenterX(number setX)

This action will set the X coordinate of the Item so that the center of the Item is aligned with the given X coordinate value.

Parameters

  • number setX

Example

use Libraries.Interface.Item
Item myItem
myItem:SetCenterX(70)

SetCenterY(number setY)

This action will set the Y coordinate of the Item so that the center of the Item is aligned with the given Y coordinate value.

Parameters

  • number setY

Example

use Libraries.Interface.Item
Item myItem
myItem:SetCenterY(65)

SetChildrenProcessingMouseEvents(boolean shouldProcess)

The SetChildrenProcessingMouseEvents action is used to set whether or not children items should receive mouse events if this Item is using custom drawing. This affects only custom drawing Items -- if the Item isn't drawing, children objects will always receive the mouse events first. This value is false by default. This is an advanced feature only necessary for complex custom components, and most users will not need to use this.

Parameters

  • boolean shouldProcess

SetClipCoordinates(Libraries.Game.Graphics.Painter2D painter)

This action sets the clipping coordinates of the given painter to respect the coordinates of this Item (if it's clipping) as well as any clipping being performed by parent Items. This action is called automatically by the Game engine as necessary, and most users will never need to use this action directly.

Parameters

SetClipping(boolean clip)

The SetClipping action is used to enable or disable clipping. If it is enabled, when the Item and its children are drawn as part of the QueueForDrawing action, any pixels that would be drawn outside of the unrotated dimensions of the Item are not rendered. In other words, the Item will only draw inside the exact rectangle formed by its x, y position and its width and height.

Parameters

  • boolean clip: True to enable pixel clipping, false to disable.

SetCollidable(boolean flag)

This action sets this item to be collidable. Passing true turns on collision for this item while passing false turns off collision for this item.

Parameters

  • boolean flag: Whether or not to turn collision on for this item

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:SetCollidable(true)

SetCollideWithChildren(boolean flag)

This action gets the position of the item in physics space from the previous frame. This action is used internally and users should not need to use this action

Parameters

  • boolean flag

SetCollisionGroupFlag(boolean flag)

This action sets the total torque on this item. The units are kilogram units squared per second per second. This action should be used to set the total torque on this item. If we want to apply a torque to this item, we should use the ApplyTorque actions instead. Physics must be enabled on this action before using this action.

Parameters

  • boolean flag

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetTorque(200)

SetCollisionGroupIndex(integer index)

This action sets the total force on this item. The units are kilogram units per second per second. This action should be used to set the total force on this item. If we want to apply a force to this item, we should use the ApplyForce actions instead. Physics must be enabled on this item before using this action.

Parameters

  • integer index

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 force

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
force:Set(300, 350)
item:SetForce(force)

SetCollisionList(Libraries.Game.Collision.CollisionEdge2D edge)

This is an action used internally by the physics system to keep track of the collisions with this item in a linked list structure. This action sets the head of the linked list of collisions to the passed CollisionEdge2D object. This action is used internally and users should not need to use this action.

Parameters

SetCustomDrawing(boolean isCustom)

The SetCustomDrawing action is used to indicate that this Item wants to directly manage how itself and its children are drawn. When this is set to true, the Item must be responsible for determining this rendering via the Draw(Painter2D) action -- if this action isn't overridden, the Item and its children won't be drawn. This is an advanced feature only necessary for complex custom components, and most users will not need to use this functionality.

Parameters

  • boolean isCustom: True if this Item should use custom drawing, or false to use default drawing rules.

SetDensity(number density)

This action applies an angular impulse to this item. The units are in kilogram units squared per second. This modifies the angular velocity of this item. Physics must be enabled on this item before using this action.

Parameters

  • number density

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:ApplyAngularImpulse(80)

SetDescription(text newDescription)

This action sets the internal description of the Item.

Parameters

  • text newDescription

Example

use Libraries.Interface.Item

Item item
item:SetDescription("Used for demo purposes.")

SetFlipX(boolean flip)

This action will set the Item2D to be flipped across the X-axis according to the boolean. If the boolean value is false, the Item2D will be set to its unflipped state. If it is true, the Item will be set to its flipped state.

Parameters

  • boolean flip

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetFlipX(true)

SetFlipY(boolean flip)

This action will set the Item2D to be flipped across the Y-axis according to the boolean. If the boolean value is false, the Item2D will be set to its unflipped state. If it is true, the Item will be set to its flipped state.

Parameters

  • boolean flip

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetFlipY(true)

SetFocusable(boolean focus)

The SetFocusable action sets whether or not this Item should be focusable. If the Item is currently focused and made unfocusable, then it will lose focus, and there will be no focused element.

Parameters

  • boolean focus

SetFont(Libraries.Game.Graphics.Font font)

return label:GetText()

Parameters

SetForce(Libraries.Compute.Vector2 force)

This action sets the total force on this item. The units are kilogram units per second per second. This action should be used to set the total force on this item. If we want to apply a force to this item, we should use the ApplyForce actions instead. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 force

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
force:Set(300, 350)
item:SetForce(force)

SetFriction(number friction)

This action applies a torque to this item. The units are kilogram units squared per second per second. Physics must be enabled on this item before using this action.

Parameters

  • number friction

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:ApplyTorque(350)

SetHasMoved(boolean flag)

This action returns the swept movement of this item used for time of impact solving for the physics system. This action is used internally and users should not need to call this action.

Parameters

  • boolean flag

SetHeight(number newHeight)

This action will set the height of the Item2D.

Parameters

  • number newHeight

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetHeight(70)

SetInputGroup(text group)

This action sets the input group for this Item. When used with the Game libraries, this tag describes what InputTable (if any) can interact with this Item due to input.

Parameters

  • text group: The new input group to use.

Example

use Libraries.Interface.Item

Item item
item:SetInputGroup("arrowKeys")
output "My item's input group is : " + item:GetInputGroup()

SetItem(integer index, Libraries.Interface.Item2D newItem)

This action sets a value inside the internal item array of this Item2D.

Parameters

Example

use Libraries.Interface.Item2D

Item2D parentItem
Item2D child1
Item2D child2
parentItem:Add(child1)
parentItem:SetItem(0, child2)

SetItem(Libraries.Interface.Item2D item)

SetJointList(Libraries.Game.Physics.Joints.JointEdge2D edge)

This is an action used internally by the physics system to keep track of the joints connected to this item in a linked list structure. This action sets the head of the linked list of collisions to the passed CollisionEdge2D object. This action is used internally and users should not need to use this action.

Parameters

SetLayer(Libraries.Game.Layer2D parentLayer)

This action is used by the Game libraries to create a reference to the layer that this Item2D exists on. It is automatically called as needed by the Layer2Dclass. Most users will never need to use this action directly.

Parameters

SetLeftBorder(boolean value)

Parameters

  • boolean value

SetLinearDamping(number linearDamping)

Given a point relative to the center of this item, this action computes and returns that point in screen coordinates.

Parameters

  • number linearDamping

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 localPoint

item:SetWidth(100)
item:SetHeight(100)
item:SetPosition(400, 250)

localPoint:Set(0, 0)    // Get the coordinates of the center of the item

Vector2 worldPoint = item:GetWorldPoint(localPoint)

SetLinearVelocity(Libraries.Compute.Vector2 linearVelocity)

This action sets the linear velocity of this item in units per second. Physics must be enabled on this item before using this action.

Parameters

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 velocity

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
velocity:Set(100, 0)
item:SetLinearVelocity(velocity)

SetLinearVelocityX(number linearVelocityX)

This action sets the x-component of this item's linear velocity in units per second. Physics must be enabled on this item before using this action.

Parameters

  • number linearVelocityX: The x-component of this item's linear velocity in units per second

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetLinearVelocityX(100)

SetLinearVelocityY(number linearVelocityY)

This action sets the y-component of this item's linear velocity in units per second. Physics must be enabled on this item before using this action.

Parameters

  • number linearVelocityY: The y-component of this item's linear velocity in units per second

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetLinearVelocityY(100)

SetMass(number mass)

This action is used to syncronize the item's position in physics space with its position in the tree used for broadphase collision. This action is used internally and users should not need to use this action.

Parameters

  • number mass

SetMass(Libraries.Game.Physics.Mass2D mass)

This action sets the position of the item in physics space from the previous frame. This action is used internally and users should not need to use this action.

Parameters

SetName(text value)

Parameters

  • text value

SetNextFocus(Libraries.Interface.Item next)

This action sets the next focus item. When this Item has the focus and the user requests the focus to advance (e.g. by pressing the tab key), the focus will move to the next focus item, if it is defined.

Parameters

SetNonResponsive()

This action returns all of the broadphase nodes attached to this item in an array. This action is used internally and users should not need to use this action.

SetOffset(number xAmount, number yAmount)

This action will set both the X and Y offsets of the item, respectively.

Parameters

  • number xAmount
  • number yAmount

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffset(100, 75)

SetOffset(number xAmount, number yAmount, number zAmount)

This action will set X, Y, and Z offsets of the item, respectively.

Parameters

  • number xAmount
  • number yAmount
  • number zAmount

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffset(100, 75, 2)

SetOffsetX(number xAmount)

This action sets the X offset of the Item. The offset tells the Item where to relate its X position to. In other words, the X offset is where an X coordinate of 0 is for this Item. This is automatically set when using an action to add an Item to another Item.

Parameters

  • number xAmount

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetX(100)

SetOffsetY(number yAmount)

This action sets the Y offset of the item. The offset tells the Item where to relate its Y position to. In other words, the Y offset is where a Y coordinate of 0 is for this item. This is automatically set when using an action to add an Item to another Item.

Parameters

  • number yAmount

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetY(75)

SetOffsetZ(number zAmount)

This action sets the Z offset of the item. The offset tells the Item where to relate its Z position to. In other words, the Z offset is where a Z coordinate of 0 is for this item. This is automatically set when using an action to add an Item to another Item.

Parameters

  • number zAmount

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetOffsetZ(75)

SetOrigin(number setX, number setY)

This action will set the origin of the Item to be at the given location in the Item. This is used when projecting the Item's vertices onto the screen, i.e. when determining where to draw a picture on the screen.

Parameters

  • number setX
  • number setY

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetOrigin(20, 20)

SetOriginCenter()

This action will set the origin of the Item to be at the current center of the Item's width and height bounds.

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(50, 80)
myItem:SetOriginCenter()

SetParent(Libraries.Interface.Item2D newItem)

This action sets a reference to the parent item. It is called automatically when an Item2D is added as a child to another Item2D. Most users will not need to use this action directly.

Parameters

SetPhysicsProperties(Libraries.Game.Physics.PhysicsProperties2D properties)

This action is used to get the bounding box of the item. A bounding box is an axis-alligned rectangle containing the shape used for broadphase collision. This action is used internally and users should not need to use this action.

Parameters

SetPosition(number setX, number setY)

This action will set both the X coordinate and the Y coordinate of the Item, in that order.

Parameters

  • number setX
  • number setY

Example

use Libraries.Interface.Item
Item myItem
myItem:SetPosition(30, 70)

SetPosition(number setX, number setY, number setZ)

This action will set both the X and Y coordinates of this Item2D, and will additionally set the Z value of this Item2D.

Parameters

  • number setX
  • number setY
  • number setZ

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetPosition(30, 70, 3)

SetPreviousFocus(Libraries.Interface.Item previous)

This action sets the previous focus item. When this Item has the focus and the user requests the focus to move backwards (e.g. by pressing shift & tab), the focus will move to the previous focus item, if it is defined.

Parameters

SetProperty(text key, Libraries.Data.Formats.JavaScriptObjectNotation value)

SetResponsive()

This action determines whether this item is collidable.

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:SetCollidable(true)
boolean result = circle:IsCollidable

SetResponsiveness(integer type)

This action returns the mass of the item in kilograms. Physics must be enabled on this item before using this action. If the item is non-responsive or unmovable, the mass is zero.

Parameters

  • integer type

Example

use Libraries.Interface.Item2D

Item2D item
item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetMass(20)
number mass = item:GetMass()

SetRestitution(number restitution)

This action applies a force to this item at the passed point. The force is in kilogram units per second per second. The point is the screen coordinates where the point will be applied. If the point is not on the center of the item, then a torque will be introduced causing the item to rotate. Physics must be enabled on this item before using this action.

Parameters

  • number restitution

Example

use Libraries.Compute.Vector2
use Libraries.Interface.Item2D

Item2D item
Vector2 force
Vector2 point

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)

force:Set(300, 350)
point:Set(100, 100)    // apply the force to the top right corner of the item

item:ApplyForce(force, point)

SetRightBorder(boolean value)

Parameters

  • boolean value

SetRotation(number degrees)

Sets this Item2D to be rotated to an angle of the given number of degrees. This will also rotate all Items in the children hierarchy of this Item.

Parameters

  • number degrees

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetRotation(90)

SetScale(number newX, number newY)

This action sets separate scaling values for the x and y planes on this Item2D. This will cause the vertices of this Item to be calculated based on a scaled percentage of the width and height. The default scaling values are 1.0, or 100% of the Item's width and height.

Parameters

  • number newX
  • number newY

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScale(1.5, 0.75)

SetScale(number scale)

This action sets the scale of this Item2D, causing the vertices of the item to be calculated based on a scaled percentage of the width and height. The default scaling values are 1.0, or 100% of the Item's width and height.

Parameters

  • number scale

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScale(1.25)

SetScaleFromCenter(number scale)

This action sets the scale of this Item2D, causing the vertices of the item to be calculated based on a scaled percentage of the width and height. The default scaling values are 1.0, or 100% of the Item's width and height. This action will increase or decrease the scale of the object from the center, and update the Item's x,y coordinates to reflect the new bottom-left corner of the Item.

Parameters

  • number scale

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScaleFromCenter(1.25)

SetScaleFromCenter(number newX, number newY)

This action sets separate scaling values for the x and y planes on this Item2D. This will cause the vertices of this Item to be calculated based on a scaled percentage of the width and height. The default scaling values are 1.0, or 100% of the Item's width and height. This action will increase or decrease the scale of the object from the center, and update the Item's x,y coordinates to reflect the new bottom-left corner of the Item.

Parameters

  • number newX
  • number newY

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScaleFromCenter(1.5, 0.75)

SetScaleX(number scaleX)

This action sets the scaling value of the x plane on this Item2D. This will cause the vertices of this Item to be calculated based on a scaled percentage of the width. The default scaling values are 1.0, or 100% of the Item's width and height.

Parameters

  • number scaleX

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScaleX(1.5)

SetScaleY(number scaleY)

This action sets the scaling value of the y plane on this Item2D. This will cause the vertices of this Item to be calculated based on a scaled percentage of the height. The default scaling values are 1.0, or 100% of the Item's width and height.

Parameters

  • number scaleY

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 200)
myItem:SetScaleY(0.75)

SetScreenPositionFromPhysicsPosition()

This item returns the collision shape of this item. The collision shape is the shape the collision system will use to test for collisions with this item. Note that this may be different from the shape drawn on the screen.

Example

use Libraries.Game.Drawable
use Libraries.Game.Collision.Shapes.Circle

Drawable ball
ball:Load("ball.png")
Circle circle
circle:SetRadius(30)
ball:SetShape(circle)
CollisionShape2D shape = ball:GetShape()

SetShape(Libraries.Game.Collision.Shapes.CollisionShape2D shape)

This action sets the collision shape of this item. The collision shape is the shape the collision system will use to test for collisions with this item. Note that this may be different from the shape drawn on the screen. A copy of the passed shape is used for the collison shape for this item.

Parameters

Example

use Libraries.Game.Drawable
use Libraries.Game.Collision.Shapes.Circle

Drawable ball
ball:Load("ball.png")
Circle circle
circle:SetRadius(30)
ball:SetShape(circle)

SetSize(number newWidth, number newHeight)

This action will set the width and height of the Item2D, respectively.

Parameters

  • number newWidth
  • number newHeight

Example

use Libraries.Interface.Item2D

Item2D myItem
myItem:SetSize(100, 50)

SetSleepTime(number time)

This action enables physics for this item. Passing true turns on physics for this item while passing false turns off physics for this item.

Parameters

  • number time

Example

use Libraries.Game.Graphics.Drawable

Drawable circle
circle:LoadFilledCircle(30)
circle:EnablePhysics(true)

SetText(text newText)

Parameters

  • text newText

SetTopBorder(boolean value)

Parameters

  • boolean value

SetTorque(number torque)

This action sets the total torque on this item. The units are kilogram units squared per second per second. This action should be used to set the total torque on this item. If we want to apply a torque to this item, we should use the ApplyTorque actions instead. Physics must be enabled on this action before using this action.

Parameters

  • number torque

Example

use Libraries.Interface.Item2D

Item2D item

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
item:SetTorque(200)

SetTransform(Libraries.Compute.Vector2 position, number angle)

This action is used internally by the physics system to set the position of this item in the physics world. This action is used internally and users users should not need to use this action.

Parameters

  • Libraries.Compute.Vector2: The vector representing the position of the center of the item in physics space
  • number angle: The rotation in radians of the item in physics space

SetTransform(Libraries.Game.Collision.PhysicsPosition2D transform)

This action sets the position of the item in physical space. This action is used internally and should not be used by users to set the position of this item on the screen.

Parameters

SetTransform0(Libraries.Game.Collision.PhysicsPosition2D transform)

This action sets the position of the item in physics space from the previous frame. This action is used internally and users should not need to use this action.

Parameters

SetUnmovable()

This action destroys the nodes for this item for the broadphase collision, essentially removing it from the collision detection system. This action is used internally and users should not need to use this action.

SetUpdateTransform(boolean flag)

This item is used to test whether a passed point is on the collision shape of this item.

Parameters

  • boolean flag

Example

use Libraries.Interface.Drawable
use Libraries.Compute.Vector2

Drawable circle
circle:LoadFilledCircle(30)
circle:SetPosition(350, 400)
Vector2 point
point:Set(365, 410)
boolean result = circle:TestPoint(point)

SetView2D(Libraries.Interface.Views.View2D content)

The IsClipping action returns true if pixel clipping is enabled, or false if it is disabled. If it is enabled, when the Item and its children are drawn as part of the QueueForDrawing action, any pixels that would be drawn outside of the unrotated dimensions of the Item are not rendered. In other words, the Item will only draw inside the exact rectangle formed by its x, y position and its width and height.

Parameters

SetWidth(number newWidth)

This action will set the width of the Item2D.

Parameters

  • number newWidth

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetWidth(50)

SetX(number setX)

This action sets the X coordinate of the Item.

Parameters

  • number setX

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetX(35.0)

SetY(number setY)

This action sets the Y coordinate of the Item.

Parameters

  • number setY

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetY(210.0)

SetZ(number setZ)

This action sets the Z value of the Item2D. For Item2D, the z value is used during layer sorting to determine ordering, where lower z values will be placed first.

Parameters

  • number setZ

Example

use Libraries.Interface.Item2D
Item2D myItem
myItem:SetZ(3)

ShouldCollide(Libraries.Interface.Item2D otherItem)

get the old target global center of the object

Parameters

Return

boolean:

Show()

This action is used to indicate that an Item and all Items that were added to it should be visible on the screen. Note that the Item class on its own cannot be drawn on the screen, but classes that inherit from it such as Libraries.Game.Graphics.Drawable can be. By default, Items are considered visible.

Example

use Libraries.Interface.Item

Item item
item:Show()

Simulate(boolean flag)

This action sets the linear velocity of this item in units per second. Physics must be enabled on this item before using this action.

Parameters

  • boolean flag

Example

use Libraries.Interface.Item2D
use Libraries.Compute.Vector2

Item2D item
Vector2 velocity

item:SetWidth(100)
item:SetHeight(100)
item:EnablePhysics(true)
velocity:Set(100, 0)
item:SetLinearVelocity(velocity)

SynchronizeNodes()

This action is used to syncronize the item's position in physics space with its position in the tree used for broadphase collision. This action is used internally and users should not need to use this action.

SynchronizeTransform()

This action is used to update this items position in physics space after physics solving is finished for this item. This action is used internally and users should not need to use this action.

TestPoint(Libraries.Compute.Vector2 point)

This item is used to test whether a passed point is on the collision shape of this item.

Parameters

Return

boolean: True if the passed point is on the collisoin shape, false otherwise

Example

use Libraries.Interface.Drawable
use Libraries.Compute.Vector2

Drawable circle
circle:LoadFilledCircle(30)
circle:SetPosition(350, 400)
Vector2 point
point:Set(365, 410)
boolean result = circle:TestPoint(point)

Update(number secondsSinceUpdate)

This action updates the item. It takes a number parameter that should indicate how many seconds have passed since the last time this action was called. This action does nothing in the Item class, but any class that inherits from Item may override it.

Parameters

  • number secondsSinceUpdate: The number of seconds that have passed since the last time Update was called.

Example

use Libraries.Interface.Item
use Libraries.System.DateTime

class Main is Item

    action Main
        // We'll use a DateTime object to count seconds.
        DateTime time
        number currentTime = time:GetEpochTime()
        number newTime = 0

        repeat while GetX() < 300
            // Check what the time is now.
            newTime = time:GetEpochTime()

            // Calculate how many seconds have passed, then call Update.
            Update( (newTime - currentTime)/1000 )

            // Store the old time.
            currentTime = newTime
        end
    end

    // Our update action will move our Item to the right at 200 units a second.
    action Update(number secondsSinceUpdate)
        SetX(GetX() + 200 * secondsSinceUpdate)
    end
end

UpdateAll(number secondsSinceUpdate)

This action calls the Update action on this Item and all Items that have been added to this item with the Add action.

Parameters

  • number secondsSinceUpdate: The number of seconds that have passed since the last time Update was called.

Example

use Libraries.Interface.Item

Item parentItem
Item child1
Item child2
parentItem:Add(child1)
parentItem:Add(child2)
parentItem:UpdateAll(0)

UpdateFlipping(boolean flipX, boolean flipY)

Parameters

  • boolean flipX
  • boolean flipY

UpdatePosition(number x, number y, number z)

Parameters

  • number x
  • number y
  • number z

UpdateRotation(number angle)

Parameters

  • number angle

UpdateSize(number width, number height)

Parameters

  • number width
  • number height

UpdateTransformAngle()

This action is used internally by the physics system to set the position of this item in the physics world. This action is used internally and users users should not need to use this action.

UpdateTransformX()

This action sets the position of the item in physical space. This action is used internally and should not be used by users to set the position of this item on the screen.

UpdateTransformY()

This action returns the position of the item in physical space. This acction is used internally and should not be used by users to get the position of this item on the screen.