add

add engine2d assets to the scene

virtuosity.engine2d.add

Methods


Methods

image

adds an image to the scene

virtuosity.engine2d.add.image(canvas, id, x, y, key, onComplete);


Parameter Type Description
canvas String Name of the canvas to add to
id String unique id of the image
x Number x position of the image
y Number y position of the image
key String id of the image asset to use
onComplete Function function to run after adding the image (takes the newly create image as a parameter)

sprite

adds a sprite to the scene

virtuosity.engine2d.add.sprite(canvas, id, x, y, key, onComplete);


Parameter Type Description
canvas String Name of the canvas to add to
id String unique id of the sprite
x Number x position of the sprite
y Number y position of the sprite
key String id of the sprite asset to use
onComplete Function function to run after adding the sprite (takes the newly create sprite as a parameter)

text

adds text to the scene

virtuosity.engine2d.add.text(canvas, id, x, y, text, fontSize, onComplete);


Parameter Type Description
canvas String Name of the canvas to add to
id String unique id of the text
x Number x position of the text
y Number y position of the text
text String the text for the text object to show
fontSize Int font size of the text
onComplete Function function to run after adding the text (takes the newly create text as a parameter)

htmltext

adds text that can use HTML and CSS styling to the scene

virtuosity.engine2d.add.htmltext(canvas, id, x, y, text, fontSize, onComplete);


Parameter Type Description
canvas String Name of the canvas to add to
id String unique id of the text
x Number x position of the text
y Number y position of the text
text String the text for the text object to show
fontSize Int font size of the text
onComplete Function function to run after adding the text (takes the newly create text as a parameter)

textbox

adds a textbox to the scene

virtuosity.engine2d.add.textbox(canvas, id, x, y, onComplete);


Parameter Type Description
canvas String Name of the canvas to add to
id String unique id of the html element
x Number x position of the html element
y Number y position of the html element
onComplete Function function to run after adding the textbox (takes the newly create textbox as a parameter)