01.
<script>
02.
03.
var
endState = {
04.
05.
create:
function
() {
06.
this
.txt = game.add.text(w/2, -150,
'WAR'
, { font:
'50px Arial'
, fill:
'#fff'
});
07.
this
.txt.anchor.setTo(0.5);
08.
game.add.tween(
this
.txt).to({ y: h/2-80 }, 1000, Phaser.Easing.Bounce.Out).start();
09.
this
.scoreText = game.add.text(w/2, h/2-20,
'score: '
+ score , { font:
'92px Arial'
, fill:
'#fff'
});
10.
var
score = game.add.text;
11.
this
.scoreText.anchor.setTo(0.5);
12.
this
.scoreText.alpha = 0;
13.
game.add.tween(
this
.scoreText).delay(500).to({ alpha: 1}, 1000).start();
14.
15.
this
.restartText = game.add.text(w/2, h/2,
'try'
, { font:
'20px Arial'
, fill:
'#fff'
});
16.
this
.restartText.anchor.setTo(0.5);
17.
this
.restartText.alpha = 0;
18.
game.add.tween(
this
.restartText).delay(500).to({ alpha: 1}, 1000).start();
19.
game.add.tween(
this
.restartText).to({y: h/2+50}, 500).to({y: h/2+70}, 500).loop().start();
20.
21.
if
(status == 0) {
22.
this
.txt.text =
'Lose!'
23.
}
24.
if
(status == 1) {
25.
this
.txt.text =
'Win!'
26.
}
27.
},
28.
29.
update:
function
() {
30.
if
(game.input.keyboard.isDown(Phaser.Keyboard.ENTER)) {
31.
game.state.start(
'play'
);
32.
}
33.
},
34.
};
35.
</script>