This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
introPage.js
284 lines (200 loc) · 9.07 KB
/
introPage.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
//create variables you need
var stage1, instance21;
function init1() {
//initialize stage variable to your html canvas element
stage1 = new createjs.Stage("demoCanvas1");
//data object that holds animation info-spritesheet and how to break it up
var data = {
images: ["dadsheetintroscene1.png"],
//this says each individual sprite is 180 wide and 247.5 tall (view image size in photoshop and do the math to get these numbers)
frames: {width:200, height:422, count:3},
//define animations here by giving frame indexes (remember to start at zero)
animations: {
stand:0,
run:[0,2]
}
};
var data2 = {
images: ["girlsheetintroscene1.png"],
//this says each individual sprite is 180 wide and 247.5 tall (view image size in photoshop and do the math to get these numbers)
frames: {width:160, height:286, count:3},
//define animations here by giving frame indexes (remember to start at zero)
animations: {
stand:0,
run:[0,2]
}
};
//these two lines pair together and are both necessary:
//create sprite sheet from the data
var ss = new createjs.SpriteSheet(data);
var ss2 = new createjs.SpriteSheet(data2);
//create animation from the sprite sheet
var instance = new createjs.Sprite(ss);
instance21 = new createjs.Sprite(ss2);
//give your animation starting coordinates: (0,0) is top left
instance.x = 550;
instance.y = 175;
//instance2.x = 0;
instance21.y = 325;
//need to add instance to stage (everything needs to be added to the stage)
stage1.addChild(instance);
stage1.addChild(instance21);
//this starts the animation and repeats forever
//gotoAndStop would cause it to run once
//can also specify a animation to follow, look at docs
instance.gotoAndPlay("stand");
instance21.gotoAndPlay("run");
//these two lines continully update the stage
createjs.Ticker.setFPS(10);
createjs.Ticker.addEventListener("tick", tick1);
}
function tick1(event) {
instance21.x = instance21.x + 10;
if (instance21.x > 250) {
instance21.gotoAndPlay("stand");
return false;
}
stage1.update(event); // important!!
}
//===========================================================INTROSCENE3================================================================
//create variables you need
var stage2;
function init2() {
//initialize stage variable to your html canvas element
stage2 = new createjs.Stage("demoCanvas2");
//data object that holds animation info-spritesheet and how to break it up
var data = {
images: ["fairyintroscene3.png"],
//this says each individual sprite is 180 wide and 247.5 tall (view image size in photoshop and do the math to get these numbers)
frames: {width:50, height:55, count:2},
//define animations here by giving frame indexes (remember to start at zero)
animations: {
stop:0,
fly:[0,2]
}
};
var data2 = {
images: ["girlsheetlvl1.png"],
//this says each individual sprite is 180 wide and 247.5 tall (view image size in photoshop and do the math to get these numbers)
frames: {width:72, height:128, count:3},
//define animations here by giving frame indexes (remember to start at zero)
animations: {
stand:0,
run:[0,2]
}
};
//these two lines pair together and are both necessary:
//create sprite sheet from the data
var ss = new createjs.SpriteSheet(data);
//create animation from the sprite sheet
var instance = new createjs.Sprite(ss);
//give your animation starting coordinates: (0,0) is top left
instance.x = 300;
instance.y = 280;
//need to add instance to stage (everything needs to be added to the stage)
stage2.addChild(instance);
//stage.addChild(instance2);
//this starts the animation and repeats forever
//gotoAndStop would cause it to run once
//can also specify a animation to follow, look at docs
instance.gotoAndPlay("run");
//these two lines continully update the stage
createjs.Ticker.setFPS(6);
createjs.Ticker.addEventListener("tick", stage2);
}
//==========================LVL1===============================================
//create variables you need
var stage3, instance23;
function init3() {
//initialize stage variable to your html canvas element
stage3 = new createjs.Stage("demoCanvas3");
//data object that holds animation info-spritesheet and how to break it up
var data = {
images: ["monstersheetlvl1.png"],
//this says each individual sprite is 180 wide and 247.5 tall (view image size in photoshop and do the math to get these numbers)
frames: {width:80, height:177, count:3},
//define animations here by giving frame indexes (remember to start at zero)
animations: {
stand:0,
run:[0,2]
}
};
var data2 = {
images: ["girlsheetlvl1.png"],
//this says each individual sprite is 180 wide and 247.5 tall (view image size in photoshop and do the math to get these numbers)
frames: {width:72, height:128, count:3},
//define animations here by giving frame indexes (remember to start at zero)
animations: {
stand:0,
run:[0,2]
}
};
//these two lines pair together and are both necessary:
//create sprite sheet from the data
var ss = new createjs.SpriteSheet(data);
var ss2 = new createjs.SpriteSheet(data2);
//create animation from the sprite sheet
var instance = new createjs.Sprite(ss);
instance23 = new createjs.Sprite(ss2);
//give your animation starting coordinates: (0,0) is top left
instance.x = 550;
instance.y = 400;
//instance2.x = 0;
instance23.y = 450;
//need to add instance to stage (everything needs to be added to the stage)
stage3.addChild(instance);
stage3.addChild(instance23);
//this starts the animation and repeats forever
//gotoAndStop would cause it to run once
//can also specify a animation to follow, look at docs
instance.gotoAndPlay("run");
instance23.gotoAndPlay("run");
//these two lines continully update the stage
createjs.Ticker.setFPS(6);
createjs.Ticker.addEventListener("tick", tick3);
}
function tick3(event) {
instance23.x = instance23.x + 10;
if (instance23.x > 250) {
instance23.gotoAndPlay("stand");
return false;
}
stage3.update(event); // important!!
}
var counter = 1;
$(document).ready(function () {
$("#startButton").append('<img src = "StartButton.png" onclick="nextPage()">');
$("#Logo").append('<p id= "title"> Potential</p><p id= "subtitle"> An interactive story adventure!</p>');
});
var nextPage = function(){
counter = counter + 1
console.log(counter)
document.querySelector(".pages").style.visibility = "hidden";
if (counter === 2){
document.getElementById("secondPage").style.visibility = "visible";
init1();
}
if (counter === 3) {
document.getElementById("secondPage").style.visibility = "hidden";
document.getElementById("thirdPage").style.visibility = "visible";
init2();
}
if (counter === 4) {
document.getElementById("thirdPage").style.visibility = "hidden";
document.getElementById("fourthPage").style.visibility = "visible";
init3()
}
if (counter == 5) {
document.getElementById("fourthPage").style.visibility = "hidden";
document.getElementById("fifthPage").style.visibility = "visible";
}
}
$(document).keydown(function(e) {
switch(e.which) {
case 39: // right
nextPage();
break;
default: return; // exit this handler for other keys
}
e.preventDefault(); // prevent the default action (scroll / move caret)
});