[SOLVED] JS code - create instances at runtime

Trying to figure out a way to instantiate instances of an object at runtime in a JS code block.

So for example in the editor i may have a sprite object called “testSprite” and in JS code I want to create an instance of it, with a reference variable that I can then manipulate its .setX() and .setY() parameters etc.

I can’t seem to find an example of this anywhere, any ideas ?

Ahh found it :slight_smile:

This example works, references the object from the editor by it’s name and instantiates it and puts it on the desired layer in the desired location;

var t=runtimeScene.createObject(“chipImage”);
t.setX(100);
t.setY(100);
t.setLayer(“chips”);