HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.93k stars 427 forks source link

FlxSpriteGroup issue #3133

Closed Joalor64GH closed 1 month ago

Joalor64GH commented 2 months ago

for some reason, when I change a keybind, the FlxSpriteGroup binds just does that (??) how do i keep it in place?

https://github.com/HaxeFlixel/flixel/assets/99079926/360f251f-7ff8-4f2e-90f3-96eee3ea06b7

Geokureli commented 1 month ago

hard to say what's happening without any code, even then you'll likely need to learn debugging techniques to figure this out for yourself. but post minimal relevant code here and we'll see if we can help

Joalor64GH commented 1 month ago
private function refreshControls() {
        kbBinds = [];
        gpBinds = [];

        for (i in 0...6) {
            kbBinds.push(SaveData.settings.keyboardBinds[i]);
            gpBinds.push(SaveData.settings.gamepadBinds[i]);
        }

        kbBinds.reverse();
        gpBinds.reverse();

        binds.forEachAlive((b) -> {
            remove(b);
            b.destroy();
        });

        remove(binds);
        add(binds);

        var bindPos = text1.x + 1150;

        for (bind in kbBinds) {
            var key = new KeyIcon(bindPos, text1.y + 150, bind);
            key.x -= key.iconWidth;
            bindPos -= key.iconWidth + 10;
            binds.add(key);
        }

        for (bind in gpBinds) {
            var control = new ControllerIcon(bindPos, text1.y + 250, bind);
            control.x -= control.iconWidth;
            bindPos -= control.iconWidth + 10;
            binds.add(control);
        }
    }
Geokureli commented 1 month ago

if you're setting the position of every member of binds, than I would use a FlxGroup rather than a FlxSpriteGroup, that said, i dont see anything immediately wrong, I would just check your math, and look for places that may be setting binds.x/y assuming thats the spritegroup you're referring to