flixel icon indicating copy to clipboard operation
flixel copied to clipboard

FlxSpriteGroup issue

Open Joalor64GH opened this issue 1 year ago • 3 comments

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

Joalor64GH avatar May 07 '24 19:05 Joalor64GH

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

Geokureli avatar May 08 '24 21:05 Geokureli

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);
		}
	}

Joalor64GH avatar May 08 '24 21:05 Joalor64GH

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

Geokureli avatar May 09 '24 13:05 Geokureli