GithubHelp home page GithubHelp logo

Interacting with EitherType about pixi-haxe HOT 5 CLOSED

pixijs avatar pixijs commented on August 24, 2024
Interacting with EitherType

from pixi-haxe.

Comments (5)

IkonOne avatar IkonOne commented on August 24, 2024

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.

from pixi-haxe.

IkonOne avatar IkonOne commented on August 24, 2024

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.

from pixi-haxe.

IkonOne avatar IkonOne commented on August 24, 2024

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.

from pixi-haxe.

IkonOne avatar IkonOne commented on August 24, 2024

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

from pixi-haxe.

modjke avatar modjke commented on August 24, 2024

Here ya go, mate :) #113

from pixi-haxe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.