-
Notifications
You must be signed in to change notification settings - Fork 65
Interacting with EitherType #111
Comments
Hi, I figured it out: http://try.haxe.org/#e07B7 If there is a better method, I'm all ears, but this doesn't seem too bad. |
Actually, that doesn't work. In the proposed solution, I was using Type.getClass to get the class of the hitArea of an InteractiveTarget at runtime. Unfortunately, there is no type information for pixi classes at runtime so this will never work. |
OK. Here is a hacky working solution. Since I am trying to specifically access the InteractiveTarget.hitArea member, this works. Solution: http://try.haxe.org/#4f078 This shouldn't actually work but since pixi has a 'type' member in all of the Shape classes, I can take advantage of that. If there are any instances of using EitherType that don't have something like this, this method will likely fail. Because of this, I am going to leave the issue open as a better solution should be found. EitherType seems to be ok for function parameters, but when using it for variables, it renders the variables almost unusable without hacks. |
I'm closing this again. The above solution is not really as hacky as I originally thought. The pixi Shapes all have the 'type' member variable so that instanceof (Std.is in haxe) doesn't have to be used. While Std.is still works, casting the hitArea to a typedef with a 'type' member variable is an effective solution. For anyone curious, here is a try.haxe that illustrates what does and doesn't work with EitherType: http://try.haxe.org/#B0783 |
Here ya go, mate :) #113 |
There are multiple instances of EitherType being used. What would be the ideal method of retrieving the value of a variable that is of EitherType? I am specifically looking at the hitArea of an Interactive Target:
pixi-haxe/src/pixi/interaction/InteractiveTarget.hx
Line 236 in 99bf8cd
As far as I can tell at the moment, it is impossible? When using haxe.ds.Either, you can at least use a switch with Left and Right, but that doesn't work in this case.
Thank you for your guidance and work on this project.
The text was updated successfully, but these errors were encountered: