-
Notifications
You must be signed in to change notification settings - Fork 0
/
FlxTitle.as
72 lines (55 loc) · 1.58 KB
/
FlxTitle.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.flixel
{
public class FlxTitle extends FlxState
{
private var title:FlxText;
private var subTitle:FlxText;
private var startText:FlxText;
private var blinkInterval:Number = 1;
private var blinkTimer:Number = blinkInterval;
private var startVisible:Boolean = true;
public function FlxTitle(Title:String = null, SubTitle:String = null, StartText:String = "Press [XXX]")
{
if (Title != null)
{
title = new FlxText(0, 10, FlxG.width, Title);
title.setFormat(null, 16, 0x000000, "center", 0);
add(title);
if (SubTitle != null)
{
subTitle = new FlxText(0, title.height + 5, FlxG.width, SubTitle);
subTitle.setFormat(null, 8, 0x000000, "center", 0);
add(subTitle);
}
}
startText = new FlxText(0, FlxG.height - 24, FlxG.width, StartText);
startText.setFormat(null, 8, 0x000000, "center", 0);
add(startText);
}
override public function update():void
{
blinkTimer -= FlxG.elapsed;
if (blinkTimer < 0)
{
if (startVisible)
{
blinkTimer = (blinkInterval) / 4;
}
else
{
blinkTimer = blinkInterval;
}
startVisible = !startVisible;
}
startText.visible = startVisible;
trace(blinkTimer);
super.update();
}
public function setColors(titleColor:uint = 0xFF000000, subTitleColor:uint = 0xFF000000, startColor:uint = 0xFF000000):void
{
title.color = titleColor;
subTitle.color = subTitleColor;
startText.color = startColor;
}
}
}