-
Notifications
You must be signed in to change notification settings - Fork 0
/
TitleScreen.as
142 lines (124 loc) · 3.7 KB
/
TitleScreen.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package
{
import net.flashpunk.Entity;
import net.flashpunk.FP;
import net.flashpunk.World;
import net.flashpunk.graphics.Image;
import net.flashpunk.graphics.Text;
import net.flashpunk.tweens.misc.VarTween;
import net.flashpunk.utils.Ease;
import net.flashpunk.utils.Input;
import net.flashpunk.Sfx
/**
* ...
* @author Bijan
*/
public class TitleScreen extends World
{
protected var background:Entity;
protected var stripe:Entity;
protected var titleText:Entity;
protected var titleFlash:Image;
protected var hasPlayedTitle:Boolean = false;
protected var normalText:Text;
protected var hardText:Text;
protected var lastTime:String;
protected var lastMode:Boolean;
protected var sfxClick:Sfx = new Sfx(Assets.CLICKSFX);
protected var sfxStart:Sfx = new Sfx(Assets.STARTSFX);
protected var IntroMP3:Sfx = new Sfx(Assets.INTROMP3);
public function TitleScreen(last_Time:String = "0:00", last_Mode:Boolean = false)
{
lastTime = last_Time;
lastMode = last_Mode;
super();
}
override public function begin():void
{
background = addGraphic(new Image(Assets.TITLE_BKGND));
stripe = addGraphic(new Image(Assets.TITLE_STRIPE));
stripe.x = -FP.width;
stripe.y = FP.halfHeight/6;
titleText = addGraphic(new Image(Assets.TITLE_TEXT));
titleText.x = -FP.width;
titleText.y = FP.halfHeight/6;
titleFlash = new Image(Assets.TITLE_FLASH);
titleFlash.alpha = 0;
addGraphic(titleFlash);
var stripeTween:VarTween = new VarTween(onIn);
stripeTween.tween(stripe,"x",0, 0.5, Ease.expoInOut);
addTween(stripeTween,true);
}
protected function onIn():void
{
var titleTween:VarTween = new VarTween(flashIn);
titleTween.tween(titleText,"x",0, 0.75, Ease.expoInOut);
addTween(titleTween,true);
}
protected function flashIn():void
{
sfxStart.play(0.5);
IntroMP3.loop(0.5);
var flashInTween:VarTween = new VarTween(flashOut);
flashInTween.tween(titleFlash,"alpha",1, 0.15, Ease.quadIn);
addTween(flashInTween, true);
}
protected function flashOut():void
{
var flashOutTween:VarTween = new VarTween(textIn);
flashOutTween.tween(titleFlash,"alpha",0, 0.25, Ease.quadOut);
addTween(flashOutTween,true);
}
protected function textIn():void
{
Text.size = 32;
if (lastTime != "0:00" && !lastMode)
normalText = new Text("play normal. Last Time: " + lastTime);
else
normalText = new Text("play normal (2 lives per level)");
normalText.x = FP.screen.width/2 - normalText.width/2;
normalText.y = FP.screen.height - 200;
//normalText.color = 0;
normalText.alpha = 0;
addGraphic(normalText, -1);
var textTween:VarTween = new VarTween(onTextFade);
textTween.tween(normalText, "alpha",1,0.5,Ease.quadIn);
addTween(textTween, true);
if (lastTime != "0:00" && lastMode)
hardText = new Text("play hard. Last Time: " + lastTime);
else
hardText = new Text("play hard (1 life per level)");
hardText.x = FP.screen.width/2 - normalText.width/2;
hardText.y = FP.screen.height - 100;
hardText.alpha = 0;
addGraphic(hardText, -1);
var textTween2:VarTween = new VarTween(onTextFade);
textTween2.tween(hardText, "alpha",1,1.0,Ease.quadIn);
addTween(textTween2, true);
}
protected function onTextFade():void
{
hasPlayedTitle = true;
}
override public function update():void
{
if (hasPlayedTitle)
{
if (Input.mousePressed && mouseY < 530)
{
if(!sfxClick.playing)
sfxClick.play();
IntroMP3.stop();
FP.world = new GameWorld();
}
else if (Input.mousePressed && mouseY > 530)
{
if(!sfxClick.playing)
sfxClick.play();
IntroMP3.stop();
FP.world = new GameWorld(true);
}
}
}
}
}