-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCongratState.hx
More file actions
46 lines (38 loc) · 1.22 KB
/
CongratState.hx
File metadata and controls
46 lines (38 loc) · 1.22 KB
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
/*
* Copyright 2013 Tux4Kids
* Distributed under the terms of the MIT License.
*
* Author(s):
* Abdelhakim Deneche
*/
package ;
import flixel.FlxState;
import flixel.ui.FlxButton;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.text.FlxText;
class CongratState extends FlxState
{
override public function create() {
add(new FlxSprite(0, 0, AssetNames.Background));
var msgWin:FlxSprite = new FlxSprite(0, 0, AssetNames.MessageWidow);
msgWin.x = (FlxG.width - msgWin.width)/2;
msgWin.y = (FlxG.height - msgWin.height)/2;
add(msgWin);
var quitBtn:FlxButton = new FlxButton(0, 0, "", quit);
quitBtn.loadGraphic(AssetNames.ReturnLevelsBtn, true, 93, 105);
quitBtn.x = msgWin.x + (msgWin.width - quitBtn.width) / 2;
quitBtn.y = msgWin.y + msgWin.height - quitBtn.height - 50;
add(quitBtn);
var numStars:Int = 0;
for (level in 0...Registry.numLevels) {
numStars += ProjectClass.getStars(level);
}
add(new FlxText(msgWin.x, msgWin.y+25, Std.int(msgWin.width),
"Congratulations\nYou Finished\nAll Levels\nStars Collected:\n"+numStars+"/"+(Registry.numLevels*3))
.setFormat(AssetNames.TextFont, 54, 0xd1535e, "center"));
}
private function quit() {
FlxG.switchState(new MenuState());
}
}