zerk.game.engine.system.viewport.canvas Class
Canvas Viewport System
Visualization implementation for HTML Canvas.
Item Index
Methods
- _createCanvas
- _debugDrawGrid
- _getCanvas deprecated
- _getCanvasX
- _getCanvasY
- _getConfigDefaults
- _getContext deprecated
- _getEntitiesInViewport
- _getSystem
- _log
- _renderWorldCenterIndicator
- _setViewPosition
- addEntity
- bufferClear
- bufferFlush
- bufferInit
- createBuffers deprecated
- drawArc
- drawLines
- drawPolygon
- drawRect
- drawText
- fillArc
- fillPolygon
- fillRect
- fireEvent
- fromScaleX
- fromScaleY
- getBufferSize
- getCanvasElement
- getCanvasPhysicsDebug
- getCanvasPosition
- getFPS
- getHeight
- getName
- getOffsetX deprecated
- getOffsetY deprecated
- getPriority
- getThread
- getWidth
- getX
- getY
- getZoom
- init
- on
- removeEntity
- reset
- setX
- setY
- start
- stop
- toScaleX
- toScaleY
- un
- update
- useComponent
- zoomIn
- zoomOut
Methods
_createCanvas
-
id
-
width
-
height
-
visible
Creates a canvas DOM element
Parameters:
-
id
StringDOM id
-
width
IntegerCanvas width
-
height
IntegerCanvas height
-
visible
BooleanCanvas visibility
Returns:
_debugDrawGrid
()
protected
Renders the grid
_getCanvas
-
PARAM_NAME
PROTECTEDMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
_getCanvasX
-
meter
-
pixel
Parameters:
-
meter
Float -
pixel
Integer
Returns:
_getCanvasY
-
meter
-
pixel
Parameters:
-
meter
Float -
pixel
Integer
Returns:
_getConfigDefaults
()
Object
protected
Returns the configuration defaults of the system
Returns:
_getContext
-
PARAM_NAME
PROTECTEDMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
_getEntitiesInViewport
()
Array
protected
Returns a list of all entities currently visible in the viewport
Returns:
_getSystem
-
name
Returns system by given name
This method is used to communicate with other systems.
Parameters:
-
name
StringSystem name
Returns:
_log
-
message
-
severity
Local log method
Parameters:
-
message
StringLog message
-
severity
IntegerLog severity
_renderWorldCenterIndicator
()
protected
Renders the world center indicator
_setViewPosition
-
x
-
y
Set the view position to a given world position
Parameters:
-
x
Float -
y
Float
bufferClear
-
buffer
Clear a buffer by given buffer id
Parameters:
-
buffer
StringBuffer id
bufferFlush
-
source
-
target
-
width
-
height
-
x
-
y
Flush a buffers content onto another buffer
Parameters:
-
source
StringSource buffer id
-
target
StringTarget buffer id
-
width
FloatTarget width
-
height
FloatTarget height
-
x
FloatTarget horizontal position
-
y
FloatTarget vertical position
bufferInit
-
buffer
-
width
-
height
-
x
-
y
-
angle
Initializes a buffer for drawing
Parameters:
-
buffer
StringBuffer id
-
width
FloatWidth
-
height
FloatHeight
-
x
FloatCenter x
-
y
FloatCenter y
-
angle
FloatAngle
createBuffers
-
buffers
Creates multiple buffers
Parameters:
-
buffers
ObjectA list of buffers to be created
drawArc
-
PARAM_NAME
PUBLICMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
drawLines
-
buffer
-
lines
-
color
-
lineWidth
Draw lines
Parameters:
-
buffer
StringBuffer id
-
lines
ObjectTwo dimensional array containing the lines
-
color
StringRGB color
-
lineWidth
FloatWidth of the lines
drawPolygon
-
PARAM_NAME
PUBLICMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
drawRect
-
PARAM_NAME
Draw a rectangle
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAM_DESCRIPTION
Returns:
drawText
-
PARAM_NAME
PUBLICMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
fillArc
-
PARAM_NAME
PUBLICMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
fillPolygon
-
PARAM_NAME
PUBLICMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
fillRect
-
PARAM_NAME
PUBLICMETHODDESCRIPTION
Parameters:
-
PARAM_NAME
Boolean | Integer | Float | String | Object | Array | Function | Mixed | Any | CLASS_NAMEPARAMDESCRIPTION SECONDLINE
Returns:
fireEvent
-
event
Fire event
Parameters:
-
event
StringEvent name
Returns:
fromScaleX
-
value
Un-scales given value by current zoom factor
Parameters:
-
value
FloatValue
Returns:
fromScaleY
-
value
Un-scales given value by current zoom factor
Parameters:
-
value
FloatValue
Returns:
getBufferSize
-
buffer
Returns the size of the buffer by given id
Parameters:
-
buffer
StringBuffer id
Returns:
getCanvasElement
-
buffer
Return a canvas element for given buffer id
Parameters:
-
buffer
StringBuffer id
Returns:
getCanvasPhysicsDebug
()
DOMElement
Returns the physics debug canvas DOM element
Returns:
getCanvasPosition
-
buffer
Returns a canvas position relative to its parent HTML document
Parameters:
-
buffer
StringBuffer id
Returns:
getFPS
()
Integer
Returns the current count of frames drawn per second
Returns:
getHeight
()
Returns the height of the viewport in pixels
Returns:
getName
()
String
Returns the name of the system
Returns:
getOffsetX
()
deprecated
Returns the horizontal view position in meters
Returns:
getOffsetY
()
deprecated
Returns the vertical view position in meters
Returns:
getPriority
()
Integer
Returns the priority of the system
Returns:
getThread
()
String
Returns the thread the systems runs in
Returns:
getWidth
()
Returns the width of the viewport in pixels
Returns:
getX
()
Returns the horizontal view position in pixels
Returns:
getY
()
Returns the vertical view position in pixels
Returns:
getZoom
()
Float
Return the current zoom factor
Returns:
init
-
engine
-
config
Class constructor
Parameters:
-
engine
zerk.game.engineGame engine
-
config
ObjectSystem configuration
on
-
event
-
callback
-
scope
Register event handler
Parameters:
-
event
StringEvent name
-
callback
FunctionCallback function. Return false to cancel event bubble.
-
scope
ObjectScope to be used in callback function
removeEntity
-
entity
Removes an entity from the system
Parameters:
-
entity
config.entityEntity state
reset
()
Reset the viewport
setX
()
Sets the horizontal view position in pixels
Returns:
setY
()
Sets the vertical view position in pixels
Returns:
start
()
Starts the system
stop
()
Stops the system
toScaleX
-
value
Scales given value by current zoom factor
Parameters:
-
value
FloatValue
Returns:
toScaleY
-
value
Scales given value by current zoom factor
Parameters:
-
value
FloatValue
Returns:
un
-
event
-
callback
Unregister event handler
Parameters:
-
event
StringEvent name
-
callback
FunctionCallback function
Returns:
update
()
Updates the system
useComponent
-
name
Returns true when the system is interested in given component
Parameters:
-
name
StringComponent name
Returns:
zoomIn
()
Increases current zoom factor by factor 10
zoomOut
()
Decreases current zoom factor by factor 10
Properties
_canvas
Object
protected
Register for canvas references
_config
Object
protected
System configuration
_context
Object
protected
Register for canvas context references
_entities
Array
protected
Entities register
Entities that this system is interested in.
_eventListeners
Array
protected
List of event handlers
_fps
Integer
protected
The number of rendered frames per second
_fpsCounter
Integer
protected
Counter used to calculate FPS
_fpsSecond
Integer
protected
Stores the second of the last FPS measuring
_frameCount
Integer
protected
The total number of frames rendered
_height
Integer
protected
Height of the viewport in pixels
_name
String
protected
Name of the system
_offsetX
Float
deprecated
protected
Horizontal view position in meters
_offsetY
Float
deprecated
protected
Vertical view position in meters
_priority
Integer
protected
Priority of this system
_thread
String
protected
Thread that runs this system
_timer
DOMTimer
protected
Rendering timer
_width
Integer
protected
Width of the viewport in pixels
_x
Float
protected
Horizontal view position in pixels
_y
Float
protected
Vertical view position in pixels
_zoom
Float
protected
Zoom factor