Libraries.Interface.Controls.Scenes.Layers.EditorLayer Documentation
The EditorLayer class is used to manage the editor’s objects. This is the base class that the 2D and 3D EditorLayer versions will inherit from. The EditorLayer is the space where the objects being added to scene are drawn to and managed so the user can interact with them. This class handles showing grids, cursors, previews, and objects in the scene.
Inherits from: Libraries.Language.Object, Libraries.Game.Layer
Actions Documentation
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
- Libraries.Interface.Events.MouseListener: The MouseListener to add to this 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)
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
- Libraries.Interface.Events.MouseMovementListener: The MouseMovementListener to add to this 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)
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
- Libraries.Interface.Events.MouseWheelListener: The MouseWheelListener to add to this 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)
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
- Libraries.Interface.Events.TouchListener: The TouchListener to add to this 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)
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
- Libraries.Language.Object: The object to compare to.
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.
EnablePhysics(boolean flag)
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.
Parameters
- boolean flag
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
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)
GainedSelection()
Internal action that shows the components of the editor when this layer is selected.
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
GetCameraPitch()
This action returns the pitch of the camera in degrees.
Return
number: The pitch angle, measured in degrees.
GetCameraRoll()
This action returns the roll of the camera in degrees.
Return
number: The roll angle, measured in degrees.
GetCameraYaw()
This action returns the yaw of the camera in degrees.
Return
number: The yaw angle, measured in degrees.
GetCameraYawPitchRoll()
This action returns the yaw, pitch, and roll of the camera as a Vector3. Each value in the Vector represents the yaw, pitch, and roll in degrees.
Return
Libraries.Compute.Vector3: Vector3 containing the value of the yaw, pitch, and roll in degrees
GetCursor()
Internal action the returns the EditorCursor object associated with this layer.
Return
Libraries.Interface.Controls.Scenes.Items.EditorCursor: The cursor associated with this layer
GetGridUnitSize()
Returns the current unit size of the grid.
Return
number: Returns the unit size of the grid as a 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()
GetItemWithInput(number x, number y, Libraries.Containers.Array<Libraries.Game.InputSet> inputValues)
This action finds an Item on this layer which is present at the given coordinates and will respond to at least one of the given InputSets.
Parameters
- number x
- number y
- Libraries.Containers.Array
Return
GetName()
This action returns the name of the Layer. This is used to identify the layer, especially in the Scene system.
Return
text:
GetNearestGridCoordinate(number coordinate)
Given a number this action returns the nearest coordinate that lies on the grid of this layer.
Parameters
- number coordinate: The number used to calculate the grid coordinate
Return
number: The nearest coordinate on the grid
GetNextGridCoordinate(number coordinate)
Given a number this action returns the nearest coordinate on the grid of this layer that is greater than the number passed.
Parameters
- number coordinate: The number used to calculate the grid coordinate
Return
number: The next coordinate on the grid
GetPreviousGridCoordinate(number coordinate)
Given a number this action returns the nearest coordinate on the grid of this layer that is less than the number passed.
Parameters
- number coordinate: The number used to calculate the grid coordinate
Return
number: The previous coordinate on the grid
GetSceneEditor()
Returns the SceneEditor object that this layer is a part of.
Return
Libraries.Interface.Controls.Scenes.SceneEditor: The SceneEditor this layer is attached to
GetViewportHeight()
This action will hide the Layer. This will prevent the Layer from appearing when asked to draw.
Return
integer:
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 square
square:LoadFilledRectangle(200, 200)
Layer2D layer
layer:Add(square)
AddLayer(layer)
layer:Hide()
end
action Update(number seconds)
end
end
GetViewportWidth()
This action will show the Layer. When Draw is called on a Layer which is showing, its items will appear on the screen. Layers begin showing by default.
Return
integer:
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 square
square:LoadFilledRectangle(200, 200)
Layer2D layer
layer:Add(square)
AddLayer(layer)
layer:Hide()
// Since layers are visible by default, it's only necessary to Show
// them after they've been hidden.
layer:Show()
end
action Update(number seconds)
end
end
GetViewportX()
This action sets the viewport that will be used by this Layer. Anything drawn on this Layer will appear in a rectangle that begins x pixels from the left side of the screen, y pixels from the bottom, and has the given width and height in pixels.
Return
integer:
GetViewportY()
This action will return if the current layer is currently visible or not. Layers which are showing will be drawn on the screen automatically by the Game class. Layers begin showing by default.
Return
integer:
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 square
square:LoadFilledRectangle(200, 200)
Layer2D layer
layer:Add(square)
AddLayer(layer)
boolean showing = layer:IsShowing()
output "layer:IsShowing() returned " + showing
layer:Hide()
showing = layer:IsShowing()
output "After calling Hide(), IsShowing() returned " + showing
end
action Update(number seconds)
end
end
Hide()
This action will hide the Layer. This will prevent the Layer from appearing when asked to draw.
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 square
square:LoadFilledRectangle(200, 200)
Layer2D layer
layer:Add(square)
AddLayer(layer)
layer:Hide()
end
action Update(number seconds)
end
end
IsGridCoordinate(number value)
Returns true if the number passed would lie on the grid of this layer, false otherwise.
Parameters
- number value
Return
boolean: True if the number is on the grid, false otherwise.
IsGridSnapping()
Returns true if this layer snaps items to a grid while editing, false otherwise.
Return
boolean: True if snapping, false otherwise.
IsShowing()
This action will return if the current layer is currently visible or not. Layers which are showing will be drawn on the screen automatically by the Game class. Layers begin showing by default.
Return
boolean:
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 square
square:LoadFilledRectangle(200, 200)
Layer2D layer
layer:Add(square)
AddLayer(layer)
boolean showing = layer:IsShowing()
output "layer:IsShowing() returned " + showing
layer:Hide()
showing = layer:IsShowing()
output "After calling Hide(), IsShowing() returned " + showing
end
action Update(number seconds)
end
end
LostSelection()
Internal action that hides the components of the editor when this layer is deselected.
PhysicsEnabled()
This action sets if the Layer should 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:
ProcessGestureEvent(Libraries.Interface.Events.GestureEvent event)
This action will notify gesture listeners that are a part of this layer of the given gesture event. This is called automatically by the Game engine as needed. Most users will never need to use this action directly.
Parameters
- Libraries.Interface.Events.GestureEvent: The TouchEvent to send to the TouchListeners.
Return
ProcessMouseEvent(Libraries.Interface.Events.MouseEvent event)
This action will notify mouse listeners that are a part of this layer of the given mouse event. This is called automatically by the Game engine as needed. Most users will never need to use this action directly.
Parameters
- Libraries.Interface.Events.MouseEvent: The MouseEvent to send to the MouseListeners.
Return
Libraries.Interface.Item: The Item which intercepted the event, or undefined if no Item received the event.
ProcessTouchEvent(Libraries.Interface.Events.TouchEvent event)
This action will notify touch listeners that are a part of this layer of the given touch event. This is called automatically by the Game engine as needed. Most users will never need to use this action directly.
Parameters
- Libraries.Interface.Events.TouchEvent: The TouchEvent to send to the TouchListeners.
Return
RemoveMouseListener(Libraries.Interface.Events.MouseListener listener)
This action will remove a MouseListener from the layer. The listener will no longer receive events from the layer. If the given MouseListener is not on the layer before calling this action, then this action will have no effect.
Parameters
- Libraries.Interface.Events.MouseListener: The MouseListener to remove from this 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:RemoveMouseListener(listener)
end
action Update(number seconds)
end
end
RemoveMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)
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.
Parameters
- Libraries.Interface.Events.MouseMovementListener: The MouseMovementListener to remove from this 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:RemoveMouseMovementListener(listener)
end
action Update(number seconds)
end
end
RemoveMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)
This action will remove a MouseWheelListener from the layer. The listener will no longer receive events from the layer. If the given MouseWheelListener is not on the layer before calling this action, then this action will have no effect.
Parameters
- Libraries.Interface.Events.MouseWheelListener: The MouseWheelListener to remove from this 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:RemoveMouseWheelListener(listener)
end
action Update(number seconds)
end
end
RemoveTouchListener(Libraries.Interface.Events.TouchListener listener)
This action will remove a TouchListener from the layer. The listener will no longer receive events from the layer. If the given TouchListener is not on the layer before calling this action, then this action will have no effect.
Parameters
- Libraries.Interface.Events.TouchListener: The TouchListener to remove from this 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:RemoveTouchListener(listener)
end
action Update(number seconds)
end
end
Resize(Libraries.Interface.Events.ResizeEvent event)
This action will resize the Layer to match the dimensions of the provided ResizeEvent. This action is called automatically by the Game engine if the GetAutomaticResizing() value returns true. Users should not typically need to call this action directly.
Parameters
SetAutomaticResizing(boolean resizing)
This action sets if the Layer should 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.
Parameters
- boolean resizing
SetCamera(Libraries.Game.Graphics.Camera camera)
This action will set 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.
Parameters
- Libraries.Game.Graphics.Camera: The camera that this layer should use.
Example
use Libraries.Game.Game
use Libraries.Game.Layer2D
use Libraries.Game.Graphics.OrthographicCamera
class Main is Game
action Main
StartGame()
end
action CreateGame
OrthographicCamera camera
Layer2D layer
layer:SetCamera(camera)
AddLayer(layer)
end
action Update(number seconds)
end
end
SetCameraPitch(number pitch)
The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using pitch angles. All angles are in degrees. The pitch describes how far the camera is angled up or down. The pitch value should typically be between -90 and 90 degrees. Larger values will cause the camera to look in the opposite direction specified by the yaw value. For pitch values between -90 and 90, positive values angle the camera upwards, and negative values angle it downwards.
Parameters
- number pitch: The pitch angle, measured in degrees.
SetCameraRoll(number roll)
The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using roll angles. All angles are in degrees. The roll describes how the top of the camera is oriented. A roll value of 0 will angle the camera so the top of the camera points upward, towards the positive Y axis. A positive roll value "twists" the camera clockwise, and a negative value will twist it counter-clockwise.
Parameters
- number roll: The roll angle, measured in degrees.
SetCameraYaw(number yaw)
The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using yaw angles. All angles are in degrees. The yaw describes how far the camera is rotated along the X/Z axis. It effectively controls how the camera turns left and right. A positive value will rotate the camera clockwise (typically to the right).
Parameters
- number yaw: The yaw angle, measured in degrees.
SetCameraYawPitchRoll(number yaw, number pitch, number roll)
The SetCameraYawPitchRoll action sets the direction and orientation of the Camera using yaw, pitch, and roll angles. All angles are in degrees. The yaw describes how far the camera is rotated along the X/Z axis. It effectively controls how the camera turns left and right. A positive value will rotate the camera clockwise (typically to the right). The pitch describes how far the camera is angled up or down. The pitch value should typically be between -90 and 90 degrees. Larger values will cause the camera to look in the opposite direction specified by the yaw value. For pitch values between -90 and 90, positive values angle the camera upwards, and negative values angle it downwards. The roll describes how the top of the camera is oriented. A roll value of 0 will angle the camera so the top of the camera points upward, towards the positive Y axis. A positive roll value "twists" the camera clockwise, and a negative value will twist it counter-clockwise.
Parameters
- number yaw: The yaw angle, measured in degrees.
- number pitch: The pitch angle, measured in degrees.
- number roll: The roll angle, measured in degrees.
SetGridSnapping(boolean enabled)
This action changes whether the EditorLayer should try to snap newly added objects along the editor’s grid. If true grid snapping will be turned on, false will turn off grid snapping. Snapping to a grid means an object's position will line up exactly with points that are on the grid.
Parameters
- boolean enabled: If true grid snapping will be turned on, if false it will be turned off
SetGridUnitSize(number units)
This action takes a number and sets the size of a single unit of the grid. For example, passing 40.0 to this action on a 2D grid will make the grid consist of 40 by 40-pixel squares.
Parameters
- number units: A length that will be used for the new grid size.
SetName(text name)
This action sets the name of the Layer. This is used to identify the layer, especially in the Scene system.
Parameters
- text name
SetSceneEditor(Libraries.Interface.Controls.Scenes.SceneEditor editor)
Sets the SceneEditor object that this layer is a part of.
Parameters
- Libraries.Interface.Controls.Scenes.SceneEditor: The SceneEditor this layer is attached to
SetViewport(integer x, integer y, integer width, integer height)
This action sets the viewport that will be used by this Layer. Anything drawn on this Layer will appear in a rectangle that begins x pixels from the left side of the screen, y pixels from the bottom, and has the given width and height in pixels.
Parameters
- integer x
- integer y
- integer width
- integer height
SetViewportAndCamera(integer x, integer y, integer width, integer height)
This actions sets the viewport that will be used by this Layer, and adjusts the Layer's camera to match the dimensions of the viewport.
Parameters
- integer x
- integer y
- integer width
- integer height
Show()
This action will show the Layer. When Draw is called on a Layer which is showing, its items will appear on the screen. Layers begin showing by default.
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 square
square:LoadFilledRectangle(200, 200)
Layer2D layer
layer:Add(square)
AddLayer(layer)
layer:Hide()
// Since layers are visible by default, it's only necessary to Show
// them after they've been hidden.
layer:Show()
end
action Update(number seconds)
end
end
ShowCursor(boolean visible)
Shows or hides the cursor based on the passed parameter.
Parameters
- boolean visible: If true the cursor will be shown, hidden otherwise.
ShowEditorComponents(boolean shouldShow)
If true is passed to this action than the components of the editor such as the grid and cursor are shown. They are hidden if false is passed.
Parameters
- boolean shouldShow: Boolean dictating whether the components should be shown.
Update(number seconds)
This action will update all of the items contained within this Layer. The given number of seconds will be passed to each updated item. This is automatically called by the Game class as needed. Most users will never need to use this action directly.
Parameters
- number seconds
On this page
Variables TableAction Documentation- AddMouseListener(Libraries.Interface.Events.MouseListener listener)
- AddMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)
- AddMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)
- AddTouchListener(Libraries.Interface.Events.TouchListener listener)
- Compare(Libraries.Language.Object object)
- Draw()
- EnablePhysics(boolean flag)
- Equals(Libraries.Language.Object object)
- GainedSelection()
- GetAutomaticResizing()
- GetCamera()
- GetCameraPitch()
- GetCameraRoll()
- GetCameraYaw()
- GetCameraYawPitchRoll()
- GetCursor()
- GetGridUnitSize()
- GetHashCode()
- GetItemWithInput(number x, number y, Libraries.Containers.Array
inputValues) - GetName()
- GetNearestGridCoordinate(number coordinate)
- GetNextGridCoordinate(number coordinate)
- GetPreviousGridCoordinate(number coordinate)
- GetSceneEditor()
- GetViewportHeight()
- GetViewportWidth()
- GetViewportX()
- GetViewportY()
- Hide()
- IsGridCoordinate(number value)
- IsGridSnapping()
- IsShowing()
- LostSelection()
- PhysicsEnabled()
- ProcessGestureEvent(Libraries.Interface.Events.GestureEvent event)
- ProcessMouseEvent(Libraries.Interface.Events.MouseEvent event)
- ProcessTouchEvent(Libraries.Interface.Events.TouchEvent event)
- RemoveMouseListener(Libraries.Interface.Events.MouseListener listener)
- RemoveMouseMovementListener(Libraries.Interface.Events.MouseMovementListener listener)
- RemoveMouseWheelListener(Libraries.Interface.Events.MouseWheelListener listener)
- RemoveTouchListener(Libraries.Interface.Events.TouchListener listener)
- Resize(Libraries.Interface.Events.ResizeEvent event)
- SetAutomaticResizing(boolean resizing)
- SetCamera(Libraries.Game.Graphics.Camera camera)
- SetCameraPitch(number pitch)
- SetCameraRoll(number roll)
- SetCameraYaw(number yaw)
- SetCameraYawPitchRoll(number yaw, number pitch, number roll)
- SetGridSnapping(boolean enabled)
- SetGridUnitSize(number units)
- SetName(text name)
- SetSceneEditor(Libraries.Interface.Controls.Scenes.SceneEditor editor)
- SetViewport(integer x, integer y, integer width, integer height)
- SetViewportAndCamera(integer x, integer y, integer width, integer height)
- Show()
- ShowCursor(boolean visible)
- ShowEditorComponents(boolean shouldShow)
- Update(number seconds)