-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FlxButton labelOffset
s aren't updating the label's position.
#3229
Comments
This isn't happening for me. Here's my test: package states;
import flixel.FlxG;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.ui.FlxButton;
class ButtonLabelOffsettestState extends flixel.FlxState
{
override function create()
{
super.create();
final button1 = new FlxButton(20, 10, "Button", ()->trace("clicked button1"));
button1.labelAlphas = [0.7, 1.0, 0.8, 0.8];
button1.labelOffsets[0].x += 10;
button1.labelOffsets[1].x += 15;
button1.labelOffsets[2].x += 20;
button1.alpha = 0;
add(button1);
FlxTween.tween(button1, {alpha: 1, x: 10}, 1);
final y = button1.y + button1.height + 10;
final button2 = new FlxButton(10, y, "Button", ()->trace("clicked button2"));
button2.labelAlphas = [0.7, 1.0, 0.8, 0.8];
button2.labelOffsets[0].x += 10;
button2.labelOffsets[1].x += 15;
button2.labelOffsets[2].x += 20;
add(button2);
}
} And here's what I see Screen.Recording.2024-08-13.at.4.26.21.PM.movTry this out and let me know if you see different behavior. Your above test references a bunch of custom external code, So for all I know that may be the culprit for the behavior you're seeing. I always recommend making a new project that only tests the specific feature you think has a bug, rather than just sharing a snippet from your personal game project, so we know whether it's a flixel bug, or a bug with your code Also, if you're using PsychEngine it may be shadowing classes, in which case there's nothing I can do for you and you'll need them to fix it |
tried adding in all the same properties you change, in case one of those is causing the issue, still not able to reproduce it: package states;
import flixel.FlxG;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import flixel.ui.FlxButton;
class ButtonLabelOffsetTestState extends flixel.FlxState
{
override function create()
{
super.create();
final button1 = new FlxButton(20, 10, "Button", ()->trace("clicked button1."));
button1.onOver.callback = ()->trace("clicked button1");
button1.scale.set(2, 2);
button1.updateHitbox();
button1.blend = SCREEN;
button1.antialiasing = false;
button1.label.antialiasing = false;
button1.label.letterSpacing = -3;
button1.label.fieldWidth = button1.width;
button1.label.fieldHeight = button1.height;
button1.label.setFormat('Helvetica', 16, 0xFFFFFFFF);
button1.label.text = "_" + button1.label.text + "_";
button1.labelAlphas = [0.7, 1.0, 0.8, 0.8];
button1.labelOffsets[0].x += 10;
button1.labelOffsets[1].x += 15;
button1.labelOffsets[2].x += 20;
button1.alpha = 0;
add(button1);
FlxTween.tween(button1, {alpha: 1, x: 10}, 1);
final y = button1.y + button1.height + 10;
final button2 = new FlxButton(10, y, "Button", ()->trace("clicked button2."));
button2.onOver.callback = ()->trace("clicked button2");
button2.scale.set(2, 2);
button2.updateHitbox();
button2.blend = SCREEN;
button2.antialiasing = false;
button2.label.antialiasing = false;
button2.label.letterSpacing = -3;
button2.label.fieldWidth = button2.width;
button2.label.fieldHeight = button2.height;
button2.label.setFormat('Helvetica', 16, 0xFFFFFFFF);
button2.label.text = "_" + button2.label.text + "_";
button2.labelAlphas = [0.7, 1.0, 0.8, 0.8];
button2.labelOffsets[0].x += 10;
button2.labelOffsets[1].x += 15;
button2.labelOffsets[2].x += 20;
add(button2);
}
} Note: you may need to switch "Helvetica" to "Arial" if you're on windows Also Note: scrollFactor defaults to (0, 0) on all UI elements |
Thanks Geokureli! I should probably stick to convention and do that myself when testing against the rest of my game's codebase, but your willingness to help with so little context was much appreciated. (they were a group of sprites at one point) It turns out that the culprit behind the buttons was the This rises a new question. Wouldn't a hybrid approach where the label's position is also updated on state change be better, especially when moves is false? This sounds like a good and harmless patch. Once again, thanks for the continued support for base flixel's UI elements while haxeui takes over! |
Code snippet reproducing the issue:
Observed behavior:
The highlight offsets are applied to the first label once, and further interactions have no impact on them.
button.offsets.not.working.mp4
Expected behavior:
The buttons' labels are offset whenever their states are changed.
The text was updated successfully, but these errors were encountered: