mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-04 22:04:29 +00:00
capsule text effect
This commit is contained in:
parent
5d6264e67e
commit
20d13f56ac
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit fd8251b139d482146ed79495865a48676a4d1d68
|
||||
Subproject commit bc7e486ba4cf52e55893daa951e58b37059b0adb
|
49
source/funkin/freeplayStuff/CapsuleText.hx
Normal file
49
source/funkin/freeplayStuff/CapsuleText.hx
Normal file
|
@ -0,0 +1,49 @@
|
|||
package funkin.freeplayStuff;
|
||||
|
||||
import openfl.filters.BitmapFilterQuality;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
import funkin.shaderslmfao.GaussianBlurShader;
|
||||
|
||||
class CapsuleText extends FlxSpriteGroup
|
||||
{
|
||||
public var blurredText:FlxText;
|
||||
|
||||
var whiteText:FlxText;
|
||||
|
||||
public var text(default, set):String;
|
||||
|
||||
public function new(x:Float, y:Float, songTitle:String, size:Float)
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
blurredText = initText(songTitle, size);
|
||||
blurredText.shader = new GaussianBlurShader(1);
|
||||
whiteText = initText(songTitle, size);
|
||||
// whiteText.shader = new GaussianBlurShader(0.3);
|
||||
text = songTitle;
|
||||
|
||||
blurredText.color = 0xFF00ccff;
|
||||
whiteText.color = 0xFFFFFFFF;
|
||||
add(blurredText);
|
||||
add(whiteText);
|
||||
}
|
||||
|
||||
function initText(songTitle, size:Float):FlxText
|
||||
{
|
||||
var text:FlxText = new FlxText(0, 0, 0, songTitle, Std.int(size));
|
||||
text.font = "5by7";
|
||||
return text;
|
||||
}
|
||||
|
||||
function set_text(value:String):String
|
||||
{
|
||||
blurredText.text = value;
|
||||
whiteText.text = value;
|
||||
whiteText.textField.filters = [
|
||||
new openfl.filters.GlowFilter(0x00ccff, 1, 5, 5, 210, BitmapFilterQuality.MEDIUM),
|
||||
// new openfl.filters.BlurFilter(5, 5, BitmapFilterQuality.LOW)
|
||||
];
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package funkin.freeplayStuff;
|
||||
|
||||
import funkin.shaderslmfao.GaussianBlurShader;
|
||||
import flixel.group.FlxGroup;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
|
@ -20,7 +21,7 @@ class SongMenuItem extends FlxSpriteGroup
|
|||
|
||||
public var songTitle:String = "Test";
|
||||
|
||||
public var songText:FlxText;
|
||||
public var songText:CapsuleText;
|
||||
public var favIcon:FlxSprite;
|
||||
public var ranking:FlxSprite;
|
||||
|
||||
|
@ -81,9 +82,7 @@ class SongMenuItem extends FlxSpriteGroup
|
|||
ranking.x -= 10;
|
||||
}
|
||||
|
||||
songText = new FlxText(capsule.width * 0.26, 45, 0, songTitle, Std.int(40 * realScaled));
|
||||
songText.font = "5by7";
|
||||
songText.color = 0xFF43C1EA;
|
||||
songText = new CapsuleText(capsule.width * 0.26, 45, songTitle, Std.int(40 * realScaled));
|
||||
add(songText);
|
||||
grpHide.add(songText);
|
||||
|
||||
|
@ -91,7 +90,6 @@ class SongMenuItem extends FlxSpriteGroup
|
|||
pixelIcon.makeGraphic(32, 32, 0x00000000);
|
||||
pixelIcon.antialiasing = false;
|
||||
pixelIcon.active = false;
|
||||
|
||||
add(pixelIcon);
|
||||
grpHide.add(pixelIcon);
|
||||
|
||||
|
@ -297,6 +295,7 @@ class SongMenuItem extends FlxSpriteGroup
|
|||
// cute one liners, lol!
|
||||
diffGrayscale.setAmount(value ? 0 : 0.8);
|
||||
songText.alpha = value ? 1 : 0.6;
|
||||
songText.blurredText.visible = value ? true : false;
|
||||
capsule.offset.x = value ? 0 : -5;
|
||||
capsule.animation.play(value ? "selected" : "unselected");
|
||||
ranking.alpha = value ? 1 : 0.7;
|
||||
|
|
25
source/funkin/shaderslmfao/GaussianBlurShader.hx
Normal file
25
source/funkin/shaderslmfao/GaussianBlurShader.hx
Normal file
|
@ -0,0 +1,25 @@
|
|||
package funkin.shaderslmfao;
|
||||
|
||||
import flixel.addons.display.FlxRuntimeShader;
|
||||
import funkin.Paths;
|
||||
import openfl.utils.Assets;
|
||||
|
||||
/**
|
||||
* Note... not actually gaussian!
|
||||
*/
|
||||
class GaussianBlurShader extends FlxRuntimeShader
|
||||
{
|
||||
public var amount:Float;
|
||||
|
||||
public function new(amount:Float = 1.0)
|
||||
{
|
||||
super(Assets.getText(Paths.frag("gaussianBlur")));
|
||||
setAmount(amount);
|
||||
}
|
||||
|
||||
public function setAmount(value:Float):Void
|
||||
{
|
||||
this.amount = value;
|
||||
this.setFloat("amount", amount);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue