Is it possible to access an Entity from the World class?


(AnthonyY) #1

Can I access properties of an Entity such as the coordinates from the World class that adds the Entity?

Any help is appreciated! Thank you!


(Jacob Albano) #2
// in your World class

var e:Entity = new Entity();
e.x = 100;
e.y = -100;
add(e);
e.graphic = Image.createRect(50, 50, 0xff00ff);

Is that what you were referring to?


(reopucino) #3

you can also try this

//in world class

var e:entity = classFirst(yournameclass);
e.x = 10;
e.y = 20;

(Ssnyder Coder) #4

You can also do the following:

var entities:Array = new Array(); //will be populated with entities
world.getAll(entities);
world.getClass(Enemy, entities);
world.getLayer(1, entities);
world.getType("enemy", entities);
var bobEntity:Entity = world.getInstance("bob");