flixel
flixel copied to clipboard
Implementing an IFlxSkew interface instead of it being a separate class packaged in flixel-addons
Hello. I'm writing this issue to here as suggested on Discord. My friend had suggested this idea before when I was writing code for a project that needed skewing for the text specifically and then had made an FlxSkewedText class. This class would just be the exact same as the FlxScrewedSprite class but different being it's the same code used with FlxText. This code works since FlxText extends from the FlxSprite class.
Carrying on from this, I feel it'd be better to have an interface for skewing sprites that all flixel sprite classes (FlxText, FlxSprite, etc.) implement from so you wouldn't need this. This'd work espeically incase you'd need to handling how skewing works on a sprite differently than another sprite. Another benefit to this is if you wouldn't need to copypaste said skewing code from one project to another because this would be a global flixel changed they already come with.
I'm skeptical, interfaces don't allow you to attach the same behavior to classes, they are just a list of functions a type should have. I would love a way to skew sprites without extending FlxSkewedSprite, but I imagine that would mean having some SpriteSkewer that takes a FlxSprite rather than extending.
But if you have an implementation of your idea I'd like to see it
There is a way to use macros with an interface to add variables and functions to a class, like the Draggable interface in HaxeUI: https://github.com/haxeui/haxeui-core/blob/91ed8d7867c52af5ea2a9513204057d69ab33c8e/haxe/ui/extensions/Draggable.hx#L4C12-L4C12 https://github.com/haxeui/haxeui-core/blob/91ed8d7867c52af5ea2a9513204057d69ab33c8e/haxe/ui/macros/extensions/DraggableBuilder.hx I'm not sure if this is what they meant though.
I'm skeptical, interfaces don't allow you to attach the same behavior to classes, they are just a list of functions a type should have. I would love a way to skew sprites without extending FlxSkewedSprite, but I imagine that would mean having some SpriteSkewer that takes a FlxSprite rather than extending.
But if you have an implementation of your idea I'd like to see it
I'll try and see if I can make a change to this, will do a PR and send it here if I do end up doing one.