Stage


Inheritance Stage Container View Module hilo/view/Stage Requires hilo/core/Hilo, hilo/core/Class, hilo/view/Container, hilo/renderer/CanvasRenderer, hilo/renderer/DOMRenderer, hilo/renderer/WebGLRenderer Source Stage.js
Stage is the root of all visual object tree, any visual object will be render only after being added to Stage or any children elements of Stage. Normally, every hilo application start with an stage instance.

Properties

Show Inherited Properties
Property Defined
canvas:HTMLCanvasElement|HTMLElement
The canvas the Stage is related to.
Stage
paused:Boolean
Paused Stage rendering.
Stage
renderer:Renderer
Stage renderer, readonly!
Stage
viewport:Object
Rendering area of the Stage.
Stage

Methods

Show Inherited Methods
Method Defined
Stage(properties:Object)
Constructor
Stage
addTo(domElement:HTMLElement):Stage
Stage
enableDOMEvent(type:String|Array, enabled:Boolean):Stage
Stage
resize(width:Number, height:Number, forceResize:Boolean)
Stage
tick(delta:Number)
Stage
updateViewport():Object
Stage

Property Detail

canvas:HTMLCanvasElement|HTMLElement
The canvas the Stage is related to. It can be a canvas or a div element, readonly!
paused:Boolean
Paused Stage rendering.
renderer:Renderer
Stage renderer, readonly!
viewport:Object
Rendering area of the Stage. Including properties like: left, top, width, height. readonly!

Constructor

Stage(properties:Object)
parameters
properties:Object — Properties parameters for the object. Includes all writable properties of this class. Some important like:
  • container:String|HTMLElement - Assign the parent container element of the Stage in the page. It should be a dom container or an id. If this parameter is not given and canvas isn't in the dom tree, you should add the stage vanvas into the dom tree yourself, otherwise Stage will not render. optional.
  • renderType:String - Renering way: canvas|dom|webgl,default value is canvas, optional.
  • canvas:String|HTMLCanvasElement|HTMLElement - 指定舞台所对应的画布元素。它是一个canvas或普通的div,也可以传入元素的id。若为canvas,则使用canvas来渲染所有对象,否则使用dom+css来渲染。可选。
  • width:Number
  • - The width of the Stage, default value is the width of canvas, optional.
  • height:Number
  • - The height of the Stage, default value is the height of canvas, optional.
  • paused:Boolean
  • - Whether stop rendering the Stage, default value is false, optional.

Method Detail

addTo(domElement:HTMLElement):Stage
parameters
domElement:HTMLElement — An dom element.
return
Stage — The Stage Object, chained call supported.
enableDOMEvent(type:String|Array, enabled:Boolean):Stage
parameters
type:String|Array — The event name or array that need to turn on/off.
enabled:Boolean — Whether turn on or off the response method of stage DOM event. If not provided, default value is true.
return
Stage — The Stage Object, chained call supported.
resize(width:Number, height:Number, forceResize:Boolean)
parameters
width:Number — The width of the new Stage.
height:Number — The height of the new Stage.
forceResize:Boolean — Whether forced to resize the Stage, means no matter the size of the Stage, force to change the size to keep Stage, canvas and window act at the same time.
tick(delta:Number)
parameters
delta:Number — The time had pass between this tick invoke and last tick invoke.
updateViewport():Object
return
Object — The visible area of the Stage (the viewport property).