Skip to content

Commit a4a2c07

Browse files
afterimage
1 parent d4ab175 commit a4a2c07

5 files changed

Lines changed: 75 additions & 6 deletions

File tree

‎source/backend/subtitles/Subtitle.hx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ class Subtitle extends flixel.addons.text.FlxTypeText {
4949
}
5050

5151
public function beginSubtitleEnd():Void {
52-
FlxTimer.wait(data.duration, () -> {
53-
FlxTween.tween(this, {alpha: 0}, .5, {onComplete: (tween:FlxTween) -> manager.onSubtitleComplete(this)});
54-
});
52+
FlxTimer.wait(data.duration, () -> FlxTween.tween(this, {alpha: 0}, .5, {onComplete: (tween:FlxTween) -> manager.onSubtitleComplete(this)}));
5553
}
5654
}

‎source/backend/subtitles/SubtitleManager.hx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SubtitleManager extends FlxSpriteGroup {
99
*/
1010
var subtitlesGroup:FlxTypedSpriteGroup<Subtitle> = new FlxTypedSpriteGroup<Subtitle>();
1111

12-
public function new() {
12+
public function new():Void {
1313
super();
1414
add(subtitlesGroup);
1515
}

‎source/effects/AfterImage.hx‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package effects;
2+
3+
class AfterImage extends FlxTypedGroup<FlxSprite> {
4+
public var target:FlxSprite;
5+
6+
public var delay:Float; // time between spawns
7+
public var lifetime:Float; // how long each afterimage lasts
8+
public var startAlpha:Float;
9+
public var color:Int;
10+
11+
public var velocity:FlxPoint = FlxPoint.get();
12+
13+
var _timer:Float = 0;
14+
15+
public function new(target:FlxSprite, delay:Float = 0.03, lifetime:Float = 0.3, startAlpha:Float = 0.6, color:Int = 0xFFFFFFFF) {
16+
super();
17+
18+
this.target = target;
19+
this.delay = delay;
20+
this.lifetime = lifetime;
21+
this.startAlpha = startAlpha;
22+
this.color = color;
23+
}
24+
25+
override public function update(elapsed:Float) {
26+
super.update(elapsed);
27+
28+
if (target == null || !target.exists) return;
29+
30+
_timer += elapsed;
31+
32+
if (_timer >= delay) {
33+
_timer = 0;
34+
spawnAfterimage();
35+
}
36+
37+
// update fade
38+
for (sprite in members) {
39+
if (sprite != null && sprite.exists) {
40+
sprite.alpha -= elapsed / lifetime;
41+
if (sprite.alpha <= 0) sprite.kill();
42+
}
43+
}
44+
}
45+
46+
function spawnAfterimage() {
47+
var spr:FlxSprite = recycle(FlxSprite);
48+
49+
spr.revive();
50+
51+
// copy position
52+
spr.setPosition(target.x, target.y);
53+
54+
// copy graphic/frame
55+
spr.loadGraphicFromSprite(target);
56+
57+
// copy transforms
58+
spr.angle = target.angle;
59+
spr.scale.copyFrom(target.scale);
60+
spr.offset.copyFrom(target.offset);
61+
spr.flipX = target.flipX;
62+
spr.flipY = target.flipY;
63+
64+
// visual style
65+
spr.alpha = startAlpha;
66+
spr.color = color;
67+
68+
// velocity
69+
spr.velocity.copyFrom(velocity);
70+
}
71+
}

‎source/macros/GitCommitMacro.hx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class GitCommitMacro {
5252
#if !LIME_DISPLAY
5353
var pos:Position = Context.currentPos();
5454
try {
55-
var proc:Process = new Process('git', ['branch', '--show-current'], false);
55+
var proc:Process = new Process('git', ['branch', '--show-current']);
5656
if (proc.exitCode() != 0) Context.warning('Could not determine current git commit; is this a proper Git repository?', pos);
5757
return macro $v{Std.parseInt(proc.stdout.readLine())};
5858
} catch (e:Dynamic) Context.error(e.toString(), pos);

‎source/macros/KeepMacro.hx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class KeepMacro {
4949
#if sys "sys", #end
5050
"json2object",
5151
// BASE PATH LIBRARIES THAT DOESN'T INCLUDE
52-
"backend", "shaders", "objects", "utils",
52+
"backend", "shaders", "objects", "utils", "effects",
5353
// BASE HAXE
5454
"DateTools", "EReg", "Lambda", "StringBuf"
5555
]) Compiler.include(inc, true, excludes);

0 commit comments

Comments
 (0)