Scenes Documentation Beta

Class Renderable​Entity

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.

%89 RenderableEntity RenderableEntity IdentifiableObject IdentifiableObject RenderableEntity->IdentifiableObject EntityMouseEnterHandler EntityMouseEnterHandler EntityMouseEnterHandler->RenderableEntity EntityMouseDragHandler EntityMouseDragHandler EntityMouseDragHandler->RenderableEntity EntityMouseClickHandler EntityMouseClickHandler EntityMouseClickHandler->RenderableEntity EntityMouseDownHandler EntityMouseDownHandler EntityMouseDownHandler->RenderableEntity EntityMouseLeaveHandler EntityMouseLeaveHandler EntityMouseLeaveHandler->RenderableEntity EntityMouseUpHandler EntityMouseUpHandler EntityMouseUpHandler->RenderableEntity ContainableRenderableEntity ContainableRenderableEntity ContainableRenderableEntity->RenderableEntity

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 a RenderableEntityContainer. Descendant classes must:

Types Conforming to Renderable​Entity

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 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

owning​Layer

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(from​Global:​)

public func local(fromGlobal:Point) -> Point 

Translated the specified global point from global space to this entities space.

global(from​Local:​)

public func global(fromLocal:Point) -> Point 

Translates the specified local point from this entities space to global space.

set​Transforms(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().

set​Alpha(alpha:​)

public func setAlpha(alpha:Alpha?) 

Sets the alpha component for this entity. This function should only be invoked during init(), setup(), or calculate().

set​Clip​Path(clip​Path:​)

public func setClipPath(clipPath:ClipPath?) 

Sets the clip path for this entity. This function should only be invoked during init(), setup(), or calculate().

apply​Transforms(to​Point:​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

apply​Transforms(to​Points:​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(canvas​Size:​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(canvas​Size:​)

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.

bounding​Rect()

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.

hit​Test(global​Location:​)

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.

is​Mouse​Transparent()

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.

is​Visible()

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.