Libraries.Game.DialogLayer Documentation

Inherits from: Libraries.Language.Object, Libraries.Game.Layer, Libraries.Game.Layer2D

Actions Documentation

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

This action will add an Item2D to this Layer's array of items at the index location. It will be updated along with the rest of the layer, and will be drawn on the screen (if it is visible and possible to draw the given Item2D).

Parameters

  • integer index: The index to store the item at in the layer's array of items.
  • Libraries.Interface.Item2D: The Item2D to be added to this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Item2D objects aren't visible, but can still be used for game logic.
        Item2D area
        area:SetSize(50, 50)
        area:SetPosition(100, 100)

        // Drawables inherit from Item2D, so they can be added too.
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(0, area)
        layer:Add(1, circle)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

Add(Libraries.Interface.Item2D item)

This action will add an Item2D to this Layer. It will be updated along with the rest of the layer, and will be drawn on the screen (if it is visible and possible to draw the given Item2D). The Item2D will be added to the back of the layer's internal array of items.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Item2D objects aren't visible, but can still be used for game logic.
        Item2D area
        area:SetSize(50, 50)
        area:SetPosition(100, 100)

        // Drawables inherit from Item2D, so they can be added too.
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(area)
        layer:Add(circle)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

AddCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)

AddCollisionListener will add a collision listener to this layer. The collision listener will be notified of collisions occuring on this layer, and is responsible for managing the collision events.

Parameters

AddGestureListener(Libraries.Interface.Events.GestureListener listener)

This action will add a GestureListener to the layer. When the layer receives a gesture event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all GestureListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.GestureListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from GestureListener.
    GestureListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddGestureListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddJoint(Libraries.Game.Physics.Joints.Joint2D joint)

This action will remove an Item2D from the front of the array of items in this layer, and return the item that was removed. This is functionally the same as calling "RemoveAt(0)".

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(circle)
        AddLayer(layer)

        Item2D item = layer:RemoveFromFront()
    end

    action Update(number seconds)
    end
end

AddMouseListener(Libraries.Interface.Events.MouseListener listener)

This action will add a MouseListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseListener.
    MouseListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)

This action will add a MouseMovementListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseMovementListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseMovementListener.
    MouseMovementListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseMovementListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)

This action will add a MouseWheelListener to the layer. When the layer receives a mouse event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all MouseWheelListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseWheelListener.
    MouseWheelListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseWheelListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AddToFront(Libraries.Interface.Item2D item)

This action will add an Item2D to this layer's array of items at index 0. It will be updated along with the rest of the layer, and will be drawn on the screen (if it is visible and possible to draw the given Item2D). Adding an item to the front will cause it to be drawn and updated before other items in the layer, and other drawn items will appear to be on top of it.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        // Item2D objects aren't visible, but can still be used for game logic.
        Item2D area
        area:SetSize(50, 50)
        area:SetPosition(100, 100)

        // Drawables inherit from Item2D, so they can be added too.
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:AddToFront(area)
        layer:AddToFront(circle)
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

AddTouchListener(Libraries.Interface.Events.TouchListener listener)

This action will add a TouchListener to the layer. When the layer receives a touch event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all TouchListeners in the layer will receive the event.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.TouchListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from TouchListener.
    TouchListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddTouchListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

AutomaticallyClearForces()

This action will add a TouchListener to the layer. When the layer receives a touch event, it will first try to find the topmost item which can handle the event. If the event is not handled, then all TouchListeners in the layer will receive the event.

Return

boolean:

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.TouchListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from TouchListener.
    TouchListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddTouchListener(myListener)
        AddLayer(layer)
    end

    action Update(number seconds)
    end

end

ClearForces()

This action will remove all MouseWheelListeners from the layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseWheelListener.
    MouseWheelListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseWheelListener(myListener)
        AddLayer(layer)

        layer:EmptyMouseWheelListeners()
    end

    action Update(number seconds)
    end

end

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)

Draw()

This action will draw all items in this Layer on the screen (if they can be drawn and they aren't hidden). If the Layer is currently hidden, then this action will do nothing. This is automatically called by the Game class as needed. Most users will never need to use this action directly.

Empty()

This action will clear all the items in this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(circle)
        AddLayer(layer)

        layer:Empty()
    end

    action Update(number seconds)
    end
end

EmptyMouseListeners()

This action will remove all MouseListeners from the layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseListener.
    MouseListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseListener(myListener)
        AddLayer(layer)

        layer:EmptyMouseListeners()
    end

    action Update(number seconds)
    end

end

EmptyMouseMovementListeners()

This action will remove all MouseMovementListeners from the layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseMovementListener.
    MouseMovementListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseMovementListener(myListener)
        AddLayer(layer)

        layer:EmptyMouseMovementListeners()
    end

    action Update(number seconds)
    end

end

EmptyMouseWheelListeners()

This action will remove all MouseWheelListeners from the layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseWheelListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseWheelListener.
    MouseWheelListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseWheelListener(myListener)
        AddLayer(layer)

        layer:EmptyMouseWheelListeners()
    end

    action Update(number seconds)
    end

end

EmptyTouchListeners()

This action will remove all TouchListeners from the layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.TouchListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from TouchListener.
    TouchListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddTouchListener(myListener)
        AddLayer(layer)

        layer:EmptyTouchListeners()
    end

    action Update(number seconds)
    end

end

EnablePhysics(boolean flag)

This action will get an Item2D stored in the layer at the given index in the layer's internal array of items.

Parameters

  • boolean flag

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(circle)
        AddLayer(layer)

        Item2D item = layer:Get(0)
    end

    action Update(number seconds)
    end
end

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)

Get(integer index)

This action will get an Item2D stored in the layer at the given index in the layer's internal array of items.

Parameters

  • integer index: The index to retrieve an item from in the layer's array of items.

Return

Libraries.Interface.Item2D: The Item2D stored at the index in the array.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(circle)
        AddLayer(layer)

        Item2D item = layer:Get(0)
    end

    action Update(number seconds)
    end
end

GetAutomaticResizing()

This action returns whether or not the Layer will automatically respond to ResizeEvents. If this value is true, then the Layer will automatically adjust the camera and resize Items on the Layer when a ResizeEvent occurs.

Return

boolean:

GetCamera()

This action will return the camera being used by this Layer. The camera is used to determine what will be drawn on the screen. Objects will be drawn on the screen as they are seen by the Layer's set camera.

Return

Libraries.Game.Graphics.Camera: The camera currently being used by this layer.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.Camera

class Main is Game

    Camera layerCamera = undefined

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layerCamera = layer:GetCamera()
        AddLayer(layer)
    end

    action Update(number seconds)
    end
end

GetCollisionList()

This action gets the list of items on this layer that are colliding and returns it as an array.

Return

Libraries.Interface.Events.CollisionEvent2D:

GetCollisionManager()

This action gets the collision manager for this object which is responsible for managing the collisions between all colliding items on this layer.

Return

Libraries.Game.Collision.CollisionManager2D:

GetFromEnd()

This action will return the item stored at the end of the layer's array of items.

Return

Libraries.Interface.Item2D: The last item in the layer's array of items.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(circle)
        AddLayer(layer)

        Item2D item = layer:GetFromEnd()
    end

    action Update(number seconds)
    end
end

GetFromFront()

This action will return the Item2D at the front of the layer's array of items. This is functionally the same as calling "Get(0)".

Return

Libraries.Interface.Item2D: The first item in the layer's array of items.

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Item2D
use Libraries.Game.Graphics.Drawable

class Main is Game

    action Main
        StartGame()
    end

    action CreateGame
        Drawable circle
        circle:LoadFilledCircle(25)
        circle:SetPosition(300, 100)

        Layer2D layer
        layer:Add(circle)
        AddLayer(layer)

        Item2D item = layer:GetFromFront()
    end

    action Update(number seconds)
    end
end

GetGravity()

This action will remove a MouseMovementListener from the layer. The listener will no longer receive events from the layer. If the given MouseMovementListener is not on the layer before calling this action, then this action will have no effect.

Return

Libraries.Compute.Vector2:

Example

use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Interface.Events.MouseMovementListener

class Main is Game

    // For most programs, this should be replaced with 
    // a custom class inheriting from MouseMovementListener.
    MouseMovementListener myListener

    action Main
        StartGame()
    end

    action CreateGame
        Layer2D layer
        layer:AddMouseMovementListener(myListener)
        AddLayer(layer)