deltaluca / nape

Haxe/AS3 Physics Engine
http://napephys.com
Other
542 stars 77 forks source link

Accessing class members when assigned to Interactor.userData breaks on flash target #91

Closed matrefeytontias closed 9 years ago

matrefeytontias commented 9 years ago

Example, this works on every target:

body = new Body(BodyType.DYNAMIC);
body.userData.gravity = new Vec2(0, 10);
trace(body.userData.gravity.get_angle());

And this crashes only on Flash:

body = new Body(BodyType.DYNAMIC);
body.userData.gravity = new Vec2(0, 10);
trace(body.userData.gravity.angle);
deltaluca commented 9 years ago

Man, I need to figure out how to get github to filter better, only just saw this now.

This issue is not to do with Nape, but the semantics of property access on Dynamic objects, since userData is completely untyped userData.gravity is also untyped so property access works differently and must be done through Reflect.getProperty I believe.

Of course, the simpler way is to tell compiler what the (known to you) type is like: (body.userData.gravity : Vec2).angle

matrefeytontias commented 9 years ago

Alright then, I'll do that, thanks :)