-
Notifications
You must be signed in to change notification settings - Fork 2
/
venusIntro.js
125 lines (95 loc) · 3.28 KB
/
venusIntro.js
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
var venusIntro = function(game){};
venusIntro.prototype = {
preload: function(){
this.game.load.image('curiousity', 'assets/CutsceneArt/curiousity.png');
this.game.load.image('venusApproach', 'assets/CutsceneArt/venusApproach.png');
this.game.load.audio('venusSong', 'assets/venus.ogg');
},
create: function() {
this.game.scale.pageAlignHorizontally = true;
this.game.scale.pageAlignVertically = true;
this.game.scale.refresh();
this.game.world.setBounds(0, 0, 800, 600);
this.music = this.game.add.audio('venusSong');
this.music.play();
this.background = this.game.add.sprite(0,0, "curiousity");
this.game.stage.setBackgroundColor('black');
this.cutsceneArray = new Array();
this.cutsceneArray.push('curiousity');
this.cutsceneArray.push('venusApproach');
this.iterator = 1;
PIXI.Text.prototype.determineFontProperties = function(fontStyle) {
var properties = PIXI.Text.fontPropertiesCache[fontStyle];
if(properties) {
return properties;
}
properties = {ascent: 40, descent: 10, fontSize: 60
};
PIXI.Text.fontPropertiesCache[fontStyle] = properties;
return properties;
};
this.content = [
"",
"Finally, after searching\n the red waste",
"the Philae ran into\na new friend.",
"There, Curiousity told Philae",
"that it had lost contact \nwith Earth as well,",
"and that the only way to \nfind out what happened to \nhumanity was to go to Earth.",
"However, the Philae overshot,\n and found itself orbiting \nthe planet Venus.",
];
this.index = 0;
this.line = '';
this.text = this.game.add.text(32, 380, '', { font: "40pt Jura", fill: 'white', stroke: 'black', strokeThickness: 2});
timer = this.game.time.create(false);
timer.loop(Phaser.Timer.SECOND * 40.00, this.nextImage,this);
timer.start();
this.nextLine();
this.skip = this.game.add.sprite(630,550);
var skipText = this.game.add.text(0,0, "Press [SPACE] to skip");
skipText.fontSize = 16;
skipText.font = "Arial";
skipText.stroke = '#000000';
skipText.strokeThickness = 6;
skipText.fill = 'white';
this.skip.addChild(skipText);
this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR).onDown.add(function() {
this.music.stop();
this.game.state.start("venus");
}, this);
},
updateLine: function() {
if (this.line.length < this.content[this.index].length)
{
this.line = this.content[this.index].substr(0, this.line.length + 1);
// text.text = line;
this.text.setText(this.line);
}
else
{
// Wait 2 seconds then start a new line
this.game.time.events.add(Phaser.Timer.SECOND * 4, this.nextLine, this);
}
},
nextLine : function() {
this.index++;
if (this.index < this.content.length)
{
this.line = '';
this.game.time.events.repeat(80, this.content[this.index].length + 1, this.updateLine, this);
}
},
nextImage : function(){
if (this.iterator < 1){
this.background.loadTexture(this.cutsceneArray[this.iterator]);
this.iterator++;
}
else {
this.background.loadTexture(this.cutsceneArray[this.iterator]);
this.game.time.events.add(Phaser.Timer.SECOND * 10, this.nextLevel, this);
}
},
nextLevel : function(){
this.music.stop();
this.game.state.start('venus');
}
}