zerk.game.engine.system.viewport Class
Viewport System
Provides the interface for visualization.
Item Index
Methods
- _debugDrawGrid
- _getCanvasX
- _getCanvasY
- _getConfigDefaults
- _getEntitiesInViewport
- _getSystem
- _log
- _renderWorldCenterIndicator
- _setViewPosition
- addEntity
- fireEvent
- fromScaleX
- fromScaleY
- 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
Properties
- _config
- _engine
- _entities
- _eventListeners
- _fps
- _fpsCounter
- _fpsSecond
- _frameCount
- _height
- _name
- _offsetX deprecated
- _offsetY deprecated
- _priority
- _thread
- _timer
- _width
- _x
- _y
- _zoom
Methods
_debugDrawGrid
()
protected
Renders the grid
_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:
_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
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:
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
_config
Object
protected
System configuration
_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