Open christopherghenderson opened 3 years ago
You might be going about it wrong? Here's what I use:
@:nodes var nodes:Node<Animation, Flag>;
if (node.animation.index < etc)
node.flag.set(etc)
@MSGhero is correct, you need to specify at least 1 component when defining your nodes
~~So instead of this:
@:nodes var nodes:Node;
~~
~~You need to do something like this:
@:nodes var nodes:Node<MyComponent>;
~~
*Edit - actually just tested it, and specifying no components (like @:nodes var nodes:Node;
) should actually work just fine, so the issue is lying elsewhere..
Are you sure your "Entity" class (from node.entity.components.get(Position).body.x;
) has it's components
field assigned correctly? For example:
class Entity {
public var components:Components;
public function new() {
// Make sure that the `components` field is assigned
components = new Components();
components.entity = this;
}
}
As a side note, all Node
instances have a reference to their relevant components
object. So you could just do this:
node.components.get(Position).body.x;
instead of:
node.entity.components.get(Position).body.x;
I'm trying to pull a component from an entity, however I'm receiving this error. Uncaught exception - Invalid field access : components
Iterating over entities in: @:nodes var nodes:Node;
I'm pulling the component using: node.entity.components.get(Position).body.x;