Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component doesn't exist through entity.exists() #27

Open
DleanJeans opened this issue Dec 14, 2016 · 0 comments
Open

Component doesn't exist through entity.exists() #27

DleanJeans opened this issue Dec 14, 2016 · 0 comments

Comments

@DleanJeans
Copy link

DleanJeans commented Dec 14, 2016

Hi, I'm using Edge with HaxeFlixel. And I use FlxSprite as a IComponent.
This should reproduce the problem:

var sprite = new FlxSprite();
var entity = engine.create([sprite]);
trace(entity.exists(sprite)); // false

Why?
FlxSprite extends FlxObject and FlxObject extends FlxBasic, thus the key for FlxSprite is flixel.FlxBasic.
But exists() uses Type.getClass() on FlxSprite and it returns flixel.FlxSprite, of course. Hence false.
This is kinda a design problem, I guess.

In the mean time, I'll just replace this in the Entity class:

  function key(component : {}) {
    var t : Class<Dynamic> = Type.getClass(component),
        s = Type.getSuperClass(t);
    while(s != null && s != edge.IComponent) {
      t = s;
      s = Type.getSuperClass(t);
    }
    return Type.getClassName(t);
  }

with this:

  function key(component : {}) {
    return Type.getClassName(Type.getClass(component));
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant