engine2d

engine2d manages all of the graphics rendered in 2D. It uses Pixi 5.3.7 for rendering. engine2d uses Pixi.js as a base and builds off of it to automatically interact with the rest of the engine, as well as adding custom functions for added features and ease of use for the already existing ones.

virtuosity.engine2d

Classes

Objects

Methods


Classes

Image*

An image using a loaded texture created by add.image

Sprite*

An sprite using a loaded srpite texture created by add.sprite

Text*

A text entity created by add.text

htmltext*

A htmltext entity created by add.htmltext

Textbox*

A textbox entity created by add.textbox



Objects

load

adds an asset to the load queue

virtuosity.engine2d.load

add

add engine2d assets to the scene

virtuosity.engine2d.add

get

get engine2d assets

virtuosity.engine2d.get

delete

delete engine2d assets

virtuosity.engine2d.delete

performance

get statistics on the performance

virtuosity.engine2d.performance

graphics

procedural graphics

virtuosity.engine2d.graphics

update

update function

virtuosity.engine2d.update

render

render function

virtuosity.engine2d.render

canvas

properties of a canvas

virtuosity.engine2d.canvas

stage

(ALPHA) Creating and managing stages for easier, engine managed transitions

virtuosity.engine2d.stage


Methods

newCanvas

creates a new engine 2d canvas

virtuosity.engine2d.newCanvas(id, config);


Parameter Type Description
id String unique id of the canvas
config Object options to configure the canvas

newCanvas > config

Properties to configure the canvas. All properties are optional.



Parameter Type Description Default
resolution Int height resolution of the canvas actual client screen resolution
defaultResolution Int sets the resolution for auto scaling. Common practise is to use the screen resolution used in development actual client screen resolution
x Int x position of the canvas 0
y Int y position of the canvas 0
width Int width of the canvas window actual width
height Int height of the canvas window actual height
powerPreference String chooses which GPU to run on if client has multiple. 'low-power' for dedicated GPU or 'high-performance' for Discrete GPU 'low-power'
antialias Boolean whether to use antialiasing true
poll Int Polling rate of the update function. The update function will run this many times per second 64
fpsBuffer Int sets the maximum samples used to calculate average FPS 1000
preload Function function to run when loading assets. Assets can be loaded and unloaded later if you want, but main assets should be loaded here.
create Function function to run while creating the scene
update Function update function which runs at a constant polling rate set by the poll property
render Function render function which runs as fast as possible and is tied to framerate

unload

unload an image asset from cache

virtuosity.engine2d.unload(key);


Parameter Type Description
key String unique id of the image asset

beginLoading

begin loading (automatiacally run at the end of the the canvas's preload function)

virtuosity.engine2d.beginLoading();

expose

interact with the Pixi.js render engine directly

virtuosity.engine2d.expose();