Am I Idiot or is HaxeFlixel limited as hell ?
-
Hello,
Now that I got your attention, I'd like to ask some questions about how HaxeFlixel works. I'm trying to do some draggable GUI Windows here and everything works fine except FlxSpriteGroup. For example, I have a Item Class that extends FlxSpriteGroup and a ItemSlot Class that also extends FlxSpriteGroup.
The problem is the following : I'm trying to create a system that swaps the two items in the slots that are being swapped. Before swapping, If I drag around the window in which the slots are (let's call it the inventory window), everything works fine. But once i swapped the items, it looks like there's some random position that's being added to the Item Instance and it starts moving away. Really annoying because it happens everytime I .remove(Item) from SLOT A and I .add(Item) to slot B. Is it a way to handle this properly ? I don't think code is needed here because I tried some workarounds and still the same thing happens.
Here's some gif of what's happening, you'll see what happens once I swap the items.
!https://gyazo.com/5d06b0f72067308179923ef39df6d914It's not the first time I have to deal with the way HaxeFlixel renders a Sprite that's already been created. I don't wanna Create a new Instance of the Item Class everytime I swap slots... So, am I Idiot or is there something I might be doing wrong ?
This is some code that totally explains what I am doing :
var a:FlxSpriteGroup = new FlxSpriteGroup(); var b:FlxSprite = new FlxSprite(); var c:FlxSpriteGroup = new FlxSpriteGroup(); a.setPosition(0,0); // Setting a position to 0,0 b.setPosition(10,10); // Setting relative position to 10,10 a.add(b) trace(b.getPosition() == (10,10)) // True a.remove(b) c.add(b) // Adding b to c with relative position c.setPosition(10,10) trace(b.getPosition() == (20,20)); // False
Instead of handling relative positions correctly, it just doesn't.
-
@zekrose said in Am I Idiot or is HaxeFlixel limited as hell ?:
FlxSpriteGroup
checkout the FlxGroupSprite source in here
https://github.com/HaxeFlixel/flixel/blob/master/flixel/group/FlxSpriteGroup.hx
When removed from a, b's x and y are transformed by the a's x and y...
I hope you'll find some clues...