Class
RenderableEntity
open class RenderableEntity : IdentifiableObject
A RenderableEntity
provides the majority of rendering and interactive
functionality by overriding the required methods and working with the
Dispatcher
to register events of intrest.
Relationships
Superclass
IdentifiableObject
IdentifiableObject
provides base functionality for using unique names that are useful for debugging.
Subclasses
ContainableRenderableEntity
A
ContainableRenderableEntity
is used for subclassing entities which may be contained in aRenderableEntityContainer
. Descendant classes must:
Types Conforming to RenderableEntity
EntityMouseClickHandler
A type conforming to
EntityMouseClickHandler
is capable of receiving entity mouse click events through the onEntityMouseClick method.EntityMouseDownHandler
A type conforming to
EntityMouseDownHandler
is capable of receiving entity mouse down events through the onEntityMouseDown method.EntityMouseDragHandler
A type conforming to
EntityMouseDragHandler
is capable of receiving entity mouse drag events through the onEntityMouseDrag method.EntityMouseEnterHandler
A type conforming to
EntityMouseEnterHandler
is capable of receiving entity mouse enter events through the onEntityMouseEnter method.EntityMouseLeaveHandler
A type conforming to
EntityMouseLeaveHandler
is capable of receiving entity mouse leave events through the onEntityMouseLeave method.EntityMouseUpHandler
A type conforming to
EntityMouseUpHandler
is capable of receiving entity mouse up events through the onEntityMouseUp method.
Initializers
init(name:)
public override init(name:String?=nil)
Creates a new RenderableEntity
from the given paramenters:
Parameters
Name | Type | Description |
---|---|---|
name | String? |
The unique name of the renderable entity. While it's very useful for debugging purposes to provide a meaningful name, it's not required. |
Properties
owningLayer
public private(set) weak var owningLayer : Layer?
layer
public var layer : Layer
The owning layer for this entity.
scene
public var scene : Scene
The owning scene for this entity.
director
public var director : Director
The owning director for this entity.
dispatcher
public var dispatcher : Dispatcher
The event dispatcher for this entities owning director.
Methods
local(fromGlobal:)
public func local(fromGlobal:Point) -> Point
Translated the specified global point from global space to this entities space.
global(fromLocal:)
public func global(fromLocal:Point) -> Point
Translates the specified local point from this entities space to global space.
setTransforms(transforms:)
public func setTransforms(transforms:[Transform]?)
Sets the transforms to be applied to this entity. This function should only be invoked during init(), setup(), or calculate().
setAlpha(alpha:)
public func setAlpha(alpha:Alpha?)
Sets the alpha component for this entity. This function should only be invoked during init(), setup(), or calculate().
setClipPath(clipPath:)
public func setClipPath(clipPath:ClipPath?)
Sets the clip path for this entity. This function should only be invoked during init(), setup(), or calculate().
applyTransforms(toPoint:transforms:)
public func applyTransforms(toPoint:Point, transforms:[Transform]? = nil) -> Point
Applies specified or current transforms to the specified point If no transforms are current, returns the original point
applyTransforms(toPoints:transforms:)
public func applyTransforms(toPoints:[Point], transforms:[Transform]? = nil) -> [Point]
Applies specified or current transforms to the specified points If no transforms are current, returns the original points
setup(canvasSize:canvas:)
open func setup(canvasSize:Size, canvas:Canvas)
setup() is invoked exactly once, either when the owning layer is first set up or, if the layer has already been setup, prior to the next calculate event.
teardown()
open func teardown()
teardown() is invoked exactly once when the scene is torndown prior to a transition. This is the appropriate location to unregister event handlers.
calculate(canvasSize:)
open func calculate(canvasSize:Size)
calculate() is invoked once per frame prior to each render event.
render(canvas:)
open func render(canvas:Canvas)
render() is invoked once per frame during each render cycle.
boundingRect()
open func boundingRect() -> Rect
This function is invoked to determine the boundingRect of the entity, in global coordinates. This should be over-ridden by inheriting types.
hitTest(globalLocation:)
open func hitTest(globalLocation:Point) -> Bool
Performs a hit test between this entities boundingRect()
and a global point.
Returns true if the specified point is contained within the bounding rect.
isMouseTransparent()
open func isMouseTransparent() -> Bool
This function is invoked to determine whether or not an entity is transparent to entity mouse events. If true, the entity will not intercept such events.
isVisible()
open func isVisible() -> Bool
This function is invoked to determine whether or not an entity is visible. If false, the render phase for this entity will be skipped and the render method will not be invoked.