Skip to content

Commit

Permalink
fixed notification message to not move around
Browse files Browse the repository at this point in the history
  • Loading branch information
jefvel committed Dec 4, 2024
1 parent 04fb449 commit fb7de81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class PlayState extends BaseState
function on_save_loaded()
{
player.on_save_loaded();
notification_message.show("Loaded save !");
}

override public function update(elapsed:Float)
Expand All @@ -190,7 +189,7 @@ class PlayState extends BaseState
SaveManager.save();

if (FlxG.keys.justPressed.N)
notification_message.show("I'm a test notification message and\n I have no idea how to not follow the camera");
notification_message.show("I'm a test notification message and\n I just want to say hi :)");
#end

if (Ctrl.mode.can_open_menus)
Expand Down
15 changes: 11 additions & 4 deletions source/ui/popups/ServerNotificationMessagePopup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ class ServerNotificationMessagePopup extends FlxTypedGroup<FlxObject>
public function new()
{
super();
text_object = new FlxText(40, 40, 0, null, 40);
text_object = new FlxText(40, 40, 0, null, 40,);
text_object.setFormat(null, 40, 0xffd8d8ff, "left", FlxTextBorderStyle.OUTLINE, 0xFF16122C);
text_object.shadowOffset.set(1, 1);
text_object.borderSize = 4;

add(text_object);
text_object.scrollFactor.set(0, 0);
}

public function show(text:String, persistent = false)
Expand All @@ -36,13 +41,15 @@ class ServerNotificationMessagePopup extends FlxTypedGroup<FlxObject>

text_object.text = text;

var text_y = FlxG.height * 0.3;

text_object.alpha = 0.0;
text_object.x = FlxG.width * 0.5;
text_object.y = FlxG.height * 0.4 - 8;
text_object.x = Math.round((FlxG.width - text_object.width) * 0.5);
text_object.y = text_y - 12;

if (current_tween != null)
current_tween.cancel();
current_tween = FlxTween.tween(text_object, {alpha: 1.0, y: FlxG.height * 0.4}, 0.45, {ease: FlxEase.circOut});
current_tween = FlxTween.tween(text_object, {alpha: 1.0, y: Math.round(text_y)}, 0.35, {ease: FlxEase.elasticOut});
}

public function hide()
Expand Down

0 comments on commit fb7de81

Please sign in to comment.