Drawing in Haxepunk?

  • Hello again!

    Does HaxePunk have some sort of drawing API, similar to OpenFL? I imported one of my old HaxePunk files and noticed some of the features I was using in the Draw util have been taken out (I assume since Draw was only meant to be used for debugging purposes), so is there another way to draw lines and such?

    Follow up question: if not, is there a reference to the base OpenFL sprite so I can use the OpenFL drawing API? 😛

  • administrators

    Draw is no longer just for debugging, you can use it as part of a Graphic's render method and it'll work fine. It's an officially supported way to hook into our rendering code. Drawing lines should work fine, and if you need more than what's in the API, please reach out.

    There's not an official or straightforward way to use OpenFL's Sprite drawing methods on top of HaxePunk. They probably don't make any guarantees about raw OpenGL and DisplayList interaction so I imagine you're going to run into challenges and inconsistencies across targets. If you do want to experiment, HXP.app is an OpenFL Sprite when you're using the OpenFL backend... good luck! If we can support what you want to do in HaxePunk itself though, that would be the ideal.

  • Oh okay cool! Is there any way to draw into an Image? The way I did it before (make a new bitmap data, Draw.setTarget(bitmapData), initialize Image with bitmap data) doesn't seem to be supported now, Draw.setTarget is missing and HXP.createBitmap is missing.

  • administrators

    There's not a way to use Draw on a BitmapData anymore, but if you create a BitmapData (using OpenFL, not HXP) and draw whatever you want on it using OpenFL's APIs, you can pass that to the Image constructor. (Initializing an image using a BitmapData does still work.)

Log in to reply

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.