-
Notifications
You must be signed in to change notification settings - Fork 453
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
FlxTextBorderStyle: Add SHADOW_XY, prevent border clipping #3236
Conversation
Code snippet reproducing the issue package;
import flixel.FlxState;
import flixel.text.FlxText;
class PlayState extends FlxState
{
override public function create()
{
super.create();
bgColor = 0xFF0000;
var text:FlxText = new FlxText();
text.text = "FlxText shadow clipping test lol";
text.size = 32;
text.screenCenter();
text.borderStyle = SHADOW;
text.shadowOffset.set(35, 35);
add(text);
}
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix doesn't work with the old deprecated method though.
I was able to fix it by just replacing like 879 and 880 with
var newWidthFloat:Float = textField.width;
var newHeightFloat:Float = _autoHeight ? textField.textHeight + VERTICAL_GUTTER : textField.height;
if (shadowOffset != null)
{
newWidthFloat += Math.ceil(Math.abs(_shadowOffset.x));
newHeightFloat += Math.ceil(Math.abs(_shadowOffset.y));
}
Thanks! truthfully I hadn't tested shadowOffset yet, but was planning to before merging, I'll try this Does the new SHADOW_CUSTOM work for your project's needs? |
TODO: fix isOnScreen when shadow is above or left |
Yes. Honestly though it seems to be like not a good solution. I feel like it would just be easier to keep the shadow style, then you can customize the offset to your liking, rather than having a whole other style for changing the offsets. |
Would it be possible to make |
No, I can change SHADOW to SHADOW(?x,?y) and make it possible to do SHADOW() with no args but that would break all previous usage of SHADOW
Why is it not a good solution? this is the exact reason enums can have args rather than using secondary fields that only effect certain enum values. Also shadowOffset moves the text and keeps the shadow in the same place, which is crazy dumb Furthermore, this is a very niche feature, I've never seen it used until now If i was making this feature now, I would make it NONE;
SHADOW(x:Float, ?y:Float);//y=x if null
OUTLINE(thickness:Float, ?cornersOnly:Bool);// cornersOnly = false if null and do away with borderSize altogether |
Fixes #3235
Changes
FlxTextBorderStyle.SHADOW_XY
shadowOffset
Concerns
- added _graphicOffset which offsets the position without using offsetoffset
is now changed whenever the graphic is redrawn, this could be a breaking change, we should try to offset its draw position without affectingoffset
Test State: