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.
An image using a loaded texture created by add.image
An sprite using a loaded srpite texture created by add.sprite
A text entity created by add.text
A htmltext entity created by add.htmltext
A textbox entity created by add.textbox
adds an asset to the load queue
add engine2d assets to the scene
get engine2d assets
delete engine2d assets
get statistics on the performance
procedural graphics
update function
render function
properties of a canvas
(ALPHA) Creating and managing stages for easier, engine managed transitions
creates a new engine 2d canvas
Parameter | Type | Description |
---|---|---|
id | String | unique id of the canvas |
config | Object | options to configure the canvas |
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 an image asset from cache
Parameter | Type | Description |
---|---|---|
key | String | unique id of the image asset |
begin loading (automatiacally run at the end of the the canvas's preload function)
interact with the Pixi.js render engine directly