mirror of
https://github.com/wassname/phaser.git
synced 2026-08-05 13:21:00 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16fa37081f | ||
|
|
fd68a2fe3a | ||
|
|
e7a9b96d27 | ||
|
|
02b75b9e23 | ||
|
|
0896c2fac7 | ||
|
|
8e77e8cedb | ||
|
|
846e9c5061 | ||
|
|
1af86771ba | ||
|
|
84f0f00f49 | ||
|
|
4502ca1bf6 | ||
|
|
70ad43e71b | ||
|
|
a1ccddcd7e | ||
|
|
82c39d0866 | ||
|
|
45f9db515a | ||
|
|
09d4b2bb8b | ||
|
|
8315973c5d | ||
|
|
28f71ed86d | ||
|
|
3488880956 | ||
|
|
33d47cf9e9 | ||
|
|
cdb1891420 | ||
|
|
30af712d6a | ||
|
|
5e182d317b | ||
|
|
26f2b2a931 | ||
|
|
e5dc16b68d | ||
|
|
27fc447928 | ||
|
|
45b6d5a741 | ||
|
|
13a86765cb | ||
|
|
68b7d22e0d | ||
|
|
6e4e99f436 | ||
|
|
651858372c | ||
|
|
d51a37211c | ||
|
|
5b85c910cb | ||
|
|
e5f52e8ae8 | ||
|
|
82cb66f47b | ||
|
|
9deb5514a2 | ||
|
|
90c09374af | ||
|
|
fbe508ab1b | ||
|
|
dbdb2a2026 | ||
|
|
4432d37e6e | ||
|
|
511858e3f5 | ||
|
|
d37ec40d72 | ||
|
|
f575967840 | ||
|
|
912551a45d | ||
|
|
4505aa50f6 | ||
|
|
45518b3ecd | ||
|
|
3fb2eb23cd | ||
|
|
8b06f9cd86 | ||
|
|
e3aaec8ac0 | ||
|
|
ea9e22f472 | ||
|
|
110ab4e253 | ||
|
|
31b68ac94f | ||
|
|
20108e47f3 | ||
|
|
1370ba52b5 | ||
|
|
b2c49ef853 | ||
|
|
f6af6fe0a3 | ||
|
|
7a0e9a478c | ||
|
|
15a002e720 | ||
|
|
c9d07c7346 | ||
|
|
a81d22a309 | ||
|
|
128c7143d5 | ||
|
|
971e17fabe | ||
|
|
2532df8793 | ||
|
|
c5840f4f6f | ||
|
|
4e7dabb47e | ||
|
|
47ee5a2c88 | ||
|
|
ca1f24868a | ||
|
|
1f9df6e3f4 | ||
|
|
ac310ab881 | ||
|
|
abdaaa0010 | ||
|
|
58fb248575 | ||
|
|
283e38aaae | ||
|
|
be6489fbc9 | ||
|
|
651737fdd0 | ||
|
|
88ef644d47 | ||
|
|
7c66a6b6cc | ||
|
|
d8bf13eaaa | ||
|
|
bd66be1804 | ||
|
|
01a314018d | ||
|
|
ff7cad102c | ||
|
|
8479e456dd | ||
|
|
b4e767161b | ||
|
|
6cde583e82 | ||
|
|
ab02040bea | ||
|
|
32f5a2fa36 | ||
|
|
011d2d8e05 | ||
|
|
17af96d46a | ||
|
|
bd9898db7e | ||
|
|
befcf74f44 | ||
|
|
e7c2b6ae9c | ||
|
|
71f82477ea | ||
|
|
c6fa2cb7b6 | ||
|
|
35cef4e529 | ||
|
|
0a0e775ea5 | ||
|
|
10d105d5ce | ||
|
|
754219a978 | ||
|
|
5f9acdca4b | ||
|
|
c6c579e6b3 | ||
|
|
c21365703d | ||
|
|
35e61172e1 | ||
|
|
67e2caafbc | ||
|
|
038bca11b2 | ||
|
|
bd9b964710 | ||
|
|
1aabb6b93d | ||
|
|
77a8dc321f | ||
|
|
428e331a11 | ||
|
|
aa3a86df6e | ||
|
|
92033fde7c | ||
|
|
7aa45b5872 | ||
|
|
c3183dcea9 | ||
|
|
f7329e0661 | ||
|
|
5526a7322b | ||
|
|
902ffee808 | ||
|
|
d1cd1df9a5 | ||
|
|
86f6ddcbc8 | ||
|
|
3b87ce9fc9 | ||
|
|
29d7cc36a0 | ||
|
|
ba74bea4b4 | ||
|
|
ce4cf531d4 | ||
|
|
fdbdd81b7b | ||
|
|
2c8077835c | ||
|
|
10f4bc7507 | ||
|
|
923a10ee81 | ||
|
|
167a498a5e | ||
|
|
7acf79338c | ||
|
|
e103d6ae83 | ||
|
|
9a968bc5bb | ||
|
|
0acef49a7c | ||
|
|
5a5d465034 | ||
|
|
6be31e0f69 | ||
|
|
bf72b4d3b0 | ||
|
|
63d90a0176 | ||
|
|
3cbb820349 | ||
|
|
352749e803 | ||
|
|
4c7a4ebf62 | ||
|
|
5cf7ed4fdb | ||
|
|
f991f9cee8 | ||
|
|
b2c680811b | ||
|
|
4ada28ba81 | ||
|
|
55d69e16b6 | ||
|
|
50eee95c99 | ||
|
|
dd7ae12271 | ||
|
|
a0961f27df | ||
|
|
896e9af9f5 | ||
|
|
b8dbb5d125 | ||
|
|
388e42c80a | ||
|
|
7917eac255 | ||
|
|
39cae4cc09 | ||
|
|
03ae324d26 | ||
|
|
a361a18616 | ||
|
|
dd9f533528 | ||
|
|
1b954066a6 | ||
|
|
da5d8c9272 | ||
|
|
215632c0a7 | ||
|
|
9988a2ffbe | ||
|
|
56389fcaf4 | ||
|
|
c74bac3a9c | ||
|
|
9f6cfca9cd | ||
|
|
6805e7264d | ||
|
|
f7202a3ff1 | ||
|
|
fc6ae6a60b | ||
|
|
636b1af25c | ||
|
|
19759699df | ||
|
|
669570c701 | ||
|
|
af5847e8e4 | ||
|
|
2071fc22fc | ||
|
|
55b2dd379a | ||
|
|
3e1207e1a3 | ||
|
|
8ade29d982 | ||
|
|
74e0cfb13a | ||
|
|
13a03f3620 | ||
|
|
886618c056 | ||
|
|
ca3c71e8f5 | ||
|
|
8e289e6b7c | ||
|
|
1f513a333e | ||
|
|
ea3802a556 | ||
|
|
cd314cd03e | ||
|
|
eb3d8241ca | ||
|
|
fe5fdb164c | ||
|
|
2e11801f9f | ||
|
|
f6712da774 | ||
|
|
b48669dded | ||
|
|
8469a9c51e | ||
|
|
b978a2b73b | ||
|
|
c5c754725a | ||
|
|
8f14483b60 | ||
|
|
539dcdd18a | ||
|
|
666df67453 | ||
|
|
42c0bed502 | ||
|
|
3bfea2101a | ||
|
|
f9ee9bfc0e | ||
|
|
2b99cb4be4 | ||
|
|
0256117307 | ||
|
|
0302e05a83 | ||
|
|
d9ffd6afd4 | ||
|
|
f9b82b66db | ||
|
|
efe839978b | ||
|
|
00a9897ae2 | ||
|
|
378ffc7ade | ||
|
|
b2fc6c422a | ||
|
|
f22159e257 | ||
|
|
8da9b67c18 | ||
|
|
780b8a5d6d | ||
|
|
39025c1c2a | ||
|
|
e91d40b9fc | ||
|
|
a9a46bfbbf | ||
|
|
4926fac578 | ||
|
|
2fc5c89c1e | ||
|
|
e8646def64 | ||
|
|
141337bed9 | ||
|
|
f4688241d2 | ||
|
|
86584a636c | ||
|
|
06a17b4b26 | ||
|
|
299115ca5d | ||
|
|
13a2cc2feb | ||
|
|
373b97648d | ||
|
|
a876fdd2b6 | ||
|
|
cbd9b77327 | ||
|
|
d30e2974c4 | ||
|
|
16ae7f3cb7 | ||
|
|
155c863d69 | ||
|
|
82f019d4d2 | ||
|
|
8015194daa | ||
|
|
7d7aa795e7 | ||
|
|
b286093093 | ||
|
|
496639ff25 | ||
|
|
e32c127a97 | ||
|
|
ca297318f0 | ||
|
|
577e3f8506 | ||
|
|
93fcb7acbf | ||
|
|
e620c99479 | ||
|
|
f115a2dbf8 | ||
|
|
9b6bfa5f37 | ||
|
|
40e1b4b9aa | ||
|
|
6ed6820429 | ||
|
|
7ef5ab8c98 | ||
|
|
e43571980d | ||
|
|
b63bd14172 | ||
|
|
a5f2d65d23 | ||
|
|
7ad4164e3a | ||
|
|
ba6863bdf5 | ||
|
|
38bd00b4ed | ||
|
|
3249aa2673 | ||
|
|
4d80d6c9b2 | ||
|
|
04ebae7a9f | ||
|
|
0dab85c853 | ||
|
|
266b62caff | ||
|
|
83cacb93a0 | ||
|
|
8d48576fe2 | ||
|
|
ebe441666c | ||
|
|
254bf67e16 | ||
|
|
f71b8d4df1 | ||
|
|
6a24d6116b | ||
|
|
e4faa34908 | ||
|
|
71b08cafbd | ||
|
|
9dc7c73135 | ||
|
|
e271f69527 | ||
|
|
46cf024a35 | ||
|
|
1d20c07ed9 | ||
|
|
18a07f7a88 | ||
|
|
13fdca9cf5 | ||
|
|
084c4239e5 | ||
|
|
b35da01cfc | ||
|
|
3f99b691c9 | ||
|
|
42cd8bd812 | ||
|
|
789f0bb0a1 | ||
|
|
dfb22f1044 | ||
|
|
8b793cd8d7 | ||
|
|
94d9fa6e77 | ||
|
|
de34a13545 | ||
|
|
35dd98c72f | ||
|
|
06e33bc8e4 | ||
|
|
1eca16a948 | ||
|
|
32bff9e419 | ||
|
|
00664f9e99 | ||
|
|
fa8533f5d1 | ||
|
|
2e576fa9a7 | ||
|
|
19ddad8095 | ||
|
|
9022a2f9d3 | ||
|
|
0e84b7ccc9 | ||
|
|
a5c8b2509c | ||
|
|
c1d60d7e19 | ||
|
|
8678373754 | ||
|
|
e8bac6c8c7 | ||
|
|
4593a42a5b | ||
|
|
3227918c57 | ||
|
|
a96ced0d82 | ||
|
|
cc42a71c66 | ||
|
|
3e9777e6f4 | ||
|
|
eb95ce231b | ||
|
|
d0889fcc17 | ||
|
|
160a321a36 | ||
|
|
685054eac5 | ||
|
|
19ac33f970 | ||
|
|
56c7f1f275 | ||
|
|
51a42c2f12 | ||
|
|
e3f76ce481 | ||
|
|
bd752785b9 | ||
|
|
787abc1e02 | ||
|
|
581d637663 | ||
|
|
3c164b466c | ||
|
|
01eab3aeb1 | ||
|
|
6f93a2ec94 | ||
|
|
903c2e73fa | ||
|
|
712858cf75 | ||
|
|
ddf15979d0 | ||
|
|
ebf4456e4e | ||
|
|
01f64c6694 | ||
|
|
0a77690f4f | ||
|
|
9030fbf352 | ||
|
|
24c809dd5f | ||
|
|
3de62907a0 | ||
|
|
7ceb11ae49 | ||
|
|
62656783f0 | ||
|
|
2b40d2f507 | ||
|
|
a814cc26cc | ||
|
|
ea651113df | ||
|
|
f00c52598b | ||
|
|
7a9508d01d | ||
|
|
9261160571 | ||
|
|
2787ed188e | ||
|
|
b6efdff286 | ||
|
|
6994e4be5e | ||
|
|
bd5bca14fe | ||
|
|
34736fbde5 | ||
|
|
155c36b0fd | ||
|
|
8dfe5aee1c | ||
|
|
3f9c07d783 | ||
|
|
f63e8d7d06 | ||
|
|
65d2bf557b | ||
|
|
9f9e6a2a57 | ||
|
|
0463bb4333 | ||
|
|
12148b3159 | ||
|
|
ce04ade458 | ||
|
|
a08436abc3 | ||
|
|
35517d94ad | ||
|
|
2659ed7a4a | ||
|
|
ba57f0ae0d | ||
|
|
d8a2b9d2af | ||
|
|
2921a6de2e | ||
|
|
d30f709208 | ||
|
|
1294b3a2b9 | ||
|
|
427819c655 | ||
|
|
1469663ea5 | ||
|
|
1f28d328a7 | ||
|
|
03054c1949 | ||
|
|
708a144c7a | ||
|
|
f6b50c4520 | ||
|
|
f522cda325 | ||
|
|
ab6dbfb49e | ||
|
|
f784a395ce | ||
|
|
9ed930c4cf | ||
|
|
a6fac64248 | ||
|
|
e4621aafdd | ||
|
|
7e5f38d022 | ||
|
|
dfee9f9b2f | ||
|
|
7b052c302f | ||
|
|
94c7c57e1c | ||
|
|
ffd5ddc534 | ||
|
|
4a51ac4671 | ||
|
|
f1f42e4d41 | ||
|
|
cab3b53cf0 | ||
|
|
e5c3ca27c5 | ||
|
|
84b837f56c | ||
|
|
77fd15bf3c | ||
|
|
07724e5001 | ||
|
|
82df8c9f54 | ||
|
|
97423a9d8d | ||
|
|
8ed783802e | ||
|
|
dabda516c2 | ||
|
|
7e8b79adf4 | ||
|
|
275fa4641e | ||
|
|
4b2ac6c6c6 | ||
|
|
9c1fdb371c | ||
|
|
31018b9295 | ||
|
|
a97f271de7 | ||
|
|
fd5eeb9088 | ||
|
|
f3ea68aad3 | ||
|
|
dd695e066f | ||
|
|
6147e07a5f | ||
|
|
969fa46484 | ||
|
|
faf432bdb0 | ||
|
|
44613f7140 | ||
|
|
78dbb1aa59 | ||
|
|
c6bf67c392 | ||
|
|
e98aa205ea | ||
|
|
786aa2900e | ||
|
|
eb98998046 | ||
|
|
3acdad92cb | ||
|
|
574f4f351b | ||
|
|
0201baef11 | ||
|
|
cf414394c3 | ||
|
|
b868c2cb1b | ||
|
|
a7230aa769 | ||
|
|
f10f9324ad | ||
|
|
29acf7fb4b | ||
|
|
ca9321ef42 | ||
|
|
83a00862be | ||
|
|
1c577d3674 | ||
|
|
f5584bdfe5 | ||
|
|
ebc4e5dc3d | ||
|
|
fa692653e3 | ||
|
|
c307f79102 | ||
|
|
1bc6ac25fa | ||
|
|
d4149a8f9a | ||
|
|
9ed2dc8e89 | ||
|
|
1a522ea786 | ||
|
|
77b553ac2a | ||
|
|
664c512a99 | ||
|
|
47e1b1b54b | ||
|
|
455b18b7ec | ||
|
|
c00bf96603 | ||
|
|
e8bed83ac3 | ||
|
|
54f073e5cb | ||
|
|
c8760b4341 | ||
|
|
96da57cac0 | ||
|
|
f832bacfd6 | ||
|
|
e85643abf4 | ||
|
|
868ae81bab | ||
|
|
1a2dc05609 | ||
|
|
852e82d0ca | ||
|
|
2a01fbb0e8 | ||
|
|
6ce6330f50 | ||
|
|
d2bd2e1600 | ||
|
|
82325ecc8a | ||
|
|
e5b1faace6 | ||
|
|
7c7cd8b01d | ||
|
|
ca113b85aa | ||
|
|
a38ad2d1a9 | ||
|
|
9b4b267e7a | ||
|
|
f593afd164 | ||
|
|
0a98bb67d8 | ||
|
|
305b12d76b | ||
|
|
fa15f8015d | ||
|
|
3740ea05ee | ||
|
|
fa8ad51c79 | ||
|
|
480d90b009 | ||
|
|
8668b82ef6 | ||
|
|
fa1ed04aa8 | ||
|
|
83fc38344c | ||
|
|
5afce4bf8e | ||
|
|
933edb203f | ||
|
|
bdc8edea9d | ||
|
|
16b1913de1 | ||
|
|
4b177e0a9b | ||
|
|
8d17e1f963 | ||
|
|
e846f3cbac | ||
|
|
e3384b7ff7 | ||
|
|
c5d90a7722 | ||
|
|
b0a9c646c9 | ||
|
|
31bbf05ace | ||
|
|
62b5aa9bd9 | ||
|
|
ce3e1708e0 | ||
|
|
80e80ddccb | ||
|
|
29dbbcae52 | ||
|
|
40b968028a | ||
|
|
8096dc67f5 | ||
|
|
efa01dcaa3 | ||
|
|
497d15b5bc | ||
|
|
903b11b730 | ||
|
|
18c695e9dd | ||
|
|
6353d8c7ab | ||
|
|
9642d4994a | ||
|
|
3a369d5485 | ||
|
|
e77dba402c | ||
|
|
c29fcfb510 | ||
|
|
9d84429960 | ||
|
|
891369b197 | ||
|
|
51049128f5 | ||
|
|
257cbe3be8 | ||
|
|
bc02a1a05e | ||
|
|
b69b3db486 | ||
|
|
093bf8343d | ||
|
|
02723d4774 | ||
|
|
6b9484aa80 | ||
|
|
f66e6326e3 | ||
|
|
20f63c0af2 | ||
|
|
9479c79d79 | ||
|
|
557160c3c2 | ||
|
|
8132427870 | ||
|
|
15ad941908 | ||
|
|
d1ea96fd83 | ||
|
|
c36543a261 | ||
|
|
e4595d2a41 | ||
|
|
a4bc69c2f7 | ||
|
|
f31d56584d | ||
|
|
45426be0bc | ||
|
|
4b6147d3e3 | ||
|
|
8452fa0fd4 | ||
|
|
68f45709d8 | ||
|
|
8c41b3253c | ||
|
|
a415e779d1 | ||
|
|
61b9e119cb | ||
|
|
ec3fc8f307 | ||
|
|
9e88da5c66 | ||
|
|
e938e41c73 | ||
|
|
1b5c1f18fe | ||
|
|
26a595cd44 | ||
|
|
3f1cafe21f | ||
|
|
7dd63df087 | ||
|
|
78a062dfb6 | ||
|
|
6e4631a849 | ||
|
|
6fde862f61 | ||
|
|
4f969901da | ||
|
|
c5fc5e3394 | ||
|
|
cf26f68693 | ||
|
|
47834ad478 | ||
|
|
91c07ea37d | ||
|
|
d9a49797c4 | ||
|
|
a102859622 | ||
|
|
a899d24d4c | ||
|
|
3c5ea01e09 | ||
|
|
f4734b1143 | ||
|
|
bb9761aaf4 | ||
|
|
fc584cf6bc | ||
|
|
17e208a95e | ||
|
|
e3869ff3ac | ||
|
|
e705509d29 | ||
|
|
8c9a7c8bc7 | ||
|
|
f069107e55 | ||
|
|
49a6ba2c02 | ||
|
|
1bf838a4c4 | ||
|
|
48161f5c24 | ||
|
|
70233b7508 | ||
|
|
ad0d32b7aa | ||
|
|
505e808318 | ||
|
|
07298c8fcd | ||
|
|
f664a4971b | ||
|
|
7c6e6df91a | ||
|
|
fd0a071cb3 | ||
|
|
62d77e7038 | ||
|
|
0a42269479 | ||
|
|
ecc91fb4e0 | ||
|
|
f812b92b8a | ||
|
|
a1450680a4 | ||
|
|
9f687b4f8a | ||
|
|
79dc3566f4 | ||
|
|
336de314a1 | ||
|
|
92e86494e3 | ||
|
|
d211cf669c | ||
|
|
dbaf7269e9 | ||
|
|
3d22d0e169 | ||
|
|
89b00db103 | ||
|
|
95374339b9 | ||
|
|
fba731e740 | ||
|
|
f260108433 | ||
|
|
87858d6bbf | ||
|
|
e79dd5856d | ||
|
|
48ed27dfcc | ||
|
|
f885f7b023 | ||
|
|
e2eddc8b24 | ||
|
|
e41e35fd09 | ||
|
|
a486bf6b4a | ||
|
|
5da0e42be4 | ||
|
|
15fe5ed6c8 | ||
|
|
609ea7ec8f | ||
|
|
4f950ae801 | ||
|
|
5d3fe891cd | ||
|
|
2ba6b4ff67 | ||
|
|
60f0e8967f | ||
|
|
30fc4099c6 | ||
|
|
ee007cd28e | ||
|
|
c904475ae6 | ||
|
|
13d6ab512b | ||
|
|
9b6c819e0e | ||
|
|
50624c1552 | ||
|
|
ebda1f99e3 | ||
|
|
abe344b408 | ||
|
|
90b1946c25 | ||
|
|
78598ae54a | ||
|
|
fe6664eac7 | ||
|
|
bb5d8ca170 | ||
|
|
eb7af3d2a2 | ||
|
|
822a2df289 | ||
|
|
0c97e8e151 | ||
|
|
b2fa345c9d | ||
|
|
c552d86639 | ||
|
|
4d4f7d3d56 | ||
|
|
aa0d8ff238 | ||
|
|
87d52bd85e | ||
|
|
912d6e46aa | ||
|
|
55cf10a085 | ||
|
|
ca0d1eb8af | ||
|
|
f4dab1847e | ||
|
|
10bc22b717 | ||
|
|
128bdccd79 | ||
|
|
d44261b191 | ||
|
|
b2263c16c6 | ||
|
|
3f3b6bfd35 | ||
|
|
2a353a0327 | ||
|
|
0f438d5221 | ||
|
|
a27f6d6562 | ||
|
|
2fe8a3a0a7 | ||
|
|
bdc1c2ceb9 | ||
|
|
923c2504ba | ||
|
|
8a90a87492 | ||
|
|
5acb4e9f1b | ||
|
|
e28cdbeb6a | ||
|
|
66e86e7d82 | ||
|
|
c18de53bab | ||
|
|
ed13283f0f | ||
|
|
7c597999d4 | ||
|
|
6235f25184 | ||
|
|
d31777972c | ||
|
|
7bdcbf5c2a | ||
|
|
71b4cc532f | ||
|
|
d54a92310d | ||
|
|
fef28c6a6a | ||
|
|
6ef89826df | ||
|
|
12e5d2aceb | ||
|
|
801c2af9d4 | ||
|
|
188d6239a3 | ||
|
|
b742439db8 | ||
|
|
99e0934244 | ||
|
|
5d4da0ce66 | ||
|
|
22847f6ade | ||
|
|
70ee753859 | ||
|
|
f9aa7f7339 | ||
|
|
54d98944e4 | ||
|
|
e77f5da2cd | ||
|
|
936118bd91 | ||
|
|
a81a8effb4 | ||
|
|
1e59bc69fb | ||
|
|
559d75eba1 | ||
|
|
4c1dacfa02 | ||
|
|
5b036557c0 | ||
|
|
6bf7bab917 | ||
|
|
19483bafed | ||
|
|
16749edf20 | ||
|
|
3d4783980e | ||
|
|
4bbcc380c5 | ||
|
|
3c8cd20b70 | ||
|
|
b8d3a61c97 | ||
|
|
d323404676 | ||
|
|
8a09469798 | ||
|
|
9289f690eb | ||
|
|
89fe2855e4 | ||
|
|
0f58945212 | ||
|
|
09def364c3 | ||
|
|
0e55e644a9 | ||
|
|
8a85155c08 | ||
|
|
ecf61fc80c | ||
|
|
c2745bec35 | ||
|
|
c884bab7ec | ||
|
|
f76ba6840f | ||
|
|
619b8415ed | ||
|
|
91dc7a4acf | ||
|
|
e74114f384 | ||
|
|
142348f70b | ||
|
|
7aa82a1cb0 | ||
|
|
c2d7fb7fab | ||
|
|
aff7d99a8a | ||
|
|
0b1bcaf270 | ||
|
|
f9776f30fc | ||
|
|
8b2f1cca51 | ||
|
|
e002827a20 | ||
|
|
c2f0128797 | ||
|
|
2d49a31ecd | ||
|
|
9bf7d070f5 | ||
|
|
1248a6c06e | ||
|
|
df32190db8 | ||
|
|
73745e5720 | ||
|
|
48f6d850c8 | ||
|
|
ab7e55ef27 | ||
|
|
5768336150 | ||
|
|
04dcb29c88 | ||
|
|
a174bbc6b3 | ||
|
|
bc77c3f84e | ||
|
|
d7205992a5 | ||
|
|
77cc3858d9 | ||
|
|
a7873a3b74 | ||
|
|
11954812c6 | ||
|
|
d1da4cbdef | ||
|
|
84ef32e62a | ||
|
|
f3dcd3e831 | ||
|
|
982faeedb8 | ||
|
|
4c9c50584e | ||
|
|
955909979d | ||
|
|
ce27acd3ca | ||
|
|
4f2c26df77 | ||
|
|
3038f6fcf8 | ||
|
|
d4781a19d9 | ||
|
|
7cae283a4c | ||
|
|
04106b1388 | ||
|
|
d80467a08a | ||
|
|
c8d6fe6c01 | ||
|
|
a5343b4bc0 | ||
|
|
3c123293ba | ||
|
|
9827e7522f | ||
|
|
727a06cd9b | ||
|
|
9f30f656bc | ||
|
|
a2c756e37f | ||
|
|
72eb22128f | ||
|
|
d0e886259d | ||
|
|
d620fc7796 | ||
|
|
b3fff37faf | ||
|
|
08fb303801 | ||
|
|
945c9c1a0d | ||
|
|
6d21d39b19 | ||
|
|
dcce99ec60 | ||
|
|
b0d3f6e192 | ||
|
|
c81cf0c882 | ||
|
|
4695f62d1d | ||
|
|
c647792c12 | ||
|
|
d19ad4976d | ||
|
|
0591c7f2bd | ||
|
|
6648cb3812 | ||
|
|
ec845155eb | ||
|
|
829a1b00e4 | ||
|
|
80f5c0a67d | ||
|
|
0a7513240a | ||
|
|
533a4c2e30 | ||
|
|
dd8962d4b5 | ||
|
|
114d1d2fbf | ||
|
|
232c96cc54 | ||
|
|
461f7ee54d | ||
|
|
d848fa089d | ||
|
|
1bcbf91398 | ||
|
|
7b6beddc0c | ||
|
|
038cb213e8 | ||
|
|
7dac2b6506 | ||
|
|
2389c6c231 | ||
|
|
c2533d1146 | ||
|
|
c5f6817c4c | ||
|
|
1f8c809f53 | ||
|
|
3b9386727e | ||
|
|
a30762ed8c | ||
|
|
730594835a | ||
|
|
2f03f5fc43 | ||
|
|
d42f396ba0 | ||
|
|
82d4ba4538 | ||
|
|
1c37cd1a96 | ||
|
|
2de70d07a5 | ||
|
|
b951b02de8 | ||
|
|
2270da2479 | ||
|
|
f9f17ad353 | ||
|
|
49fe5ee65f | ||
|
|
59f7a59312 | ||
|
|
5b532ab2e4 | ||
|
|
b20a6ff85a | ||
|
|
31c4d8cb14 | ||
|
|
d510b785b1 | ||
|
|
fe372af453 | ||
|
|
23ec3816db | ||
|
|
39e7b84cd9 | ||
|
|
3e53c0671d | ||
|
|
498725c078 | ||
|
|
ce1523585f | ||
|
|
f2054f8a2a | ||
|
|
0fad46e04b | ||
|
|
c1eafe865a | ||
|
|
f3c9049e76 | ||
|
|
7b4374cabf | ||
|
|
b1d836dfaf | ||
|
|
2a26257caa | ||
|
|
09f57fa346 | ||
|
|
3c0c349089 | ||
|
|
03b7467018 | ||
|
|
4cef0d1d35 | ||
|
|
204ec46b2b | ||
|
|
4ef0750c07 | ||
|
|
67bf221073 | ||
|
|
94add2ea6e | ||
|
|
c7485301ca | ||
|
|
c5ace72180 | ||
|
|
bd54460e80 | ||
|
|
e2141c91a6 | ||
|
|
0b2d818ba8 | ||
|
|
05cc32fbc9 | ||
|
|
53aa43566e | ||
|
|
55568592b5 | ||
|
|
a6e8436e6d | ||
|
|
3cdd2baff0 | ||
|
|
ce7bfd1fc2 | ||
|
|
8fc31ed83b | ||
|
|
1c311a73df | ||
|
|
0adbf1d92f | ||
|
|
aaaaf7ede3 | ||
|
|
77582fb1ed | ||
|
|
2a8447f64e | ||
|
|
deb37e9a90 | ||
|
|
ca932038fb | ||
|
|
00ef200914 | ||
|
|
e88c48641d | ||
|
|
1052df6660 | ||
|
|
4be5a10e44 | ||
|
|
5cf8b846f8 | ||
|
|
9da64e6baf | ||
|
|
98693cb418 | ||
|
|
b1a33cc593 | ||
|
|
b5b5a99dce | ||
|
|
be982b4322 | ||
|
|
493380a51e | ||
|
|
0a08e1ae0e | ||
|
|
e39073d07b | ||
|
|
54a5e6477c | ||
|
|
2a5b6ef12a | ||
|
|
e62b300a25 | ||
|
|
7d98a1bb9d | ||
|
|
c5cccf3283 | ||
|
|
9f23c378a1 | ||
|
|
b6f8a3fba6 | ||
|
|
cb9cb6e894 | ||
|
|
e948f1e3be | ||
|
|
4c21ac0d87 | ||
|
|
db9b8ec370 | ||
|
|
f66e0e9254 | ||
|
|
2087b2d76e | ||
|
|
b2e1434f5e | ||
|
|
b8ab13fec8 | ||
|
|
53d8e4da2e | ||
|
|
33882ae5d1 | ||
|
|
3898faf17e | ||
|
|
1b6fbc1324 | ||
|
|
268470ef62 | ||
|
|
6466361f5f | ||
|
|
00fb20f8c2 | ||
|
|
332f715943 | ||
|
|
f2678104fa | ||
|
|
2638e598dc |
+16
@@ -1 +1,17 @@
|
||||
# System and IDE files
|
||||
Thumbs.db
|
||||
.DS_Store
|
||||
.idea
|
||||
Phaser OSX.sublime-project
|
||||
Phaser OSX.sublime-workspace
|
||||
Phaser.sublime-project
|
||||
Phaser.sublime-workspace
|
||||
*.suo
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
# Vendors
|
||||
node_modules/
|
||||
|
||||
# Build
|
||||
dist/
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"globals" : { "Phaser": false, "PIXI": false },
|
||||
// Ignore Environment Globals
|
||||
"browser" : true, // Standard browser globals e.g. `window`, `document`.
|
||||
"couch" : false,
|
||||
"dojo" : false,
|
||||
"jquery" : true,
|
||||
"mootools" : false,
|
||||
"node" : false,
|
||||
"nonstandard" : false,
|
||||
"phantom" : false,
|
||||
"prototypejs" : false,
|
||||
"rhino" : false,
|
||||
"worker" : false,
|
||||
"wsh" : true, // Windows Scripting Host.
|
||||
"yui" : false,
|
||||
|
||||
// Development
|
||||
"debug" : true, // Allow debugger statements e.g. browser breakpoints.
|
||||
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
||||
|
||||
// ECMAScript Support
|
||||
"es3" : true, // Support legacy browser and javascript environments.
|
||||
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
|
||||
"strict" : false, // Require `use strict` pragma in every file.
|
||||
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
|
||||
|
||||
// Functionality
|
||||
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
|
||||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
||||
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
|
||||
"curly" : true, // Require {} for every new block or scope.
|
||||
"eqeqeq" : false, // Require triple equals i.e. `===`.
|
||||
"eqnull" : true, // Tolerate use of `== null`.
|
||||
"evil" : false, // Tolerate use of `eval`.
|
||||
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
||||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
|
||||
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
|
||||
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
|
||||
"immed" : false, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||
"iterator" : true, // This option suppresses warnings about the __iterator__ property.
|
||||
"lastsemic" : true, // This option suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block.
|
||||
"latedef" : false, // Prohipit variable use before definition.
|
||||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
||||
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
|
||||
"loopfunc" : true, // Allow functions to be defined within loops.
|
||||
// "maxcomplexity" : 10, // This option lets you control cyclomatic complexity throughout your code.
|
||||
// "maxdepth" : 2, // This option lets you control how nested do you want your blocks to be.
|
||||
// "maxlen" : 80, // This option lets you set the maximum length of a line.
|
||||
// "maxparams" : 5, // This option lets you set the max number of formal parameters allowed per function.
|
||||
// "maxstatements" : 25, // This option lets you set the max number of statements allowed per function.This option lets you set the max number of formal parameters allowed per function.
|
||||
"moz" : false, // This options tells JSHint that your code uses Mozilla JavaScript extensions.
|
||||
"multistr" : true, // This option suppresses warnings about multi-line strings.
|
||||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
|
||||
"proto" : true, // This option suppresses warnings about the __proto__ property.
|
||||
"scripturl" : true, // Tolerate script-targeted URLs.
|
||||
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
||||
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
|
||||
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
||||
"undef" : true, // Require all non-global variables be declared before they are used.
|
||||
"unused" : true, // This option warns when you define and never use your variables.
|
||||
"validthis" : true, // This option suppresses warnings about possible strict violations when the code is running in strict mode and you use this in a non-constructor function.
|
||||
|
||||
// Styling
|
||||
"indent" : 4, // Specify indentation spacing
|
||||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||
"noempty" : true, // Prohibit use of empty blocks.
|
||||
"nonew" : true, // Prohibit use of constructors for side-effects.
|
||||
"plusplus" : false, // Prohibit use of `++` & `--`.
|
||||
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
|
||||
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
||||
"trailing" : true // Prohibit trailing whitespaces.
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#How to contribute
|
||||
|
||||
It's important to us that you feel you can contribute towards the evolution of Phaser. This can take many forms: from helping to fix bugs or improve the docs, to adding in new features to the source. This guide should help you in making that process as smooth as possible.
|
||||
|
||||
|
||||
##Reporting issues
|
||||
|
||||
[GitHub Issues][0] is the place to report bugs you may have found in either the core library or any of the examples that are part of the repository. When submitting a bug please do the following:
|
||||
|
||||
1. **Search for existing issues.** Your bug may have already been fixed or addressed in a development branch version of Phaser, so be sure to search the issues first before putting in a duplicate issue.
|
||||
|
||||
2. **Create an isolated and reproducible test case.** If you are reporting a bug, make sure you also have a minimal, runnable, code example that reproduces the problem you have.
|
||||
|
||||
3. **Include a live example.** After narrowing your code down to only the problem areas, make use of[jsFiddle][1], [jsBin][2], or a link to your live site so that we can view a live example of the problem.
|
||||
|
||||
4. **Share as much information as possible.** Include browser version affected, your OS, version of the library, steps to reproduce, etc. "X isn't working!!!1!" will probably just be closed.
|
||||
|
||||
|
||||
##Pixi and Phaser
|
||||
|
||||
It's important to understand that internally Phaser uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) for all rendering. It's possible you may find a bug that is generated on the Pixi level rather than Phaser. You're welcome to still report the issue of course, but if you get a reply saying we think it might be a Pixi issue this is what we're talking about :)
|
||||
|
||||
|
||||
##Support Forum
|
||||
|
||||
We have a very active [Phaser Support Forum](http://www.html5gamedevs.com/forum/14-phaser/). If you need general support, or are struggling to understand how to do something or need your code checked over, then we would urge you to post it to our forum. There are a lot of friendly devs in there who can help, as well as the core Phaser and Pixi teams, so it's a great place to get support from. You're welcome to report bugs directly on GitHub, but for general support we'd always recommend using the forum first.
|
||||
|
||||
|
||||
##Dev vs. Master
|
||||
|
||||
The dev branch of Phaser is our 'current working' version. It is always ahead of the master branch in terms of features and fixes. However it's also bleeding-edge and experimental and we cannot and do not guarantee it will compile or work for you. Very often we have to break things for a few days while we rebuild and patch. So by all means please export the dev branch and contribute towards it, indeed that is where all Pull Requests should be sent, but do so understanding the API may change beneath you.
|
||||
|
||||
|
||||
##Making Changes
|
||||
|
||||
To take advantage of our grunt build script and jshint config it will be easiest for you if you have node.js and grunt installed locally.
|
||||
|
||||
You can download node.js from[nodejs.org][3]. After it has been installed open a console and run `npm i - g grunt - cli` to install the global `grunt` executable.
|
||||
|
||||
After that you can clone the repository and run `npm i` inside the cloned folder. This will install dependencies necessary for building the project. Once that is ready,
|
||||
make your changes and submit a Pull Request:
|
||||
|
||||
- **Send Pull Requests to the `dev` branch.** All Pull Requests must be sent to the `dev` branch, `master` is the latest release and PRs to that branch will be closed.
|
||||
|
||||
- **Ensure changes are jshint validated.** Our JSHint configuration file is provided in the repository and you should check against it before submitting.
|
||||
|
||||
- **Never commit new builds.** When making a code change you should always run `grunt` which will rebuild the project so you can test, *however* please do not commit these new builds or your PR will be closed. Builds by default are placed in the `dist` folder, to keep them separate from the `build` folder releases.
|
||||
|
||||
- **Only commit relevant changes.** Don't include changes that are not directly relevant to the fix you are making. The more focused a PR is, the faster it will get attention and be merged. Extra files changing only whitespace or trash files will likely get your PR closed.
|
||||
|
||||
|
||||
##I don't really like git / node.js, but I can fix this bug
|
||||
|
||||
That is fine too. While Pull Requests are the best thing in the world for us, they are not the only way to help. You're welcome to post fixes to our forum or even just email them to us. All we ask is that you still adhere to the guidelines presented here re: JSHint, etc.
|
||||
|
||||
|
||||
##Code Style Guide
|
||||
|
||||
- Use 4 spaces for tabs, never tab characters.
|
||||
|
||||
- No trailing whitespace, blank lines should have no whitespace.
|
||||
|
||||
- Always favor strict equals` === `unless you * need * to use type coercion.
|
||||
|
||||
- Follow conventions already in the code, and listen to jshint. Our config is set-up for a reason.
|
||||
|
||||
Thanks to Chad for creating the original Pixi.js Contributing file which we adapted for Phaser.
|
||||
|
||||
[0]: https://github.com/photonstorm/phaser/issues
|
||||
[1]: http://jsfiddle.net
|
||||
[2]: http://jsbin.com/
|
||||
[3]: http://nodejs.org
|
||||
@@ -1,31 +0,0 @@
|
||||
module.exports = function (grunt) {
|
||||
grunt.loadNpmTasks('grunt-typescript');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
typescript: {
|
||||
base: {
|
||||
src: ['Phaser/**/*.ts'],
|
||||
dest: 'build/phaser.js',
|
||||
options: {
|
||||
target: 'ES5'
|
||||
}
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
main: {
|
||||
files: [
|
||||
{src: 'build/phaser.js', dest: 'Tests/phaser.js'}
|
||||
]}
|
||||
},
|
||||
watch: {
|
||||
files: '**/*.ts',
|
||||
tasks: ['typescript', 'copy']
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['watch']);
|
||||
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
module.exports = function (grunt) {
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadTasks('./tasks');
|
||||
|
||||
grunt.initConfig({
|
||||
compile_dir: 'dist',
|
||||
src: {
|
||||
phaser: [
|
||||
'src/Intro.js',
|
||||
'src/pixi/Pixi.js',
|
||||
'src/Phaser.js',
|
||||
'src/utils/Utils.js',
|
||||
'src/pixi/core/Matrix.js',
|
||||
'src/pixi/core/Point.js',
|
||||
'src/pixi/core/Rectangle.js',
|
||||
'src/pixi/core/Polygon.js',
|
||||
'src/pixi/display/DisplayObject.js',
|
||||
'src/pixi/display/DisplayObjectContainer.js',
|
||||
'src/pixi/display/Sprite.js',
|
||||
'src/pixi/display/Stage.js',
|
||||
'src/pixi/extras/CustomRenderable.js',
|
||||
'src/pixi/extras/Strip.js',
|
||||
'src/pixi/extras/Rope.js',
|
||||
'src/pixi/extras/TilingSprite.js',
|
||||
'src/pixi/filters/AbstractFilter.js',
|
||||
'src/pixi/filters/FilterBlock.js',
|
||||
'src/pixi/primitives/Graphics.js',
|
||||
'src/pixi/renderers/canvas/CanvasGraphics.js',
|
||||
'src/pixi/renderers/canvas/CanvasRenderer.js',
|
||||
'src/pixi/renderers/webgl/PixiShader.js',
|
||||
'src/pixi/renderers/webgl/PrimitiveShader.js',
|
||||
'src/pixi/renderers/webgl/StripShader.js',
|
||||
'src/pixi/renderers/webgl/WebGLBatch.js',
|
||||
'src/pixi/renderers/webgl/WebGLFilterManager.js',
|
||||
'src/pixi/renderers/webgl/WebGLGraphics.js',
|
||||
'src/pixi/renderers/webgl/WebGLRenderer.js',
|
||||
'src/pixi/renderers/webgl/WebGLRenderGroup.js',
|
||||
'src/pixi/renderers/webgl/WebGLShaders.js',
|
||||
'src/pixi/text/BitmapText.js',
|
||||
'src/pixi/text/Text.js',
|
||||
'src/pixi/textures/BaseTexture.js',
|
||||
'src/pixi/textures/Texture.js',
|
||||
'src/pixi/textures/RenderTexture.js',
|
||||
'src/pixi/utils/EventTarget.js',
|
||||
'src/pixi/utils/Polyk.js',
|
||||
'src/core/Camera.js',
|
||||
'src/core/State.js',
|
||||
'src/core/StateManager.js',
|
||||
'src/core/LinkedList.js',
|
||||
'src/core/Signal.js',
|
||||
'src/core/SignalBinding.js',
|
||||
'src/core/Filter.js',
|
||||
'src/core/Plugin.js',
|
||||
'src/core/PluginManager.js',
|
||||
'src/core/Stage.js',
|
||||
'src/core/Group.js',
|
||||
'src/core/World.js',
|
||||
'src/core/Game.js',
|
||||
'src/input/Input.js',
|
||||
'src/input/Key.js',
|
||||
'src/input/Keyboard.js',
|
||||
'src/input/Mouse.js',
|
||||
'src/input/MSPointer.js',
|
||||
'src/input/Pointer.js',
|
||||
'src/input/Touch.js',
|
||||
'src/input/InputHandler.js',
|
||||
'src/input/Gamepad.js',
|
||||
'src/input/SinglePad.js',
|
||||
'src/input/GamepadButton.js',
|
||||
'src/gameobjects/Events.js',
|
||||
'src/gameobjects/GameObjectFactory.js',
|
||||
'src/gameobjects/BitmapData.js',
|
||||
'src/gameobjects/Sprite.js',
|
||||
'src/gameobjects/TileSprite.js',
|
||||
'src/gameobjects/Text.js',
|
||||
'src/gameobjects/BitmapText.js',
|
||||
'src/gameobjects/Button.js',
|
||||
'src/gameobjects/Graphics.js',
|
||||
'src/gameobjects/RenderTexture.js',
|
||||
'src/system/Canvas.js',
|
||||
'src/system/StageScaleMode.js',
|
||||
'src/system/Device.js',
|
||||
'src/system/RequestAnimationFrame.js',
|
||||
'src/math/RandomDataGenerator.js',
|
||||
'src/math/Math.js',
|
||||
'src/math/QuadTree.js',
|
||||
'src/geom/Circle.js',
|
||||
'src/geom/Point.js',
|
||||
'src/geom/Rectangle.js',
|
||||
'src/geom/Polygon.js',
|
||||
'src/net/Net.js',
|
||||
'src/tween/TweenManager.js',
|
||||
'src/tween/Tween.js',
|
||||
'src/tween/Easing.js',
|
||||
'src/time/Time.js',
|
||||
'src/time/Timer.js',
|
||||
'src/time/TimerEvent.js',
|
||||
'src/animation/AnimationManager.js',
|
||||
'src/animation/Animation.js',
|
||||
'src/animation/Frame.js',
|
||||
'src/animation/FrameData.js',
|
||||
'src/animation/AnimationParser.js',
|
||||
'src/loader/Cache.js',
|
||||
'src/loader/Loader.js',
|
||||
'src/loader/LoaderParser.js',
|
||||
'src/sound/Sound.js',
|
||||
'src/sound/SoundManager.js',
|
||||
'src/utils/Debug.js',
|
||||
'src/utils/Color.js',
|
||||
'src/physics/arcade/SAT.js',
|
||||
'src/physics/arcade/ArcadePhysics.js',
|
||||
'src/physics/arcade/Body.js',
|
||||
'src/particles/Particles.js',
|
||||
'src/particles/arcade/ArcadeParticles.js',
|
||||
'src/particles/arcade/Emitter.js',
|
||||
'src/tilemap/Tile.js',
|
||||
'src/tilemap/Tilemap.js',
|
||||
'src/tilemap/TilemapLayer.js',
|
||||
'src/tilemap/TilemapParser.js',
|
||||
'src/tilemap/Tileset.js',
|
||||
'src/PixiPatch.js'
|
||||
]
|
||||
},
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
clean: ['<%= compile_dir %>'],
|
||||
concat: {
|
||||
phaser: {
|
||||
options: {
|
||||
process: {
|
||||
data: {
|
||||
version: '<%= pkg.version %>',
|
||||
buildDate: '<%= grunt.template.today() %>'
|
||||
}
|
||||
}
|
||||
},
|
||||
src: ['<%= src.phaser %>'],
|
||||
dest: '<%= compile_dir %>/phaser.js'
|
||||
}
|
||||
},
|
||||
umd: {
|
||||
phaser: {
|
||||
src: '<%= concat.phaser.dest %>',
|
||||
dest: '<%= umd.phaser.src %>'
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
phaser: {
|
||||
options: {
|
||||
banner: '/*! Phaser v<%= pkg.version %> | (c) 2013 Photon Storm Ltd. */\n'
|
||||
},
|
||||
src: ['<%= umd.phaser.dest %>'],
|
||||
dest: '<%= compile_dir %>/phaser.min.js'
|
||||
}
|
||||
},
|
||||
examples: {
|
||||
all: {
|
||||
options: {
|
||||
base: 'examples',
|
||||
excludes: ['_site', 'assets', 'states', 'wip']
|
||||
},
|
||||
src: ['examples/**/*.js'],
|
||||
dest: 'examples/_site/examples.json'
|
||||
}
|
||||
},
|
||||
connect: {
|
||||
root: {
|
||||
options: {
|
||||
keepalive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['build', 'examples']);
|
||||
grunt.registerTask('build', ['clean', 'concat', 'umd', 'uglify']);
|
||||
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
#ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
#Ignore files build by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.sln
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
*.map
|
||||
*.orig
|
||||
*.js
|
||||
!phaser.js
|
||||
*.map
|
||||
*.config
|
||||
.DS_Store
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="gameobjects/Sprite.ts" />
|
||||
/// <reference path="system/animation/Animation.ts" />
|
||||
/// <reference path="system/animation/AnimationLoader.ts" />
|
||||
/// <reference path="system/animation/Frame.ts" />
|
||||
/// <reference path="system/animation/FrameData.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - AnimationManager
|
||||
*
|
||||
* Any Sprite that has animation contains an instance of the AnimationManager, which is used to add, play and update
|
||||
* sprite specific animations.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class AnimationManager {
|
||||
|
||||
constructor(game: Game, parent: Sprite) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
this._anims = {};
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Sprite;
|
||||
|
||||
private _anims: {};
|
||||
private _frameIndex: number;
|
||||
private _frameData: FrameData = null;
|
||||
|
||||
public currentAnim: Animation;
|
||||
public currentFrame: Frame = null;
|
||||
|
||||
public loadFrameData(frameData: FrameData) {
|
||||
|
||||
this._frameData = frameData;
|
||||
|
||||
this.frame = 0;
|
||||
|
||||
}
|
||||
|
||||
public add(name: string, frames: any[] = null, frameRate: number = 60, loop: bool = false, useNumericIndex: bool = true) {
|
||||
|
||||
if (this._frameData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (frames == null)
|
||||
{
|
||||
frames = this._frameData.getFrameIndexes();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.validateFrames(frames, useNumericIndex) == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (useNumericIndex == false)
|
||||
{
|
||||
frames = this._frameData.getFrameIndexesByName(frames);
|
||||
}
|
||||
|
||||
this._anims[name] = new Animation(this._game, this._parent, this._frameData, name, frames, frameRate, loop);
|
||||
|
||||
this.currentAnim = this._anims[name];
|
||||
|
||||
}
|
||||
|
||||
private validateFrames(frames: any[], useNumericIndex: bool): bool {
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
if (useNumericIndex == true)
|
||||
{
|
||||
if (frames[i] > this._frameData.total)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._frameData.checkFrameName(frames[i]) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public play(name: string, frameRate?: number = null, loop?: bool) {
|
||||
|
||||
if (this._anims[name])
|
||||
{
|
||||
if (this.currentAnim == this._anims[name])
|
||||
{
|
||||
if (this.currentAnim.isPlaying == false)
|
||||
{
|
||||
this.currentAnim.play(frameRate, loop);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentAnim.play(frameRate, loop);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public stop(name: string) {
|
||||
|
||||
if (this._anims[name])
|
||||
{
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentAnim.stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
if (this.currentAnim && this.currentAnim.update() == true)
|
||||
{
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this._parent.bounds.width = this.currentFrame.width;
|
||||
this._parent.bounds.height = this.currentFrame.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get frameData(): FrameData {
|
||||
return this._frameData;
|
||||
}
|
||||
|
||||
public get frameTotal(): number {
|
||||
return this._frameData.total;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this._frameIndex;
|
||||
}
|
||||
|
||||
public set frame(value: number) {
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
{
|
||||
this._parent.bounds.width = this.currentFrame.width;
|
||||
this._parent.bounds.height = this.currentFrame.height;
|
||||
this._frameIndex = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get frameName(): string {
|
||||
return this.currentFrame.name;
|
||||
}
|
||||
|
||||
public set frameName(value: string) {
|
||||
|
||||
this.currentFrame = this._frameData.getFrameByName(value);
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
{
|
||||
this._parent.bounds.width = this.currentFrame.width;
|
||||
this._parent.bounds.height = this.currentFrame.height;
|
||||
this._frameIndex = this.currentFrame.index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-138
@@ -1,138 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Basic
|
||||
*
|
||||
* A useful "generic" object on which all GameObjects and Groups are based.
|
||||
* It has no size, position or graphical data.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Basic {
|
||||
|
||||
/**
|
||||
* Instantiate the basic object.
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.ID = -1;
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.ignoreDrawDebug = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object
|
||||
*/
|
||||
public _game: Game;
|
||||
|
||||
/**
|
||||
* Allows you to give this object a name. Useful for debugging, but not actually used internally.
|
||||
*/
|
||||
public name: string = '';
|
||||
|
||||
/**
|
||||
* IDs seem like they could be pretty useful, huh?
|
||||
* They're not actually used for anything yet though.
|
||||
*/
|
||||
public ID: number;
|
||||
|
||||
/**
|
||||
* A boolean to store if this object is a Group or not.
|
||||
* Saves us an expensive typeof check inside of core loops.
|
||||
*/
|
||||
public isGroup: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>update()</code> and <code>draw()</code> are automatically called by State/Group.
|
||||
*/
|
||||
public exists: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>update()</code> is automatically called by State/Group.
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether <code>draw()</code> is automatically called by State/Group.
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Useful state for many game objects - "dead" (!alive) vs alive.
|
||||
* <code>kill()</code> and <code>revive()</code> both flip this switch (along with exists, but you can override that).
|
||||
*/
|
||||
public alive: bool;
|
||||
|
||||
/**
|
||||
* Setting this to true will prevent the object from appearing
|
||||
* when the visual debug mode in the debugger overlay is toggled on.
|
||||
*/
|
||||
public ignoreDrawDebug: bool;
|
||||
|
||||
/**
|
||||
* Override this to null out iables or manually call
|
||||
* <code>destroy()</code> on class members if necessary.
|
||||
* Don't forget to call <code>super.destroy()</code>!
|
||||
*/
|
||||
public destroy() { }
|
||||
|
||||
/**
|
||||
* Pre-update is called right before <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this to update your class's position and appearance.
|
||||
* This is where most of your game rules and behavioral code will go.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called right after <code>update()</code> on each object in the game loop.
|
||||
*/
|
||||
public postUpdate() {
|
||||
}
|
||||
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for "killing" game objects.
|
||||
* Default behavior is to flag them as nonexistent AND dead.
|
||||
* However, if you want the "corpse" to remain in the game,
|
||||
* like to animate an effect or whatever, you should override this,
|
||||
* setting only alive to false, and leaving exists true.
|
||||
*/
|
||||
public kill() {
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
|
||||
* In practice, this is most often called by <code>Object.reset()</code>.
|
||||
*/
|
||||
public revive() {
|
||||
this.alive = true;
|
||||
this.exists = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert object to readable string name. Useful for debugging, save games, etc.
|
||||
*/
|
||||
public toString(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Cache
|
||||
*
|
||||
* A game only has one instance of a Cache and it is used to store all externally loaded assets such
|
||||
* as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Cache {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this._canvases = {};
|
||||
this._images = {};
|
||||
this._sounds = {};
|
||||
this._text = {};
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _canvases;
|
||||
private _images;
|
||||
private _sounds;
|
||||
private _text;
|
||||
|
||||
public addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D) {
|
||||
|
||||
this._canvases[key] = { canvas: canvas, context: context };
|
||||
|
||||
}
|
||||
|
||||
public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number) {
|
||||
|
||||
this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight };
|
||||
this._images[key].frameData = AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax);
|
||||
|
||||
}
|
||||
|
||||
public addTextureAtlas(key: string, url: string, data, jsonData) {
|
||||
|
||||
this._images[key] = { url: url, data: data, spriteSheet: true };
|
||||
this._images[key].frameData = AnimationLoader.parseJSONData(this._game, jsonData);
|
||||
|
||||
}
|
||||
|
||||
public addImage(key: string, url: string, data) {
|
||||
|
||||
this._images[key] = { url: url, data: data, spriteSheet: false };
|
||||
|
||||
}
|
||||
|
||||
public addSound(key: string, url: string, data) {
|
||||
|
||||
this._sounds[key] = { url: url, data: data, decoded: false };
|
||||
|
||||
}
|
||||
|
||||
public decodedSound(key: string, data) {
|
||||
|
||||
this._sounds[key].data = data;
|
||||
this._sounds[key].decoded = true;
|
||||
|
||||
}
|
||||
|
||||
public addText(key: string, url: string, data) {
|
||||
|
||||
this._text[key] = { url: url, data: data };
|
||||
|
||||
}
|
||||
|
||||
public getCanvas(key: string) {
|
||||
|
||||
if (this._canvases[key])
|
||||
{
|
||||
return this._canvases[key].canvas;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getImage(key: string) {
|
||||
|
||||
if (this._images[key])
|
||||
{
|
||||
return this._images[key].data;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getFrameData(key: string): FrameData {
|
||||
|
||||
if (this._images[key] && this._images[key].spriteSheet == true)
|
||||
{
|
||||
return this._images[key].frameData;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getSound(key: string) {
|
||||
|
||||
if (this._sounds[key])
|
||||
{
|
||||
return this._sounds[key].data;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public isSoundDecoded(key: string): bool {
|
||||
|
||||
if (this._sounds[key])
|
||||
{
|
||||
return this._sounds[key].decoded;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public isSpriteSheet(key: string): bool {
|
||||
|
||||
if (this._images[key])
|
||||
{
|
||||
return this._images[key].spriteSheet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public getText(key: string) {
|
||||
|
||||
if (this._text[key])
|
||||
{
|
||||
return this._text[key].data;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
for (var item in this._canvases)
|
||||
{
|
||||
delete this._canvases[item['key']];
|
||||
}
|
||||
|
||||
for (var item in this._images)
|
||||
{
|
||||
delete this._images[item['key']];
|
||||
}
|
||||
|
||||
for (var item in this._sounds)
|
||||
{
|
||||
delete this._sounds[item['key']];
|
||||
}
|
||||
|
||||
for (var item in this._text)
|
||||
{
|
||||
delete this._text[item['key']];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="system/Camera.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - CameraManager
|
||||
*
|
||||
* Your game only has one CameraManager instance and it's responsible for looking after, creating and destroying
|
||||
* all of the cameras in the world.
|
||||
*
|
||||
* TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct
|
||||
* TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class CameraManager {
|
||||
|
||||
constructor(game: Game, x: number, y: number, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this._cameras = [];
|
||||
|
||||
this.current = this.addCamera(x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _cameras: Camera[];
|
||||
|
||||
public current: Camera;
|
||||
|
||||
public getAll(): Camera[] {
|
||||
return this._cameras;
|
||||
}
|
||||
|
||||
public update() {
|
||||
this._cameras.forEach((camera) => camera.update());
|
||||
}
|
||||
|
||||
public render() {
|
||||
this._cameras.forEach((camera) => camera.render());
|
||||
}
|
||||
|
||||
public addCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
|
||||
var newCam: Camera = new Camera(this._game, this._cameras.length, x, y, width, height);
|
||||
|
||||
this._cameras.push(newCam);
|
||||
|
||||
return newCam;
|
||||
|
||||
}
|
||||
|
||||
public removeCamera(id: number): bool {
|
||||
|
||||
if (this._cameras[id])
|
||||
{
|
||||
if (this.current === this._cameras[id])
|
||||
{
|
||||
this.current = null;
|
||||
}
|
||||
|
||||
this._cameras.splice(id, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
this._cameras.length = 0;
|
||||
|
||||
this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,893 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="geom/Point.ts" />
|
||||
/// <reference path="geom/Rectangle.ts" />
|
||||
/// <reference path="geom/Circle.ts" />
|
||||
/// <reference path="geom/Line.ts" />
|
||||
/// <reference path="geom/IntersectResult.ts" />
|
||||
/// <reference path="system/QuadTree.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Collision
|
||||
*
|
||||
* A set of extremely useful collision and geometry intersection functions.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Collision {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
public static LEFT: number = 0x0001;
|
||||
public static RIGHT: number = 0x0010;
|
||||
public static UP: number = 0x0100;
|
||||
public static DOWN: number = 0x1000;
|
||||
public static NONE: number = 0;
|
||||
public static CEILING: number = Collision.UP;
|
||||
public static FLOOR: number = Collision.DOWN;
|
||||
public static WALL: number = Collision.LEFT | Collision.RIGHT;
|
||||
public static ANY: number = Collision.LEFT | Collision.RIGHT | Collision.UP | Collision.DOWN;
|
||||
public static OVERLAP_BIAS: number = 4;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------------------------
|
||||
* Lines
|
||||
* -------------------------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Check if the two given Line objects intersect
|
||||
* @method lineToLine
|
||||
* @param {Phaser.Line} The first line object to check
|
||||
* @param {Phaser.Line} The second line object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineToLine(line1: Line, line2: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var denom = (line1.x1 - line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 - line2.x2);
|
||||
|
||||
if (denom !== 0)
|
||||
{
|
||||
output.result = true;
|
||||
output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.x1 - line2.x2) - (line1.x1 - line1.x2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom;
|
||||
output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (line2.y1 - line2.y2) - (line1.y1 - line1.y2) * (line2.x1 * line2.y2 - line2.y1 * line2.x2)) / denom;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line and Line Segment intersects
|
||||
* @method lineToLineSegment
|
||||
* @param {Phaser.Line} The line object to check
|
||||
* @param {Phaser.Line} The line segment object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineToLineSegment(line1: Line, seg: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var denom = (line1.x1 - line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 - seg.x2);
|
||||
|
||||
if (denom !== 0)
|
||||
{
|
||||
output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.x1 - seg.x2) - (line1.x1 - line1.x2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom;
|
||||
output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (seg.y1 - seg.y2) - (line1.y1 - line1.y2) * (seg.x1 * seg.y2 - seg.y1 * seg.x2)) / denom;
|
||||
|
||||
var maxX = Math.max(seg.x1, seg.x2);
|
||||
var minX = Math.min(seg.x1, seg.x2);
|
||||
var maxY = Math.max(seg.y1, seg.y2);
|
||||
var minY = Math.min(seg.y1, seg.y2);
|
||||
|
||||
//if (!(output.x <= maxX && output.x >= minX) || !(output.y <= maxY && output.y >= minY))
|
||||
if ((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true)
|
||||
{
|
||||
output.result = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line and Line Segment intersects
|
||||
* @method lineToLineSegment
|
||||
* @param {Phaser.Line} The line object to check
|
||||
* @param {number} The x1 value
|
||||
* @param {number} The y1 value
|
||||
* @param {number} The x2 value
|
||||
* @param {number} The y2 value
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineToRawSegment(line: Line, x1: number, y1: number, x2: number, y2: number, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var denom = (line.x1 - line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 - x2);
|
||||
|
||||
if (denom !== 0)
|
||||
{
|
||||
output.x = ((line.x1 * line.y2 - line.y1 * line.x2) * (x1 - x2) - (line.x1 - line.x2) * (x1 * y2 - y1 * x2)) / denom;
|
||||
output.y = ((line.x1 * line.y2 - line.y1 * line.x2) * (y1 - y2) - (line.y1 - line.y2) * (x1 * y2 - y1 * x2)) / denom;
|
||||
|
||||
var maxX = Math.max(x1, x2);
|
||||
var minX = Math.min(x1, x2);
|
||||
var maxY = Math.max(y1, y2);
|
||||
var minY = Math.min(y1, y2);
|
||||
|
||||
if ((output.x <= maxX && output.x >= minX) === true || (output.y <= maxY && output.y >= minY) === true)
|
||||
{
|
||||
output.result = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line and Ray intersects
|
||||
* @method lineToRay
|
||||
* @param {Phaser.Line} The Line object to check
|
||||
* @param {Phaser.Line} The Ray object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineToRay(line1: Line, ray: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var denom = (line1.x1 - line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 - ray.x2);
|
||||
|
||||
if (denom !== 0)
|
||||
{
|
||||
output.x = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.x1 - ray.x2) - (line1.x1 - line1.x2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denom;
|
||||
output.y = ((line1.x1 * line1.y2 - line1.y1 * line1.x2) * (ray.y1 - ray.y2) - (line1.y1 - line1.y2) * (ray.x1 * ray.y2 - ray.y1 * ray.x2)) / denom;
|
||||
output.result = true; // true unless either of the 2 following conditions are met
|
||||
|
||||
if (!(ray.x1 >= ray.x2) && output.x < ray.x1)
|
||||
{
|
||||
output.result = false;
|
||||
}
|
||||
|
||||
if (!(ray.y1 >= ray.y2) && output.y < ray.y1)
|
||||
{
|
||||
output.result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line and Circle intersects
|
||||
* @method lineToCircle
|
||||
* @param {Phaser.Line} The Line object to check
|
||||
* @param {Phaser.Circle} The Circle object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection
|
||||
**/
|
||||
public static lineToCircle(line: Line, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
// Get a perpendicular line running to the center of the circle
|
||||
if (line.perp(circle.x, circle.y).length <= circle.radius)
|
||||
{
|
||||
output.result = true;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line intersects each side of the Rectangle
|
||||
* @method lineToRectangle
|
||||
* @param {Phaser.Line} The Line object to check
|
||||
* @param {Phaser.Rectangle} The Rectangle object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection
|
||||
**/
|
||||
public static lineToRectangle(line: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
// Top of the Rectangle vs the Line
|
||||
this.lineToRawSegment(line, rect.x, rect.y, rect.right, rect.y, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// Left of the Rectangle vs the Line
|
||||
this.lineToRawSegment(line, rect.x, rect.y, rect.x, rect.bottom, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// Bottom of the Rectangle vs the Line
|
||||
this.lineToRawSegment(line, rect.x, rect.bottom, rect.right, rect.bottom, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// Right of the Rectangle vs the Line
|
||||
this.lineToRawSegment(line, rect.right, rect.y, rect.right, rect.bottom, output);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------------------------
|
||||
* Line Segment
|
||||
* -------------------------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Check if Line1 intersects with Line2
|
||||
* @method lineSegmentToLineSegment
|
||||
* @param {Phaser.Line} The first line object to check
|
||||
* @param {Phaser.Line} The second line object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineSegmentToLineSegment(line1: Line, line2: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
this.lineToLineSegment(line1, line2, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2)
|
||||
&& output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2)))
|
||||
{
|
||||
output.result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line Segment intersects with the Ray
|
||||
* @method lineSegmentToRay
|
||||
* @param {Phaser.Line} The Line object to check
|
||||
* @param {Phaser.Line} The Line Ray object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineSegmentToRay(line1: Line, ray: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
this.lineToRay(line1, ray, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
if (!(output.x >= Math.min(line1.x1, line1.x2) && output.x <= Math.max(line1.x1, line1.x2)
|
||||
&& output.y >= Math.min(line1.y1, line1.y2) && output.y <= Math.max(line1.y1, line1.y2)))
|
||||
{
|
||||
output.result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line Segment intersects with the Circle
|
||||
* @method lineSegmentToCircle
|
||||
* @param {Phaser.Line} The Line object to check
|
||||
* @param {Phaser.Circle} The Circle object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineSegmentToCircle(seg: Line, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var perp = seg.perp(circle.x, circle.y);
|
||||
|
||||
if (perp.length <= circle.radius)
|
||||
{
|
||||
// Line intersects circle - check if segment does
|
||||
var maxX = Math.max(seg.x1, seg.x2);
|
||||
var minX = Math.min(seg.x1, seg.x2);
|
||||
var maxY = Math.max(seg.y1, seg.y2);
|
||||
var minY = Math.min(seg.y1, seg.y2);
|
||||
|
||||
if ((perp.x2 <= maxX && perp.x2 >= minX) && (perp.y2 <= maxY && perp.y2 >= minY))
|
||||
{
|
||||
output.result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Worst case - segment doesn't traverse center, so no perpendicular connection.
|
||||
if (this.circleContainsPoint(circle, <Point> { x: seg.x1, y: seg.y1 }) || this.circleContainsPoint(circle, <Point> { x: seg.x2, y: seg.y2 }))
|
||||
{
|
||||
output.result = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Line Segment intersects with the Rectangle
|
||||
* @method lineSegmentToCircle
|
||||
* @param {Phaser.Line} The Line object to check
|
||||
* @param {Phaser.Circle} The Circle object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y
|
||||
**/
|
||||
public static lineSegmentToRectangle(seg: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
if (rect.contains(seg.x1, seg.y1) && rect.contains(seg.x2, seg.y2))
|
||||
{
|
||||
output.result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Top of the Rectangle vs the Line
|
||||
this.lineToRawSegment(seg, rect.x, rect.y, rect.right, rect.bottom, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// Left of the Rectangle vs the Line
|
||||
this.lineToRawSegment(seg, rect.x, rect.y, rect.x, rect.bottom, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// Bottom of the Rectangle vs the Line
|
||||
this.lineToRawSegment(seg, rect.x, rect.bottom, rect.right, rect.bottom, output);
|
||||
|
||||
if (output.result === true)
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// Right of the Rectangle vs the Line
|
||||
this.lineToRawSegment(seg, rect.right, rect.y, rect.right, rect.bottom, output);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------------------------
|
||||
* Ray
|
||||
* -------------------------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Check if the two given Circle objects intersect
|
||||
* @method circleToCircle
|
||||
* @param {Phaser.Circle} The first circle object to check
|
||||
* @param {Phaser.Circle} The second circle object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection
|
||||
**/
|
||||
public static rayToRectangle(ray: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
// Currently just finds first intersection - might not be closest to ray pt1
|
||||
this.lineToRectangle(ray, rect, output);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a ray intersects a line segment, returns the parametric value where the intersection occurs.
|
||||
* @method rayToLineSegment
|
||||
* @static
|
||||
* @param {Number} rayx1. The origin x of the ray.
|
||||
* @param {Number} rayy1. The origin y of the ray.
|
||||
* @param {Number} rayx2. The direction x of the ray.
|
||||
* @param {Number} rayy2. The direction y of the ray.
|
||||
* @param {Number} linex1. The x of the first point of the line segment.
|
||||
* @param {Number} liney1. The y of the first point of the line segment.
|
||||
* @param {Number} linex2. The x of the second point of the line segment.
|
||||
* @param {Number} liney2. The y of the second point of the line segment.
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection stored in x
|
||||
**/
|
||||
public static rayToLineSegment(rayx1, rayy1, rayx2, rayy2, linex1, liney1, linex2, liney2, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var r, s, d;
|
||||
|
||||
// Check lines are not parallel
|
||||
if ((rayy2 - rayy1) / (rayx2 - rayx1) != (liney2 - liney1) / (linex2 - linex1))
|
||||
{
|
||||
d = (((rayx2 - rayx1) * (liney2 - liney1)) - (rayy2 - rayy1) * (linex2 - linex1));
|
||||
|
||||
if (d != 0)
|
||||
{
|
||||
r = (((rayy1 - liney1) * (linex2 - linex1)) - (rayx1 - linex1) * (liney2 - liney1)) / d;
|
||||
s = (((rayy1 - liney1) * (rayx2 - rayx1)) - (rayx1 - linex1) * (rayy2 - rayy1)) / d;
|
||||
|
||||
if (r >= 0)
|
||||
{
|
||||
if (s >= 0 && s <= 1)
|
||||
{
|
||||
output.result = true;
|
||||
output.x = rayx1 + r * (rayx2 - rayx1), rayy1 + r * (rayy2 - rayy1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------------------------
|
||||
* Rectangles
|
||||
* -------------------------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Determines whether the specified point is contained within the rectangular region defined by the Rectangle object.
|
||||
* @method pointToRectangle
|
||||
* @param {Point} point The point object being checked.
|
||||
* @param {Rectangle} rect The rectangle object being checked.
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y/result
|
||||
**/
|
||||
public static pointToRectangle(point: Point, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
output.setTo(point.x, point.y);
|
||||
|
||||
output.result = rect.containsPoint(point);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether two axis aligned rectangles intersect. Return the intersecting rectangle dimensions if they do.
|
||||
* @method rectangleToRectangle
|
||||
* @param {Phaser.Rectangle} The first Rectangle object
|
||||
* @param {Phaser.Rectangle} The second Rectangle object
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection in x/y/width/height
|
||||
**/
|
||||
public static rectangleToRectangle(rect1: Rectangle, rect2: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var leftX = Math.max(rect1.x, rect2.x);
|
||||
var rightX = Math.min(rect1.right, rect2.right);
|
||||
var topY = Math.max(rect1.y, rect2.y);
|
||||
var bottomY = Math.min(rect1.bottom, rect2.bottom);
|
||||
|
||||
output.setTo(leftX, topY, rightX - leftX, bottomY - topY, rightX - leftX, bottomY - topY);
|
||||
|
||||
var cx = output.x + output.width * .5;
|
||||
var cy = output.y + output.height * .5;
|
||||
|
||||
if ((cx > rect1.x && cx < rect1.right) && (cy > rect1.y && cy < rect1.bottom))
|
||||
{
|
||||
output.result = true;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
public static rectangleToCircle(rect: Rectangle, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
return this.circleToRectangle(circle, rect, output);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------------------------
|
||||
* Circle
|
||||
* -------------------------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Check if the two given Circle objects intersect
|
||||
* @method circleToCircle
|
||||
* @param {Phaser.Circle} The first circle object to check
|
||||
* @param {Phaser.Circle} The second circle object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection
|
||||
**/
|
||||
public static circleToCircle(circle1: Circle, circle2: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
output.result = ((circle1.radius + circle2.radius) * (circle1.radius + circle2.radius)) >= this.distanceSquared(circle1.x, circle1.y, circle2.x, circle2.y);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given Rectangle intersects with the given Circle
|
||||
* @method circleToRectangle
|
||||
* @param {Phaser.Circle} The circle object to check
|
||||
* @param {Phaser.Rectangle} The Rectangle object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection
|
||||
**/
|
||||
public static circleToRectangle(circle: Circle, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
var inflatedRect: Rectangle = rect.clone();
|
||||
|
||||
inflatedRect.inflate(circle.radius, circle.radius);
|
||||
|
||||
output.result = inflatedRect.contains(circle.x, circle.y);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given Point is found within the given Circle
|
||||
* @method circleContainsPoint
|
||||
* @param {Phaser.Circle} The circle object to check
|
||||
* @param {Phaser.Point} The point object to check
|
||||
* @param {Phaser.IntersectResult} An optional IntersectResult object to store the intersection values in (one is created if none given)
|
||||
* @return {Phaser.IntersectResult} An IntersectResult object containing the results of this intersection
|
||||
**/
|
||||
public static circleContainsPoint(circle: Circle, point: Point, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
||||
output.result = circle.radius * circle.radius >= this.distanceSquared(circle.x, circle.y, point.x, point.y);
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------------------------
|
||||
* Game Object Collision
|
||||
* -------------------------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
/**
|
||||
* Call this function to see if one <code>GameObject</code> overlaps another.
|
||||
* Can be called with one object and one group, or two groups, or two objects,
|
||||
* whatever floats your boat! For maximum performance try bundling a lot of objects
|
||||
* together using a <code>Group</code> (or even bundling groups together!).
|
||||
*
|
||||
* <p>NOTE: does NOT take objects' scrollfactor into account, all overlaps are checked in world space.</p>
|
||||
*
|
||||
* @param ObjectOrGroup1 The first object or group you want to check.
|
||||
* @param ObjectOrGroup2 The second object or group you want to check. If it is the same as the first it knows to just do a comparison within that group.
|
||||
* @param NotifyCallback A function with two <code>GameObject</code> parameters - e.g. <code>myOverlapFunction(Object1:GameObject,Object2:GameObject)</code> - that is called if those two objects overlap.
|
||||
* @param ProcessCallback A function with two <code>GameObject</code> parameters - e.g. <code>myOverlapFunction(Object1:GameObject,Object2:GameObject)</code> - that is called if those two objects overlap. If a ProcessCallback is provided, then NotifyCallback will only be called if ProcessCallback returns true for those objects!
|
||||
*
|
||||
* @return Whether any overlaps were detected.
|
||||
*/
|
||||
public overlap(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null, ProcessCallback = null): bool {
|
||||
|
||||
if (ObjectOrGroup1 == null)
|
||||
{
|
||||
ObjectOrGroup1 = this._game.world.group;
|
||||
}
|
||||
|
||||
if (ObjectOrGroup2 == ObjectOrGroup1)
|
||||
{
|
||||
ObjectOrGroup2 = null;
|
||||
}
|
||||
|
||||
QuadTree.divisions = this._game.world.worldDivisions;
|
||||
|
||||
var quadTree: QuadTree = new QuadTree(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height);
|
||||
|
||||
quadTree.load(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, ProcessCallback);
|
||||
|
||||
var result: bool = quadTree.execute();
|
||||
|
||||
quadTree.destroy();
|
||||
|
||||
quadTree = null;
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The main collision resolution in flixel.
|
||||
*
|
||||
* @param Object1 Any <code>Sprite</code>.
|
||||
* @param Object2 Any other <code>Sprite</code>.
|
||||
*
|
||||
* @return Whether the objects in fact touched and were separated.
|
||||
*/
|
||||
public static separate(Object1, Object2): bool {
|
||||
|
||||
var separatedX: bool = Collision.separateX(Object1, Object2);
|
||||
var separatedY: bool = Collision.separateY(Object1, Object2);
|
||||
|
||||
return separatedX || separatedY;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The X-axis component of the object separation process.
|
||||
*
|
||||
* @param Object1 Any <code>Sprite</code>.
|
||||
* @param Object2 Any other <code>Sprite</code>.
|
||||
*
|
||||
* @return Whether the objects in fact touched and were separated along the X axis.
|
||||
*/
|
||||
public static separateX(Object1, Object2): bool {
|
||||
|
||||
//can't separate two immovable objects
|
||||
var obj1immovable: bool = Object1.immovable;
|
||||
var obj2immovable: bool = Object2.immovable;
|
||||
|
||||
if (obj1immovable && obj2immovable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//If one of the objects is a tilemap, just pass it off.
|
||||
/*
|
||||
if (typeof Object1 === 'Tilemap')
|
||||
{
|
||||
return Object1.overlapsWithCallback(Object2, separateX);
|
||||
}
|
||||
|
||||
if (typeof Object2 === 'Tilemap')
|
||||
{
|
||||
return Object2.overlapsWithCallback(Object1, separateX, true);
|
||||
}
|
||||
*/
|
||||
|
||||
//First, get the two object deltas
|
||||
var overlap: number = 0;
|
||||
var obj1delta: number = Object1.x - Object1.last.x;
|
||||
var obj2delta: number = Object2.x - Object2.last.x;
|
||||
|
||||
if (obj1delta != obj2delta)
|
||||
{
|
||||
//Check if the X hulls actually overlap
|
||||
var obj1deltaAbs: number = (obj1delta > 0) ? obj1delta : -obj1delta;
|
||||
var obj2deltaAbs: number = (obj2delta > 0) ? obj2delta : -obj2delta;
|
||||
var obj1rect: Rectangle = new Rectangle(Object1.x - ((obj1delta > 0) ? obj1delta : 0), Object1.last.y, Object1.width + ((obj1delta > 0) ? obj1delta : -obj1delta), Object1.height);
|
||||
var obj2rect: Rectangle = new Rectangle(Object2.x - ((obj2delta > 0) ? obj2delta : 0), Object2.last.y, Object2.width + ((obj2delta > 0) ? obj2delta : -obj2delta), Object2.height);
|
||||
|
||||
if ((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height))
|
||||
{
|
||||
var maxOverlap: number = obj1deltaAbs + obj2deltaAbs + Collision.OVERLAP_BIAS;
|
||||
|
||||
//If they did overlap (and can), figure out by how much and flip the corresponding flags
|
||||
if (obj1delta > obj2delta)
|
||||
{
|
||||
overlap = Object1.x + Object1.width - Object2.x;
|
||||
|
||||
if ((overlap > maxOverlap) || !(Object1.allowCollisions & Collision.RIGHT) || !(Object2.allowCollisions & Collision.LEFT))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= Collision.RIGHT;
|
||||
Object2.touching |= Collision.LEFT;
|
||||
}
|
||||
}
|
||||
else if (obj1delta < obj2delta)
|
||||
{
|
||||
overlap = Object1.x - Object2.width - Object2.x;
|
||||
|
||||
if ((-overlap > maxOverlap) || !(Object1.allowCollisions & Collision.LEFT) || !(Object2.allowCollisions & Collision.RIGHT))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= Collision.LEFT;
|
||||
Object2.touching |= Collision.RIGHT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (overlap != 0)
|
||||
{
|
||||
var obj1v: number = Object1.velocity.x;
|
||||
var obj2v: number = Object2.velocity.x;
|
||||
|
||||
if (!obj1immovable && !obj2immovable)
|
||||
{
|
||||
overlap *= 0.5;
|
||||
Object1.x = Object1.x - overlap;
|
||||
Object2.x += overlap;
|
||||
|
||||
var obj1velocity: number = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1);
|
||||
var obj2velocity: number = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1);
|
||||
var average: number = (obj1velocity + obj2velocity) * 0.5;
|
||||
obj1velocity -= average;
|
||||
obj2velocity -= average;
|
||||
Object1.velocity.x = average + obj1velocity * Object1.elasticity;
|
||||
Object2.velocity.x = average + obj2velocity * Object2.elasticity;
|
||||
}
|
||||
else if (!obj1immovable)
|
||||
{
|
||||
Object1.x = Object1.x - overlap;
|
||||
Object1.velocity.x = obj2v - obj1v * Object1.elasticity;
|
||||
}
|
||||
else if (!obj2immovable)
|
||||
{
|
||||
Object2.x += overlap;
|
||||
Object2.velocity.x = obj1v - obj2v * Object2.elasticity;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Y-axis component of the object separation process.
|
||||
*
|
||||
* @param Object1 Any <code>Sprite</code>.
|
||||
* @param Object2 Any other <code>Sprite</code>.
|
||||
*
|
||||
* @return Whether the objects in fact touched and were separated along the Y axis.
|
||||
*/
|
||||
public static separateY(Object1, Object2): bool {
|
||||
|
||||
//can't separate two immovable objects
|
||||
|
||||
var obj1immovable: bool = Object1.immovable;
|
||||
var obj2immovable: bool = Object2.immovable;
|
||||
|
||||
if (obj1immovable && obj2immovable)
|
||||
return false;
|
||||
|
||||
//If one of the objects is a tilemap, just pass it off.
|
||||
/*
|
||||
if (typeof Object1 === 'Tilemap')
|
||||
{
|
||||
return Object1.overlapsWithCallback(Object2, separateY);
|
||||
}
|
||||
|
||||
if (typeof Object2 === 'Tilemap')
|
||||
{
|
||||
return Object2.overlapsWithCallback(Object1, separateY, true);
|
||||
}
|
||||
*/
|
||||
|
||||
//First, get the two object deltas
|
||||
var overlap: number = 0;
|
||||
var obj1delta: number = Object1.y - Object1.last.y;
|
||||
var obj2delta: number = Object2.y - Object2.last.y;
|
||||
|
||||
if (obj1delta != obj2delta)
|
||||
{
|
||||
//Check if the Y hulls actually overlap
|
||||
var obj1deltaAbs: number = (obj1delta > 0) ? obj1delta : -obj1delta;
|
||||
var obj2deltaAbs: number = (obj2delta > 0) ? obj2delta : -obj2delta;
|
||||
var obj1rect: Rectangle = new Rectangle(Object1.x, Object1.y - ((obj1delta > 0) ? obj1delta : 0), Object1.width, Object1.height + obj1deltaAbs);
|
||||
var obj2rect: Rectangle = new Rectangle(Object2.x, Object2.y - ((obj2delta > 0) ? obj2delta : 0), Object2.width, Object2.height + obj2deltaAbs);
|
||||
|
||||
if ((obj1rect.x + obj1rect.width > obj2rect.x) && (obj1rect.x < obj2rect.x + obj2rect.width) && (obj1rect.y + obj1rect.height > obj2rect.y) && (obj1rect.y < obj2rect.y + obj2rect.height))
|
||||
{
|
||||
var maxOverlap: number = obj1deltaAbs + obj2deltaAbs + Collision.OVERLAP_BIAS;
|
||||
|
||||
//If they did overlap (and can), figure out by how much and flip the corresponding flags
|
||||
if (obj1delta > obj2delta)
|
||||
{
|
||||
overlap = Object1.y + Object1.height - Object2.y;
|
||||
|
||||
if ((overlap > maxOverlap) || !(Object1.allowCollisions & Collision.DOWN) || !(Object2.allowCollisions & Collision.UP))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= Collision.DOWN;
|
||||
Object2.touching |= Collision.UP;
|
||||
}
|
||||
}
|
||||
else if (obj1delta < obj2delta)
|
||||
{
|
||||
overlap = Object1.y - Object2.height - Object2.y;
|
||||
|
||||
if ((-overlap > maxOverlap) || !(Object1.allowCollisions & Collision.UP) || !(Object2.allowCollisions & Collision.DOWN))
|
||||
{
|
||||
overlap = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Object1.touching |= Collision.UP;
|
||||
Object2.touching |= Collision.DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Then adjust their positions and velocities accordingly (if there was any overlap)
|
||||
if (overlap != 0)
|
||||
{
|
||||
var obj1v: number = Object1.velocity.y;
|
||||
var obj2v: number = Object2.velocity.y;
|
||||
|
||||
if (!obj1immovable && !obj2immovable)
|
||||
{
|
||||
overlap *= 0.5;
|
||||
Object1.y = Object1.y - overlap;
|
||||
Object2.y += overlap;
|
||||
|
||||
var obj1velocity: number = Math.sqrt((obj2v * obj2v * Object2.mass) / Object1.mass) * ((obj2v > 0) ? 1 : -1);
|
||||
var obj2velocity: number = Math.sqrt((obj1v * obj1v * Object1.mass) / Object2.mass) * ((obj1v > 0) ? 1 : -1);
|
||||
var average: number = (obj1velocity + obj2velocity) * 0.5;
|
||||
obj1velocity -= average;
|
||||
obj2velocity -= average;
|
||||
Object1.velocity.y = average + obj1velocity * Object1.elasticity;
|
||||
Object2.velocity.y = average + obj2velocity * Object2.elasticity;
|
||||
}
|
||||
else if (!obj1immovable)
|
||||
{
|
||||
Object1.y = Object1.y - overlap;
|
||||
Object1.velocity.y = obj2v - obj1v * Object1.elasticity;
|
||||
//This is special case code that handles cases like horizontal moving platforms you can ride
|
||||
if (Object2.active && Object2.moves && (obj1delta > obj2delta))
|
||||
{
|
||||
Object1.x += Object2.x - Object2.last.x;
|
||||
}
|
||||
}
|
||||
else if (!obj2immovable)
|
||||
{
|
||||
Object2.y += overlap;
|
||||
Object2.velocity.y = obj1v - obj2v * Object2.elasticity;
|
||||
//This is special case code that handles cases like horizontal moving platforms you can ride
|
||||
if (Object1.active && Object1.moves && (obj1delta < obj2delta))
|
||||
{
|
||||
Object2.x += Object1.x - Object1.last.x;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------------------------
|
||||
* Distance
|
||||
* -------------------------------------------------------------------------------------------
|
||||
**/
|
||||
|
||||
public static distance(x1: number, y1: number, x2: number, y2: number) {
|
||||
return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||
}
|
||||
|
||||
public static distanceSquared(x1: number, y1: number, x2: number, y2: number) {
|
||||
return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - DynamicTexture
|
||||
*
|
||||
* A DynamicTexture can be thought of as a mini canvas into which you can draw anything.
|
||||
* Game Objects can be assigned a DynamicTexture, so when they render in the world they do so
|
||||
* based on the contents of the texture at the time. This allows you to create powerful effects
|
||||
* once and have them replicated across as many game objects as you like.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class DynamicTexture {
|
||||
|
||||
constructor(game: Game, key: string, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.canvas.width = width;
|
||||
this.canvas.height = height;
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
this.bounds = new Rectangle(0, 0, width, height);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
private _sw: number = 0;
|
||||
private _sh: number = 0;
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _dw: number = 0;
|
||||
private _dh: number = 0;
|
||||
|
||||
// Input / Output nodes?
|
||||
|
||||
public bounds: Rectangle;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
public getPixel(x: number, y: number): number {
|
||||
|
||||
//r = imageData.data[0];
|
||||
//g = imageData.data[1];
|
||||
//b = imageData.data[2];
|
||||
//a = imageData.data[3];
|
||||
var imageData = this.context.getImageData(x, y, 1, 1);
|
||||
|
||||
return this.getColor(imageData.data[0], imageData.data[1], imageData.data[2]);
|
||||
|
||||
}
|
||||
|
||||
public getPixel32(x: number, y: number) {
|
||||
|
||||
var imageData = this.context.getImageData(x, y, 1, 1);
|
||||
|
||||
return this.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]);
|
||||
|
||||
}
|
||||
|
||||
// Returns a CanvasPixelArray
|
||||
public getPixels(rect: Rectangle) {
|
||||
|
||||
return this.context.getImageData(rect.x, rect.y, rect.width, rect.height);
|
||||
|
||||
}
|
||||
|
||||
public setPixel(x: number, y: number, color: number) {
|
||||
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillRect(x, y, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
public setPixel32(x: number, y: number, color: number) {
|
||||
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillRect(x, y, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
public setPixels(rect: Rectangle, input) {
|
||||
|
||||
this.context.putImageData(input, rect.x, rect.y);
|
||||
|
||||
}
|
||||
|
||||
public fillRect(rect: Rectangle, color: number) {
|
||||
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
|
||||
|
||||
}
|
||||
|
||||
public pasteImage(key: string, frame?: number = -1, destX?: number = 0, destY?: number = 0, destWidth?: number = null, destHeight?: number = null) {
|
||||
|
||||
var texture = null;
|
||||
var frameData;
|
||||
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
this._dx = destX;
|
||||
this._dy = destY;
|
||||
|
||||
// TODO - Load a frame from a sprite sheet, otherwise we'll draw the whole lot
|
||||
if (frame > -1)
|
||||
{
|
||||
//if (this._game.cache.isSpriteSheet(key))
|
||||
//{
|
||||
// texture = this._game.cache.getImage(key);
|
||||
//this.animations.loadFrameData(this._game.cache.getFrameData(key));
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = this._game.cache.getImage(key);
|
||||
this._sw = texture.width;
|
||||
this._sh = texture.height;
|
||||
this._dw = texture.width;
|
||||
this._dh = texture.height;
|
||||
}
|
||||
|
||||
if (destWidth !== null)
|
||||
{
|
||||
this._dw = destWidth;
|
||||
}
|
||||
|
||||
if (destHeight !== null)
|
||||
{
|
||||
this._dh = destHeight;
|
||||
}
|
||||
|
||||
if (texture != null)
|
||||
{
|
||||
this.context.drawImage(
|
||||
texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
this._sh, // Source Height
|
||||
this._dx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._dy, // Destination Y
|
||||
this._dw, // Destination Width (always same as Source Width unless scaled)
|
||||
this._dh // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO - Add in support for: alphaBitmapData: BitmapData = null, alphaPoint: Point = null, mergeAlpha: bool = false
|
||||
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point) {
|
||||
|
||||
// Swap for drawImage if the sourceRect is the same size as the sourceTexture to avoid a costly getImageData call
|
||||
if (sourceRect.equals(this.bounds) == true)
|
||||
{
|
||||
this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public clear() {
|
||||
|
||||
this.context.clearRect(0, 0, this.bounds.width, this.bounds.height);
|
||||
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an alpha and 3 color values this will return an integer representation of it
|
||||
*
|
||||
* @param alpha The Alpha value (between 0 and 255)
|
||||
* @param red The Red channel value (between 0 and 255)
|
||||
* @param green The Green channel value (between 0 and 255)
|
||||
* @param blue The Blue channel value (between 0 and 255)
|
||||
*
|
||||
* @return A native color value integer (format: 0xAARRGGBB)
|
||||
*/
|
||||
private getColor32(alpha: number, red: number, green: number, blue: number): number {
|
||||
|
||||
return alpha << 24 | red << 16 | green << 8 | blue;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given 3 color values this will return an integer representation of it
|
||||
*
|
||||
* @param red The Red channel value (between 0 and 255)
|
||||
* @param green The Green channel value (between 0 and 255)
|
||||
* @param blue The Blue channel value (between 0 and 255)
|
||||
*
|
||||
* @return A native color value integer (format: 0xRRGGBB)
|
||||
*/
|
||||
private getColor(red: number, green: number, blue: number): number {
|
||||
|
||||
return red << 16 | green << 8 | blue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-414
@@ -1,414 +0,0 @@
|
||||
/// <reference path="AnimationManager.ts" />
|
||||
/// <reference path="Basic.ts" />
|
||||
/// <reference path="Cache.ts" />
|
||||
/// <reference path="CameraManager.ts" />
|
||||
/// <reference path="Collision.ts" />
|
||||
/// <reference path="DynamicTexture.ts" />
|
||||
/// <reference path="GameMath.ts" />
|
||||
/// <reference path="Group.ts" />
|
||||
/// <reference path="Loader.ts" />
|
||||
/// <reference path="Motion.ts" />
|
||||
/// <reference path="Signal.ts" />
|
||||
/// <reference path="SignalBinding.ts" />
|
||||
/// <reference path="SoundManager.ts" />
|
||||
/// <reference path="Stage.ts" />
|
||||
/// <reference path="Time.ts" />
|
||||
/// <reference path="TweenManager.ts" />
|
||||
/// <reference path="World.ts" />
|
||||
/// <reference path="system/Device.ts" />
|
||||
/// <reference path="system/RandomDataGenerator.ts" />
|
||||
/// <reference path="system/RequestAnimationFrame.ts" />
|
||||
/// <reference path="system/input/Input.ts" />
|
||||
/// <reference path="system/input/Keyboard.ts" />
|
||||
/// <reference path="system/input/Mouse.ts" />
|
||||
/// <reference path="system/input/Touch.ts" />
|
||||
/// <reference path="gameobjects/Emitter.ts" />
|
||||
/// <reference path="gameobjects/GameObject.ts" />
|
||||
/// <reference path="gameobjects/GeomSprite.ts" />
|
||||
/// <reference path="gameobjects/Particle.ts" />
|
||||
/// <reference path="gameobjects/Sprite.ts" />
|
||||
/// <reference path="gameobjects/Tilemap.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Game
|
||||
*
|
||||
* This is where the magic happens. The Game object is the heart of your game, providing quick access to common
|
||||
* functions and handling the boot process.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Game {
|
||||
|
||||
constructor(callbackContext, parent?: string = '', width?: number = 800, height?: number = 600, initCallback = null, createCallback = null, updateCallback = null, renderCallback = null) {
|
||||
|
||||
this.callbackContext = callbackContext;
|
||||
this.onInitCallback = initCallback;
|
||||
this.onCreateCallback = createCallback;
|
||||
this.onUpdateCallback = updateCallback;
|
||||
this.onRenderCallback = renderCallback;
|
||||
|
||||
if (document.readyState === 'complete' || document.readyState === 'interactive')
|
||||
{
|
||||
this.boot(parent, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
document.addEventListener('DOMContentLoaded', () => this.boot(parent, width, height), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _raf: RequestAnimationFrame;
|
||||
private _maxAccumulation: number = 32;
|
||||
private _accumulator: number = 0;
|
||||
private _step: number = 0;
|
||||
private _loadComplete: bool = false;
|
||||
private _paused: bool = false;
|
||||
private _pendingState = null;
|
||||
|
||||
// Event callbacks
|
||||
public callbackContext;
|
||||
public onInitCallback = null;
|
||||
public onCreateCallback = null;
|
||||
public onUpdateCallback = null;
|
||||
public onRenderCallback = null;
|
||||
public onPausedCallback = null;
|
||||
|
||||
public camera: Camera; // quick reference to the default created camera, access the rest via .world
|
||||
public cache: Cache;
|
||||
public collision: Collision;
|
||||
public input: Input;
|
||||
public loader: Loader;
|
||||
public math: GameMath;
|
||||
public motion: Motion;
|
||||
public sound: SoundManager;
|
||||
public stage: Stage;
|
||||
public time: Time;
|
||||
public tweens: TweenManager;
|
||||
public world: World;
|
||||
public rnd: RandomDataGenerator;
|
||||
public device: Device;
|
||||
|
||||
public isBooted: bool = false;
|
||||
|
||||
private boot(parent: string, width: number, height: number) {
|
||||
|
||||
if (!document.body)
|
||||
{
|
||||
window.setTimeout(() => this.boot(parent, width, height), 13);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.device = new Device();
|
||||
this.motion = new Motion(this);
|
||||
this.math = new GameMath(this);
|
||||
this.stage = new Stage(this, parent, width, height);
|
||||
this.world = new World(this, width, height);
|
||||
this.sound = new SoundManager(this);
|
||||
this.cache = new Cache(this);
|
||||
this.collision = new Collision(this);
|
||||
this.loader = new Loader(this, this.loadComplete);
|
||||
this.time = new Time(this);
|
||||
this.tweens = new TweenManager(this);
|
||||
this.input = new Input(this);
|
||||
this.rnd = new RandomDataGenerator([(Date.now() * Math.random()).toString()]);
|
||||
|
||||
this.framerate = 60;
|
||||
|
||||
// Display the default game screen?
|
||||
if (this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null)
|
||||
{
|
||||
this.isBooted = false;
|
||||
this.stage.drawInitScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isBooted = true;
|
||||
this._loadComplete = false;
|
||||
|
||||
this._raf = new RequestAnimationFrame(this.loop, this);
|
||||
|
||||
if (this._pendingState)
|
||||
{
|
||||
this.switchState(this._pendingState, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.startState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private loadComplete() {
|
||||
|
||||
// Called when the loader has finished after init was run
|
||||
this._loadComplete = true;
|
||||
|
||||
}
|
||||
|
||||
private loop() {
|
||||
|
||||
this.time.update();
|
||||
this.tweens.update();
|
||||
|
||||
if (this._paused == true)
|
||||
{
|
||||
if (this.onPausedCallback !== null)
|
||||
{
|
||||
this.onPausedCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
this.input.update();
|
||||
this.stage.update();
|
||||
|
||||
this._accumulator += this.time.delta;
|
||||
|
||||
if (this._accumulator > this._maxAccumulation)
|
||||
{
|
||||
this._accumulator = this._maxAccumulation;
|
||||
}
|
||||
|
||||
while (this._accumulator >= this._step)
|
||||
{
|
||||
this.time.elapsed = this.time.timeScale * (this._step / 1000);
|
||||
this.world.update();
|
||||
this._accumulator = this._accumulator - this._step;
|
||||
}
|
||||
|
||||
if (this._loadComplete && this.onUpdateCallback)
|
||||
{
|
||||
this.onUpdateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this.world.render();
|
||||
|
||||
if (this._loadComplete && this.onRenderCallback)
|
||||
{
|
||||
this.onRenderCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private startState() {
|
||||
|
||||
if (this.onInitCallback !== null)
|
||||
{
|
||||
this.loader.reset();
|
||||
|
||||
this.onInitCallback.call(this.callbackContext);
|
||||
|
||||
// Is the loader empty?
|
||||
if (this.loader.queueSize == 0)
|
||||
{
|
||||
if (this.onCreateCallback !== null)
|
||||
{
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this._loadComplete = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No init? Then there was nothing to load either
|
||||
if (this.onCreateCallback !== null)
|
||||
{
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this._loadComplete = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public setCallbacks(initCallback = null, createCallback = null, updateCallback = null, renderCallback = null) {
|
||||
|
||||
this.onInitCallback = initCallback;
|
||||
this.onCreateCallback = createCallback;
|
||||
this.onUpdateCallback = updateCallback;
|
||||
this.onRenderCallback = renderCallback;
|
||||
|
||||
}
|
||||
|
||||
public switchState(state, clearWorld: bool = true, clearCache: bool = false) {
|
||||
|
||||
if (this.isBooted == false)
|
||||
{
|
||||
this._pendingState = state;
|
||||
return;
|
||||
}
|
||||
|
||||
// Prototype?
|
||||
if (typeof state === 'function')
|
||||
{
|
||||
state = new state(this);
|
||||
}
|
||||
|
||||
// Ok, have we got the right functions?
|
||||
if (state['create'] || state['update'])
|
||||
{
|
||||
this.callbackContext = state;
|
||||
|
||||
this.onInitCallback = null;
|
||||
this.onCreateCallback = null;
|
||||
this.onUpdateCallback = null;
|
||||
this.onRenderCallback = null;
|
||||
this.onPausedCallback = null;
|
||||
|
||||
// Bingo, let's set them up
|
||||
if (state['init'])
|
||||
{
|
||||
this.onInitCallback = state['init'];
|
||||
}
|
||||
|
||||
if (state['create'])
|
||||
{
|
||||
this.onCreateCallback = state['create'];
|
||||
}
|
||||
|
||||
if (state['update'])
|
||||
{
|
||||
this.onUpdateCallback = state['update'];
|
||||
}
|
||||
|
||||
if (state['render'])
|
||||
{
|
||||
this.onRenderCallback = state['render'];
|
||||
}
|
||||
|
||||
if (state['paused'])
|
||||
{
|
||||
this.onPausedCallback = state['paused'];
|
||||
}
|
||||
|
||||
if (clearWorld)
|
||||
{
|
||||
this.world.destroy();
|
||||
|
||||
if (clearCache == true)
|
||||
{
|
||||
this.cache.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
this._loadComplete = false;
|
||||
|
||||
this.startState();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Error("Invalid State object given. Must contain at least a create or update function.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Nuke the whole game from orbit
|
||||
public destroy() {
|
||||
|
||||
this.callbackContext = null;
|
||||
this.onInitCallback = null;
|
||||
this.onCreateCallback = null;
|
||||
this.onUpdateCallback = null;
|
||||
this.onRenderCallback = null;
|
||||
this.onPausedCallback = null;
|
||||
this.camera = null;
|
||||
this.cache = null;
|
||||
this.input = null;
|
||||
this.loader = null;
|
||||
this.sound = null;
|
||||
this.stage = null;
|
||||
this.time = null;
|
||||
this.world = null;
|
||||
this.isBooted = false;
|
||||
|
||||
}
|
||||
|
||||
public get paused(): bool {
|
||||
return this._paused;
|
||||
}
|
||||
|
||||
public set paused(value: bool) {
|
||||
|
||||
if (value == true && this._paused == false)
|
||||
{
|
||||
this._paused = true;
|
||||
}
|
||||
else if (value == false && this._paused == true)
|
||||
{
|
||||
this._paused = false;
|
||||
this.time.time = Date.now();
|
||||
this.input.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get framerate(): number {
|
||||
return 1000 / this._step;
|
||||
}
|
||||
|
||||
public set framerate(value: number) {
|
||||
|
||||
this._step = 1000 / value;
|
||||
|
||||
if (this._maxAccumulation < this._step)
|
||||
{
|
||||
this._maxAccumulation = this._step;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Handy Proxy methods
|
||||
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this.world.createCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
public createGeomSprite(x: number, y: number): GeomSprite {
|
||||
return this.world.createGeomSprite(x, y);
|
||||
}
|
||||
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return this.world.createSprite(x, y, key);
|
||||
}
|
||||
|
||||
public createDynamicTexture(key: string, width: number, height: number): DynamicTexture {
|
||||
return this.world.createDynamicTexture(key, width, height);
|
||||
}
|
||||
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return this.world.createGroup(MaxSize);
|
||||
}
|
||||
|
||||
public createParticle(): Particle {
|
||||
return this.world.createParticle();
|
||||
}
|
||||
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return this.world.createEmitter(x, y, size);
|
||||
}
|
||||
|
||||
public createTilemap(key: string, mapData: string, format: number, tileWidth?: number, tileHeight?: number): Tilemap {
|
||||
return this.world.createTilemap(key, mapData, format, tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
public createTween(obj): Tween {
|
||||
return this.tweens.create(obj);
|
||||
}
|
||||
|
||||
public collide(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null): bool {
|
||||
return this.collision.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, Collision.separate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-745
@@ -1,745 +0,0 @@
|
||||
/// <reference path="Basic.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Group
|
||||
*
|
||||
* This class is used for organising, updating and sorting game objects.
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Group extends Basic {
|
||||
|
||||
constructor(game: Game, MaxSize?: number = 0) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.isGroup = true;
|
||||
this.members = [];
|
||||
this.length = 0;
|
||||
this._maxSize = MaxSize;
|
||||
this._marker = 0;
|
||||
this._sortIndex = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use with <code>sort()</code> to sort in ascending order.
|
||||
*/
|
||||
public static ASCENDING: number = -1;
|
||||
|
||||
/**
|
||||
* Use with <code>sort()</code> to sort in descending order.
|
||||
*/
|
||||
public static DESCENDING: number = 1;
|
||||
|
||||
/**
|
||||
* Array of all the <code>Basic</code>s that exist in this group.
|
||||
*/
|
||||
public members: Basic[];
|
||||
|
||||
/**
|
||||
* The number of entries in the members array.
|
||||
* For performance and safety you should check this variable
|
||||
* instead of members.length unless you really know what you're doing!
|
||||
*/
|
||||
public length: number;
|
||||
|
||||
/**
|
||||
* Internal tracker for the maximum capacity of the group.
|
||||
* Default is 0, or no max capacity.
|
||||
*/
|
||||
private _maxSize: number;
|
||||
|
||||
/**
|
||||
* Internal helper variable for recycling objects a la <code>Emitter</code>.
|
||||
*/
|
||||
private _marker: number;
|
||||
|
||||
/**
|
||||
* Helper for sort.
|
||||
*/
|
||||
private _sortIndex: string;
|
||||
|
||||
/**
|
||||
* Helper for sort.
|
||||
*/
|
||||
private _sortOrder: number;
|
||||
|
||||
/**
|
||||
* Override this function to handle any deleting or "shutdown" type operations you might need,
|
||||
* such as removing traditional Flash children like Basic objects.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
if (this.members != null)
|
||||
{
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
basic.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
this.members.length = 0;
|
||||
}
|
||||
|
||||
this._sortIndex = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically goes through and calls update on everything you added.
|
||||
*/
|
||||
public update() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.active)
|
||||
{
|
||||
basic.preUpdate();
|
||||
basic.update();
|
||||
basic.postUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.visible)
|
||||
{
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum capacity of this group. Default is 0, meaning no max capacity, and the group can just grow.
|
||||
*/
|
||||
public get maxSize(): number {
|
||||
return this._maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public set maxSize(Size: number) {
|
||||
|
||||
this._maxSize = Size;
|
||||
|
||||
if (this._marker >= this._maxSize)
|
||||
{
|
||||
this._marker = 0;
|
||||
}
|
||||
|
||||
if ((this._maxSize == 0) || (this.members == null) || (this._maxSize >= this.members.length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//If the max size has shrunk, we need to get rid of some objects
|
||||
var basic: Basic;
|
||||
var i: number = this._maxSize;
|
||||
var l: number = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
basic.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
this.length = this.members.length = this._maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new <code>Basic</code> subclass (Basic, Basic, Enemy, etc) to the group.
|
||||
* Group will try to replace a null member of the array first.
|
||||
* Failing that, Group will add it to the end of the member array,
|
||||
* assuming there is room for it, and doubling the size of the array if necessary.
|
||||
*
|
||||
* <p>WARNING: If the group has a maxSize that has already been met,
|
||||
* the object will NOT be added to the group!</p>
|
||||
*
|
||||
* @param Object The object you want to add to the group.
|
||||
*
|
||||
* @return The same <code>Basic</code> object that was passed in.
|
||||
*/
|
||||
public add(Object: Basic) {
|
||||
|
||||
//Don't bother adding an object twice.
|
||||
if (this.members.indexOf(Object) >= 0)
|
||||
{
|
||||
return Object;
|
||||
}
|
||||
|
||||
//First, look for a null entry where we can add the object.
|
||||
var i: number = 0;
|
||||
var l: number = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
if (this.members[i] == null)
|
||||
{
|
||||
this.members[i] = Object;
|
||||
|
||||
if (i >= this.length)
|
||||
{
|
||||
this.length = i + 1;
|
||||
}
|
||||
|
||||
return Object;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
//Failing that, expand the array (if we can) and add the object.
|
||||
if (this._maxSize > 0)
|
||||
{
|
||||
if (this.members.length >= this._maxSize)
|
||||
{
|
||||
return Object;
|
||||
}
|
||||
else if (this.members.length * 2 <= this._maxSize)
|
||||
{
|
||||
this.members.length *= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.members.length = this._maxSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.members.length *= 2;
|
||||
}
|
||||
|
||||
//If we made it this far, then we successfully grew the group,
|
||||
//and we can go ahead and add the object at the first open slot.
|
||||
this.members[i] = Object;
|
||||
this.length = i + 1;
|
||||
|
||||
return Object;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
|
||||
*
|
||||
* <p>If you specified a maximum size for this group (like in Emitter),
|
||||
* then recycle will employ what we're calling "rotating" recycling.
|
||||
* Recycle() will first check to see if the group is at capacity yet.
|
||||
* If group is not yet at capacity, recycle() returns a new object.
|
||||
* If the group IS at capacity, then recycle() just returns the next object in line.</p>
|
||||
*
|
||||
* <p>If you did NOT specify a maximum size for this group,
|
||||
* then recycle() will employ what we're calling "grow-style" recycling.
|
||||
* Recycle() will return either the first object with exists == false,
|
||||
* or, finding none, add a new object to the array,
|
||||
* doubling the size of the array if necessary.</p>
|
||||
*
|
||||
* <p>WARNING: If this function needs to create a new object,
|
||||
* and no object class was provided, it will return null
|
||||
* instead of a valid object!</p>
|
||||
*
|
||||
* @param ObjectClass The class type you want to recycle (e.g. Basic, EvilRobot, etc). Do NOT "new" the class in the parameter!
|
||||
*
|
||||
* @return A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).
|
||||
*/
|
||||
public recycle(ObjectClass = null) {
|
||||
|
||||
var basic;
|
||||
|
||||
if (this._maxSize > 0)
|
||||
{
|
||||
if (this.length < this._maxSize)
|
||||
{
|
||||
if (ObjectClass == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.add(new ObjectClass());
|
||||
}
|
||||
else
|
||||
{
|
||||
basic = this.members[this._marker++];
|
||||
|
||||
if (this._marker >= this._maxSize)
|
||||
{
|
||||
this._marker = 0;
|
||||
}
|
||||
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
basic = this.getFirstAvailable(ObjectClass);
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
|
||||
if (ObjectClass == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.add(new ObjectClass());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an object from the group.
|
||||
*
|
||||
* @param Object The <code>Basic</code> you want to remove.
|
||||
* @param Splice Whether the object should be cut from the array entirely or not.
|
||||
*
|
||||
* @return The removed object.
|
||||
*/
|
||||
public remove(Object: Basic, Splice: bool = false): Basic {
|
||||
|
||||
var index: number = this.members.indexOf(Object);
|
||||
|
||||
if ((index < 0) || (index >= this.members.length))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Splice)
|
||||
{
|
||||
this.members.splice(index, 1);
|
||||
this.length--;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.members[index] = null;
|
||||
}
|
||||
|
||||
return Object;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces an existing <code>Basic</code> with a new one.
|
||||
*
|
||||
* @param OldObject The object you want to replace.
|
||||
* @param NewObject The new object you want to use instead.
|
||||
*
|
||||
* @return The new object.
|
||||
*/
|
||||
public replace(OldObject: Basic, NewObject: Basic): Basic {
|
||||
|
||||
var index: number = this.members.indexOf(OldObject);
|
||||
|
||||
if ((index < 0) || (index >= this.members.length))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
this.members[index] = NewObject;
|
||||
|
||||
return NewObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to sort the group according to a particular value and order.
|
||||
* For example, to sort game objects for Zelda-style overlaps you might call
|
||||
* <code>myGroup.sort("y",Group.ASCENDING)</code> at the bottom of your
|
||||
* <code>State.update()</code> override. To sort all existing objects after
|
||||
* a big explosion or bomb attack, you might call <code>myGroup.sort("exists",Group.DESCENDING)</code>.
|
||||
*
|
||||
* @param Index The <code>string</code> name of the member variable you want to sort on. Default value is "y".
|
||||
* @param Order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
|
||||
*/
|
||||
public sort(Index: string = "y", Order: number = Group.ASCENDING) {
|
||||
|
||||
this._sortIndex = Index;
|
||||
this._sortOrder = Order;
|
||||
this.members.sort(this.sortHandler);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through and set the specified variable to the specified value on all members of the group.
|
||||
*
|
||||
* @param VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor".
|
||||
* @param Value The value you want to assign to that variable.
|
||||
* @param Recurse Default value is true, meaning if <code>setAll()</code> encounters a member that is a group, it will call <code>setAll()</code> on that group rather than modifying its variable.
|
||||
*/
|
||||
public setAll(VariableName: string, Value: Object, Recurse: bool = true) {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
{
|
||||
<Group> basic['setAll'](VariableName, Value, Recurse);
|
||||
}
|
||||
else
|
||||
{
|
||||
basic[VariableName] = Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go through and call the specified function on all members of the group.
|
||||
* Currently only works on functions that have no required parameters.
|
||||
*
|
||||
* @param FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()".
|
||||
* @param Recurse Default value is true, meaning if <code>callAll()</code> encounters a member that is a group, it will call <code>callAll()</code> on that group rather than calling the group's function.
|
||||
*/
|
||||
public callAll(FunctionName: string, Recurse: bool = true) {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
{
|
||||
<Group> basic['callAll'](FunctionName, Recurse);
|
||||
}
|
||||
else
|
||||
{
|
||||
basic[FunctionName]();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public forEach(callback, Recurse: bool = false) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (Recurse && (basic.isGroup == true))
|
||||
{
|
||||
basic.forEach(callback, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(this, basic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with exists == false in the group.
|
||||
* This is handy for recycling in general, e.g. respawning enemies.
|
||||
*
|
||||
* @param ObjectClass An optional parameter that lets you narrow the results to instances of this particular class.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as not existing.
|
||||
*/
|
||||
public getFirstAvailable(ObjectClass = null) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && !basic.exists && ((ObjectClass == null) || (typeof basic === ObjectClass)))
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first index set to 'null'.
|
||||
* Returns -1 if no index stores a null object.
|
||||
*
|
||||
* @return An <code>int</code> indicating the first null slot in the group.
|
||||
*/
|
||||
public getFirstNull(): number {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
var l: number = this.members.length;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
if (this.members[i] == null)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with exists == true in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as existing.
|
||||
*/
|
||||
public getFirstExtant(): Basic {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with dead == false in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as not dead.
|
||||
*/
|
||||
public getFirstAlive(): Basic {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.alive)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with dead == true in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as dead.
|
||||
*/
|
||||
public getFirstDead(): Basic {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && !basic.alive)
|
||||
{
|
||||
return basic;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are not dead.
|
||||
*
|
||||
* @return The number of <code>Basic</code>s flagged as not dead. Returns -1 if group is empty.
|
||||
*/
|
||||
public countLiving(): number {
|
||||
|
||||
var count: number = -1;
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (count < 0)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if (basic.exists && basic.alive)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are dead.
|
||||
*
|
||||
* @return The number of <code>Basic</code>s flagged as dead. Returns -1 if group is empty.
|
||||
*/
|
||||
public countDead(): number {
|
||||
|
||||
var count: number = -1;
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (count < 0)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if (!basic.alive)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a member at random from the group.
|
||||
*
|
||||
* @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
|
||||
* @param Length Optional restriction on the number of values you want to randomly select from.
|
||||
*
|
||||
* @return A <code>Basic</code> from the members list.
|
||||
*/
|
||||
public getRandom(StartIndex: number = 0, Length: number = 0): Basic {
|
||||
|
||||
if (Length == 0)
|
||||
{
|
||||
Length = this.length;
|
||||
}
|
||||
|
||||
return this._game.math.getRandom(this.members, StartIndex, Length);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all instances of <code>Basic</code> subclass (Basic, Block, etc) from the list.
|
||||
* WARNING: does not destroy() or kill() any of these objects!
|
||||
*/
|
||||
public clear() {
|
||||
this.length = this.members.length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls kill on the group's members and then on the group itself.
|
||||
*/
|
||||
public kill() {
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
{
|
||||
basic.kill();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for the sort process.
|
||||
*
|
||||
* @param Obj1 The first object being sorted.
|
||||
* @param Obj2 The second object being sorted.
|
||||
*
|
||||
* @return An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
|
||||
*/
|
||||
public sortHandler(Obj1: Basic, Obj2: Basic): number {
|
||||
|
||||
if (Obj1[this._sortIndex] < Obj2[this._sortIndex])
|
||||
{
|
||||
return this._sortOrder;
|
||||
}
|
||||
else if (Obj1[this._sortIndex] > Obj2[this._sortIndex])
|
||||
{
|
||||
return -this._sortOrder;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Loader
|
||||
*
|
||||
* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
|
||||
* It uses a combination of Image() loading and xhr and provides for progress and completion callbacks.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Loader {
|
||||
|
||||
constructor(game: Game, callback) {
|
||||
|
||||
this._game = game;
|
||||
this._gameCreateComplete = callback;
|
||||
this._keys = [];
|
||||
this._fileList = {};
|
||||
this._xhr = new XMLHttpRequest();
|
||||
this._queueSize = 0;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _keys: string[];
|
||||
private _fileList;
|
||||
private _gameCreateComplete;
|
||||
private _onComplete;
|
||||
private _onFileLoad;
|
||||
private _progressChunk: number;
|
||||
private _xhr: XMLHttpRequest;
|
||||
private _queueSize: number;
|
||||
|
||||
public hasLoaded: bool;
|
||||
public progress: number;
|
||||
|
||||
public reset() {
|
||||
this._queueSize = 0;
|
||||
}
|
||||
|
||||
public get queueSize(): number {
|
||||
|
||||
return this._queueSize;
|
||||
|
||||
}
|
||||
|
||||
public addImageFile(key: string, url: string) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._queueSize++;
|
||||
this._fileList[key] = { type: 'image', key: key, url: url, data: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addSpriteSheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number = -1) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._queueSize++;
|
||||
this._fileList[key] = { type: 'spritesheet', key: key, url: url, data: null, frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addTextureAtlas(key: string, url: string, jsonURL?: string = null, jsonData? = null) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
if (jsonURL !== null)
|
||||
{
|
||||
// A URL to a json file has been given
|
||||
this._queueSize++;
|
||||
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: jsonURL, jsonData: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
// A json string or object has been given
|
||||
if (typeof jsonData === 'string')
|
||||
{
|
||||
var data = JSON.parse(jsonData);
|
||||
// Malformed?
|
||||
if (data['frames'])
|
||||
{
|
||||
this._queueSize++;
|
||||
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: null, jsonData: data['frames'], error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Malformed?
|
||||
if (jsonData['frames'])
|
||||
{
|
||||
this._queueSize++;
|
||||
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: null, jsonData: jsonData['frames'], error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addAudioFile(key: string, url: string) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._queueSize++;
|
||||
this._fileList[key] = { type: 'audio', key: key, url: url, data: null, buffer: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public addTextFile(key: string, url: string) {
|
||||
|
||||
if (this.checkKeyExists(key) === false)
|
||||
{
|
||||
this._queueSize++;
|
||||
this._fileList[key] = { type: 'text', key: key, url: url, data: null, error: false, loaded: false };
|
||||
this._keys.push(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public removeFile(key: string) {
|
||||
|
||||
delete this._fileList[key];
|
||||
|
||||
}
|
||||
|
||||
public removeAll() {
|
||||
|
||||
this._fileList = {};
|
||||
|
||||
}
|
||||
|
||||
public load(onFileLoadCallback = null, onCompleteCallback = null) {
|
||||
|
||||
this.progress = 0;
|
||||
this.hasLoaded = false;
|
||||
|
||||
this._onComplete = onCompleteCallback;
|
||||
|
||||
if (onCompleteCallback == null)
|
||||
{
|
||||
this._onComplete = this._game.onCreateCallback;
|
||||
}
|
||||
|
||||
this._onFileLoad = onFileLoadCallback;
|
||||
|
||||
if (this._keys.length > 0)
|
||||
{
|
||||
this._progressChunk = 100 / this._keys.length;
|
||||
this.loadFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.progress = 1;
|
||||
this.hasLoaded = true;
|
||||
this._gameCreateComplete.call(this._game);
|
||||
|
||||
if (this._onComplete !== null)
|
||||
{
|
||||
this._onComplete.call(this._game.callbackContext);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private loadFile() {
|
||||
|
||||
var file = this._fileList[this._keys.pop()];
|
||||
|
||||
// Image or Data?
|
||||
|
||||
switch (file.type)
|
||||
{
|
||||
case 'image':
|
||||
case 'spritesheet':
|
||||
case 'textureatlas':
|
||||
file.data = new Image();
|
||||
file.data.name = file.key;
|
||||
file.data.onload = () => this.fileComplete(file.key);
|
||||
file.data.onerror = () => this.fileError(file.key);
|
||||
file.data.src = file.url;
|
||||
break;
|
||||
|
||||
case 'audio':
|
||||
this._xhr.open("GET", file.url, true);
|
||||
this._xhr.responseType = "arraybuffer";
|
||||
this._xhr.onload = () => this.fileComplete(file.key);
|
||||
this._xhr.onerror = () => this.fileError(file.key);
|
||||
this._xhr.send();
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
this._xhr.open("GET", file.url, true);
|
||||
this._xhr.responseType = "text";
|
||||
this._xhr.onload = () => this.fileComplete(file.key);
|
||||
this._xhr.onerror = () => this.fileError(file.key);
|
||||
this._xhr.send();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fileError(key: string) {
|
||||
|
||||
this._fileList[key].loaded = true;
|
||||
this._fileList[key].error = true;
|
||||
|
||||
this.nextFile(key, false);
|
||||
|
||||
}
|
||||
|
||||
private fileComplete(key: string) {
|
||||
|
||||
this._fileList[key].loaded = true;
|
||||
|
||||
var file = this._fileList[key];
|
||||
var loadNext: bool = true;
|
||||
|
||||
switch (file.type)
|
||||
{
|
||||
case 'image':
|
||||
this._game.cache.addImage(file.key, file.url, file.data);
|
||||
break;
|
||||
|
||||
case 'spritesheet':
|
||||
this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax);
|
||||
break;
|
||||
|
||||
case 'textureatlas':
|
||||
if (file.jsonURL == null)
|
||||
{
|
||||
this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.jsonData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load the JSON before carrying on with the next file
|
||||
loadNext = false;
|
||||
this._xhr.open("GET", file.jsonURL, true);
|
||||
this._xhr.responseType = "text";
|
||||
this._xhr.onload = () => this.jsonLoadComplete(file.key);
|
||||
this._xhr.onerror = () => this.jsonLoadError(file.key);
|
||||
this._xhr.send();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'audio':
|
||||
file.data = this._xhr.response;
|
||||
this._game.cache.addSound(file.key, file.url, file.data);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
file.data = this._xhr.response;
|
||||
this._game.cache.addText(file.key, file.url, file.data);
|
||||
break;
|
||||
}
|
||||
|
||||
if (loadNext)
|
||||
{
|
||||
this.nextFile(key, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private jsonLoadComplete(key: string) {
|
||||
|
||||
var data = JSON.parse(this._xhr.response);
|
||||
|
||||
// Malformed?
|
||||
if (data['frames'])
|
||||
{
|
||||
var file = this._fileList[key];
|
||||
this._game.cache.addTextureAtlas(file.key, file.url, file.data, data['frames']);
|
||||
}
|
||||
|
||||
this.nextFile(key, true);
|
||||
|
||||
}
|
||||
|
||||
private jsonLoadError(key: string) {
|
||||
|
||||
var file = this._fileList[key];
|
||||
file.error = true;
|
||||
this.nextFile(key, true);
|
||||
|
||||
}
|
||||
|
||||
private nextFile(previousKey: string, success: bool) {
|
||||
|
||||
this.progress = Math.round(this.progress + this._progressChunk);
|
||||
|
||||
if (this.progress > 1)
|
||||
{
|
||||
this.progress = 1;
|
||||
}
|
||||
|
||||
if (this._onFileLoad)
|
||||
{
|
||||
this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success);
|
||||
}
|
||||
|
||||
if (this._keys.length > 0)
|
||||
{
|
||||
this.loadFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hasLoaded = true;
|
||||
this.removeAll();
|
||||
this._gameCreateComplete.call(this._game);
|
||||
|
||||
if (this._onComplete !== null)
|
||||
{
|
||||
this._onComplete.call(this._game.callbackContext);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private checkKeyExists(key: string): bool {
|
||||
|
||||
if (this._fileList[key])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,404 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="gameobjects/GameObject.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Motion
|
||||
*
|
||||
* The Motion class contains lots of useful functions for moving game objects around in world space.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Motion {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
|
||||
*
|
||||
* @param Velocity Any component of velocity (e.g. 20).
|
||||
* @param Acceleration Rate at which the velocity is changing.
|
||||
* @param Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
|
||||
* @param Max An absolute value cap for the velocity.
|
||||
*
|
||||
* @return The altered Velocity value.
|
||||
*/
|
||||
public computeVelocity(Velocity: number, Acceleration: number = 0, Drag: number = 0, Max: number = 10000): number {
|
||||
|
||||
if (Acceleration !== 0)
|
||||
{
|
||||
Velocity += Acceleration * this._game.time.elapsed;
|
||||
}
|
||||
else if (Drag !== 0)
|
||||
{
|
||||
var drag: number = Drag * this._game.time.elapsed;
|
||||
|
||||
if (Velocity - drag > 0)
|
||||
{
|
||||
Velocity = Velocity - drag;
|
||||
}
|
||||
else if (Velocity + drag < 0)
|
||||
{
|
||||
Velocity += drag;
|
||||
}
|
||||
else
|
||||
{
|
||||
Velocity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Velocity != 0) && (Max != 10000))
|
||||
{
|
||||
if (Velocity > Max)
|
||||
{
|
||||
Velocity = Max;
|
||||
}
|
||||
else if (Velocity < -Max)
|
||||
{
|
||||
Velocity = -Max;
|
||||
}
|
||||
}
|
||||
|
||||
return Velocity;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the angle and speed calculate the velocity and return it as a Point
|
||||
*
|
||||
* @param angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
|
||||
* @param speed The speed it will move, in pixels per second sq
|
||||
*
|
||||
* @return A Point where Point.x contains the velocity x value and Point.y contains the velocity y value
|
||||
*/
|
||||
public velocityFromAngle(angle: number, speed: number): Point {
|
||||
|
||||
var a: number = this._game.math.degreesToRadians(angle);
|
||||
|
||||
return new Point((Math.cos(a) * speed), (Math.sin(a) * speed));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source Sprite x/y velocity so it will move directly towards the destination Sprite at the speed given (in pixels per second)<br>
|
||||
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
|
||||
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
|
||||
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
|
||||
* If you need the object to accelerate, see accelerateTowardsObject() instead
|
||||
* Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all)
|
||||
*
|
||||
* @param source The Sprite on which the velocity will be set
|
||||
* @param dest The Sprite where the source object will move to
|
||||
* @param speed The speed it will move, in pixels per second (default is 60 pixels/sec)
|
||||
* @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
|
||||
*/
|
||||
public moveTowardsObject(source:GameObject, dest:GameObject, speed:number= 60, maxTime:number = 0)
|
||||
{
|
||||
var a:number = this.angleBetween(source, dest);
|
||||
|
||||
if (maxTime > 0)
|
||||
{
|
||||
var d:number = this.distanceBetween(source, dest);
|
||||
|
||||
// We know how many pixels we need to move, but how fast?
|
||||
speed = d / (maxTime / 1000);
|
||||
}
|
||||
|
||||
source.velocity.x = Math.cos(a) * speed;
|
||||
source.velocity.y = Math.sin(a) * speed;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x/y acceleration on the source Sprite so it will move towards the destination Sprite at the speed given (in pixels per second)<br>
|
||||
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
|
||||
* If you don't need acceleration look at moveTowardsObject() instead.
|
||||
*
|
||||
* @param source The Sprite on which the acceleration will be set
|
||||
* @param dest The Sprite where the source object will move towards
|
||||
* @param speed The speed it will accelerate in pixels per second
|
||||
* @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
|
||||
* @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
|
||||
*/
|
||||
public accelerateTowardsObject(source:GameObject, dest:GameObject, speed:number, xSpeedMax:number, ySpeedMax:number)
|
||||
{
|
||||
var a:number = this.angleBetween(source, dest);
|
||||
|
||||
source.velocity.x = 0;
|
||||
source.velocity.y = 0;
|
||||
|
||||
source.acceleration.x = Math.cos(a) * speed;
|
||||
source.acceleration.y = Math.sin(a) * speed;
|
||||
|
||||
source.maxVelocity.x = xSpeedMax;
|
||||
source.maxVelocity.y = ySpeedMax;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the given Sprite towards the mouse pointer coordinates at a steady velocity
|
||||
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
|
||||
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
|
||||
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
|
||||
*
|
||||
* @param source The Sprite to move
|
||||
* @param speed The speed it will move, in pixels per second (default is 60 pixels/sec)
|
||||
* @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
|
||||
*/
|
||||
public moveTowardsMouse(source:GameObject, speed:number = 60, maxTime:number = 0)
|
||||
{
|
||||
var a:number = this.angleBetweenMouse(source);
|
||||
|
||||
if (maxTime > 0)
|
||||
{
|
||||
var d:number = this.distanceToMouse(source);
|
||||
|
||||
// We know how many pixels we need to move, but how fast?
|
||||
speed = d / (maxTime / 1000);
|
||||
}
|
||||
|
||||
source.velocity.x = Math.cos(a) * speed;
|
||||
source.velocity.y = Math.sin(a) * speed;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x/y acceleration on the source Sprite so it will move towards the mouse coordinates at the speed given (in pixels per second)<br>
|
||||
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
|
||||
* If you don't need acceleration look at moveTowardsMouse() instead.
|
||||
*
|
||||
* @param source The Sprite on which the acceleration will be set
|
||||
* @param speed The speed it will accelerate in pixels per second
|
||||
* @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
|
||||
* @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
|
||||
*/
|
||||
public accelerateTowardsMouse(source:GameObject, speed:number, xSpeedMax:number, ySpeedMax:number)
|
||||
{
|
||||
var a:number = this.angleBetweenMouse(source);
|
||||
|
||||
source.velocity.x = 0;
|
||||
source.velocity.y = 0;
|
||||
|
||||
source.acceleration.x = Math.cos(a) * speed;
|
||||
source.acceleration.y = Math.sin(a) * speed;
|
||||
|
||||
source.maxVelocity.x = xSpeedMax;
|
||||
source.maxVelocity.y = ySpeedMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x/y velocity on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>
|
||||
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
|
||||
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
|
||||
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
|
||||
*
|
||||
* @param source The Sprite to move
|
||||
* @param target The Point coordinates to move the source Sprite towards
|
||||
* @param speed The speed it will move, in pixels per second (default is 60 pixels/sec)
|
||||
* @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
|
||||
*/
|
||||
public moveTowardsPoint(source:GameObject, target:Point, speed:number = 60, maxTime:number = 0)
|
||||
{
|
||||
var a:number = this.angleBetweenPoint(source, target);
|
||||
|
||||
if (maxTime > 0)
|
||||
{
|
||||
var d:number = this.distanceToPoint(source, target);
|
||||
|
||||
// We know how many pixels we need to move, but how fast?
|
||||
speed = d / (maxTime / 1000);
|
||||
}
|
||||
|
||||
source.velocity.x = Math.cos(a) * speed;
|
||||
source.velocity.y = Math.sin(a) * speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x/y acceleration on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>
|
||||
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
|
||||
* If you don't need acceleration look at moveTowardsPoint() instead.
|
||||
*
|
||||
* @param source The Sprite on which the acceleration will be set
|
||||
* @param target The Point coordinates to move the source Sprite towards
|
||||
* @param speed The speed it will accelerate in pixels per second
|
||||
* @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
|
||||
* @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
|
||||
*/
|
||||
public accelerateTowardsPoint(source:GameObject, target:Point, speed:number, xSpeedMax:number, ySpeedMax:number)
|
||||
{
|
||||
var a:number = this.angleBetweenPoint(source, target);
|
||||
|
||||
source.velocity.x = 0;
|
||||
source.velocity.y = 0;
|
||||
|
||||
source.acceleration.x = Math.cos(a) * speed;
|
||||
source.acceleration.y = Math.sin(a) * speed;
|
||||
|
||||
source.maxVelocity.x = xSpeedMax;
|
||||
source.maxVelocity.y = ySpeedMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the distance (in pixels, rounded) between two Sprites, taking their origin into account
|
||||
*
|
||||
* @param a The first Sprite
|
||||
* @param b The second Sprite
|
||||
* @return int Distance (in pixels)
|
||||
*/
|
||||
public distanceBetween(a:GameObject, b:GameObject):number
|
||||
{
|
||||
var dx:number = (a.x + a.origin.x) - (b.x + b.origin.x);
|
||||
var dy:number = (a.y + a.origin.y) - (b.y + b.origin.y);
|
||||
|
||||
return this._game.math.vectorLength(dx, dy);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the distance (in pixels, rounded) from an Sprite to the given Point, taking the source origin into account
|
||||
*
|
||||
* @param a The Sprite
|
||||
* @param target The Point
|
||||
* @return int Distance (in pixels)
|
||||
*/
|
||||
public distanceToPoint(a:GameObject, target:Point):number
|
||||
{
|
||||
var dx:number = (a.x + a.origin.x) - (target.x);
|
||||
var dy:number = (a.y + a.origin.y) - (target.y);
|
||||
|
||||
return this._game.math.vectorLength(dx, dy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the distance (in pixels, rounded) from the object x/y and the mouse x/y
|
||||
*
|
||||
* @param a The Sprite to test against
|
||||
* @return int The distance between the given sprite and the mouse coordinates
|
||||
*/
|
||||
public distanceToMouse(a:GameObject):number
|
||||
{
|
||||
var dx: number = (a.x + a.origin.x) - this._game.input.x;
|
||||
var dy: number = (a.y + a.origin.y) - this._game.input.y;
|
||||
|
||||
return this._game.math.vectorLength(dx, dy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the angle (in radians) between an Sprite and an Point. The source sprite takes its x/y and origin into account.
|
||||
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
|
||||
*
|
||||
* @param a The Sprite to test from
|
||||
* @param target The Point to angle the Sprite towards
|
||||
* @param asDegrees If you need the value in degrees instead of radians, set to true
|
||||
*
|
||||
* @return Number The angle (in radians unless asDegrees is true)
|
||||
*/
|
||||
public angleBetweenPoint(a:GameObject, target:Point, asDegrees:bool = false):number
|
||||
{
|
||||
var dx:number = (target.x) - (a.x + a.origin.x);
|
||||
var dy:number = (target.y) - (a.y + a.origin.y);
|
||||
|
||||
if (asDegrees)
|
||||
{
|
||||
return this._game.math.radiansToDegrees(Math.atan2(dy, dx));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.atan2(dy, dx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the angle (in radians) between the two Sprite, taking their x/y and origin into account.
|
||||
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
|
||||
*
|
||||
* @param a The Sprite to test from
|
||||
* @param b The Sprite to test to
|
||||
* @param asDegrees If you need the value in degrees instead of radians, set to true
|
||||
*
|
||||
* @return Number The angle (in radians unless asDegrees is true)
|
||||
*/
|
||||
public angleBetween(a:GameObject, b:GameObject, asDegrees:bool = false):number
|
||||
{
|
||||
var dx:number = (b.x + b.origin.x) - (a.x + a.origin.x);
|
||||
var dy:number = (b.y + b.origin.y) - (a.y + a.origin.y);
|
||||
|
||||
if (asDegrees)
|
||||
{
|
||||
return this._game.math.radiansToDegrees(Math.atan2(dy, dx));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.atan2(dy, dx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the GameObject and speed calculate the velocity and return it as an Point based on the direction the sprite is facing
|
||||
*
|
||||
* @param parent The Sprite to get the facing value from
|
||||
* @param speed The speed it will move, in pixels per second sq
|
||||
*
|
||||
* @return An Point where Point.x contains the velocity x value and Point.y contains the velocity y value
|
||||
*/
|
||||
public velocityFromFacing(parent:GameObject, speed:number):Point
|
||||
{
|
||||
var a:number;
|
||||
|
||||
if (parent.facing == Collision.LEFT)
|
||||
{
|
||||
a = this._game.math.degreesToRadians(180);
|
||||
}
|
||||
else if (parent.facing == Collision.RIGHT)
|
||||
{
|
||||
a = this._game.math.degreesToRadians(0);
|
||||
}
|
||||
else if (parent.facing == Collision.UP)
|
||||
{
|
||||
a = this._game.math.degreesToRadians(-90);
|
||||
}
|
||||
else if (parent.facing == Collision.DOWN)
|
||||
{
|
||||
a = this._game.math.degreesToRadians(90);
|
||||
}
|
||||
|
||||
return new Point(Math.cos(a) * speed, Math.sin(a) * speed);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the angle (in radians) between an Sprite and the mouse, taking their x/y and origin into account.
|
||||
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
|
||||
*
|
||||
* @param a The Object to test from
|
||||
* @param asDegrees If you need the value in degrees instead of radians, set to true
|
||||
*
|
||||
* @return Number The angle (in radians unless asDegrees is true)
|
||||
*/
|
||||
public angleBetweenMouse(a:GameObject, asDegrees:bool = false):number
|
||||
{
|
||||
// In order to get the angle between the object and mouse, we need the objects screen coordinates (rather than world coordinates)
|
||||
var p:MicroPoint = a.getScreenXY();
|
||||
|
||||
var dx:number = a._game.input.x - p.x;
|
||||
var dy:number = a._game.input.y - p.y;
|
||||
|
||||
if (asDegrees)
|
||||
{
|
||||
return this._game.math.radiansToDegrees(Math.atan2(dy, dx));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.atan2(dy, dx);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,319 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<ProjectGuid>{A90BE60F-CAEA-4747-904A-CDB097BA2459}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<OutputPath>bin</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Phaser</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:51891/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="plugins\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="AnimationManager.js">
|
||||
<DependentUpon>AnimationManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Collision.js">
|
||||
<DependentUpon>Collision.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="DynamicTexture.js">
|
||||
<DependentUpon>DynamicTexture.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Game.js">
|
||||
<DependentUpon>Game.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="GameMath.js">
|
||||
<DependentUpon>GameMath.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Emitter.js">
|
||||
<DependentUpon>Emitter.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\GameObject.js">
|
||||
<DependentUpon>GameObject.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\GeomSprite.js">
|
||||
<DependentUpon>GeomSprite.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Particle.js">
|
||||
<DependentUpon>Particle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Sprite.js">
|
||||
<DependentUpon>Sprite.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Tilemap.js">
|
||||
<DependentUpon>Tilemap.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Circle.js">
|
||||
<DependentUpon>Circle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\IntersectResult.js">
|
||||
<DependentUpon>IntersectResult.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Line.js">
|
||||
<DependentUpon>Line.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\MicroPoint.ts" />
|
||||
<Content Include="geom\MicroPoint.js">
|
||||
<DependentUpon>MicroPoint.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Point.js">
|
||||
<DependentUpon>Point.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Rectangle.js">
|
||||
<DependentUpon>Rectangle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="SoundManager.js">
|
||||
<DependentUpon>SoundManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\Sound.js">
|
||||
<DependentUpon>Sound.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="system\Sound.ts" />
|
||||
<TypeScriptCompile Include="SoundManager.ts" />
|
||||
<Content Include="system\animation\Animation.js">
|
||||
<DependentUpon>Animation.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\animation\AnimationLoader.js">
|
||||
<DependentUpon>AnimationLoader.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\animation\Frame.js">
|
||||
<DependentUpon>Frame.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\animation\FrameData.js">
|
||||
<DependentUpon>FrameData.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\Camera.js">
|
||||
<DependentUpon>Camera.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\Device.js">
|
||||
<DependentUpon>Device.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\LinkedList.js">
|
||||
<DependentUpon>LinkedList.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\QuadTree.js">
|
||||
<DependentUpon>QuadTree.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\RandomDataGenerator.js">
|
||||
<DependentUpon>RandomDataGenerator.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\RequestAnimationFrame.js">
|
||||
<DependentUpon>RequestAnimationFrame.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\StageScaleMode.js">
|
||||
<DependentUpon>StageScaleMode.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\Tile.js">
|
||||
<DependentUpon>Tile.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\TilemapBuffer.js">
|
||||
<DependentUpon>TilemapBuffer.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\Tween.js">
|
||||
<DependentUpon>Tween.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="system\Tween.ts" />
|
||||
<TypeScriptCompile Include="system\TilemapBuffer.ts" />
|
||||
<TypeScriptCompile Include="system\Tile.ts" />
|
||||
<TypeScriptCompile Include="system\StageScaleMode.ts" />
|
||||
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
|
||||
<TypeScriptCompile Include="system\RandomDataGenerator.ts" />
|
||||
<TypeScriptCompile Include="system\QuadTree.ts" />
|
||||
<TypeScriptCompile Include="system\LinkedList.ts" />
|
||||
<TypeScriptCompile Include="system\Device.ts" />
|
||||
<TypeScriptCompile Include="system\Camera.ts" />
|
||||
<Content Include="system\easing\Back.js">
|
||||
<DependentUpon>Back.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Bounce.js">
|
||||
<DependentUpon>Bounce.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Circular.js">
|
||||
<DependentUpon>Circular.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Cubic.js">
|
||||
<DependentUpon>Cubic.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Elastic.js">
|
||||
<DependentUpon>Elastic.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Exponential.js">
|
||||
<DependentUpon>Exponential.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Linear.js">
|
||||
<DependentUpon>Linear.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Quadratic.js">
|
||||
<DependentUpon>Quadratic.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Quartic.js">
|
||||
<DependentUpon>Quartic.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Quintic.js">
|
||||
<DependentUpon>Quintic.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\easing\Sinusoidal.js">
|
||||
<DependentUpon>Sinusoidal.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\input\Finger.js">
|
||||
<DependentUpon>Finger.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\input\Input.js">
|
||||
<DependentUpon>Input.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\input\Keyboard.js">
|
||||
<DependentUpon>Keyboard.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\input\Mouse.js">
|
||||
<DependentUpon>Mouse.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\input\Touch.js">
|
||||
<DependentUpon>Touch.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="system\input\Touch.ts" />
|
||||
<TypeScriptCompile Include="system\input\Mouse.ts" />
|
||||
<TypeScriptCompile Include="system\input\Keyboard.ts" />
|
||||
<TypeScriptCompile Include="system\input\Input.ts" />
|
||||
<TypeScriptCompile Include="system\input\Finger.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Sinusoidal.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Quintic.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Quartic.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Quadratic.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Linear.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Exponential.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Elastic.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Cubic.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Circular.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Bounce.ts" />
|
||||
<TypeScriptCompile Include="system\easing\Back.ts" />
|
||||
<TypeScriptCompile Include="system\animation\FrameData.ts" />
|
||||
<TypeScriptCompile Include="system\animation\Frame.ts" />
|
||||
<TypeScriptCompile Include="system\animation\AnimationLoader.ts" />
|
||||
<TypeScriptCompile Include="system\animation\Animation.ts" />
|
||||
<TypeScriptCompile Include="geom\Rectangle.ts" />
|
||||
<TypeScriptCompile Include="geom\Point.ts" />
|
||||
<TypeScriptCompile Include="geom\Line.ts" />
|
||||
<TypeScriptCompile Include="geom\IntersectResult.ts" />
|
||||
<TypeScriptCompile Include="geom\Circle.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Tilemap.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Particle.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\GeomSprite.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\GameObject.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\Emitter.ts" />
|
||||
<Content Include="Group.js">
|
||||
<DependentUpon>Group.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Loader.js">
|
||||
<DependentUpon>Loader.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Motion.js">
|
||||
<DependentUpon>Motion.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Phaser.js">
|
||||
<DependentUpon>Phaser.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Signal.js">
|
||||
<DependentUpon>Signal.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="SignalBinding.js">
|
||||
<DependentUpon>SignalBinding.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Stage.js">
|
||||
<DependentUpon>Stage.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="State.js">
|
||||
<DependentUpon>State.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Time.js">
|
||||
<DependentUpon>Time.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="TweenManager.js">
|
||||
<DependentUpon>TweenManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="World.js">
|
||||
<DependentUpon>World.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="World.ts" />
|
||||
<TypeScriptCompile Include="TweenManager.ts" />
|
||||
<TypeScriptCompile Include="Time.ts" />
|
||||
<TypeScriptCompile Include="State.ts" />
|
||||
<TypeScriptCompile Include="Stage.ts" />
|
||||
<TypeScriptCompile Include="SignalBinding.ts" />
|
||||
<TypeScriptCompile Include="Signal.ts" />
|
||||
<TypeScriptCompile Include="Phaser.ts" />
|
||||
<TypeScriptCompile Include="Motion.ts" />
|
||||
<TypeScriptCompile Include="Loader.ts" />
|
||||
<TypeScriptCompile Include="Group.ts" />
|
||||
<TypeScriptCompile Include="GameMath.ts" />
|
||||
<TypeScriptCompile Include="Game.ts" />
|
||||
<TypeScriptCompile Include="DynamicTexture.ts" />
|
||||
<TypeScriptCompile Include="Collision.ts" />
|
||||
<TypeScriptCompile Include="AnimationManager.ts" />
|
||||
<Content Include="Basic.js">
|
||||
<DependentUpon>Basic.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Cache.js">
|
||||
<DependentUpon>Cache.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="CameraManager.js">
|
||||
<DependentUpon>CameraManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="CameraManager.ts" />
|
||||
<TypeScriptCompile Include="Cache.ts" />
|
||||
<TypeScriptCompile Include="Basic.ts" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>cd $(ProjectDir)..\build
|
||||
copy phaser.js ..\Tests\</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Phaser
|
||||
*
|
||||
* v0.9.2 - April 20th 2013
|
||||
*
|
||||
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
|
||||
*
|
||||
* Richard Davey (@photonstorm)
|
||||
*
|
||||
* Many thanks to Adam Saltsman (@ADAMATOMIC) for the original Flixel AS3 code on which Phaser is based.
|
||||
*
|
||||
* "If you want your children to be intelligent, read them fairy tales."
|
||||
* "If you want them to be more intelligent, read them more fairy tales."
|
||||
* -- Albert Einstein
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export var VERSION: string = 'Phaser version 0.9.2';
|
||||
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="system/Sound.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - SoundManager
|
||||
*
|
||||
* This is an embroyonic web audio sound management class. There is a lot of work still to do here.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class SoundManager {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
if (game.device.webaudio == true)
|
||||
{
|
||||
if (!!window['AudioContext'])
|
||||
{
|
||||
this._context = new window['AudioContext']();
|
||||
}
|
||||
else if (!!window['webkitAudioContext'])
|
||||
{
|
||||
this._context = new window['webkitAudioContext']();
|
||||
}
|
||||
|
||||
if (this._context !== null)
|
||||
{
|
||||
this._gainNode = this._context.createGainNode();
|
||||
this._gainNode.connect(this._context.destination);
|
||||
this._volume = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _context = null;
|
||||
private _gainNode;
|
||||
private _volume: number;
|
||||
|
||||
public mute() {
|
||||
|
||||
this._gainNode.gain.value = 0;
|
||||
|
||||
}
|
||||
|
||||
public unmute() {
|
||||
|
||||
this._gainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public set volume(value: number) {
|
||||
|
||||
this._volume = value;
|
||||
this._gainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public get volume(): number {
|
||||
return this._volume;
|
||||
}
|
||||
|
||||
public decode(key: string, callback = null, sound?: Sound = null) {
|
||||
|
||||
var soundData = this._game.cache.getSound(key);
|
||||
|
||||
if (soundData)
|
||||
{
|
||||
if (this._game.cache.isSoundDecoded(key) === false)
|
||||
{
|
||||
var that = this;
|
||||
|
||||
this._context.decodeAudioData(soundData, function (buffer) {
|
||||
that._game.cache.decodedSound(key, buffer);
|
||||
|
||||
if (sound)
|
||||
{
|
||||
sound.setDecodedBuffer(buffer);
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public play(key: string, volume?: number = 1, loop?: bool = false): Sound {
|
||||
|
||||
if (this._context === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var soundData = this._game.cache.getSound(key);
|
||||
|
||||
if (soundData)
|
||||
{
|
||||
// Does the sound need decoding?
|
||||
if (this._game.cache.isSoundDecoded(key) === true)
|
||||
{
|
||||
return new Sound(this._context, this._gainNode, soundData, volume, loop);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tempSound: Sound = new Sound(this._context, this._gainNode, null, volume, loop);
|
||||
|
||||
// this is an async process, so we can return the Sound object anyway, it just won't be playing yet
|
||||
this.decode(key, () => this.play(key), tempSound);
|
||||
|
||||
return tempSound;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-240
@@ -1,240 +0,0 @@
|
||||
/// <reference path="Phaser.ts" />
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="system/StageScaleMode.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Stage
|
||||
*
|
||||
* The Stage is the canvas on which everything is displayed. This class handles display within the web browser, focus handling,
|
||||
* resizing, scaling and pause/boot screens.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Stage {
|
||||
|
||||
constructor(game: Game, parent: string, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.canvas.width = width;
|
||||
this.canvas.height = height;
|
||||
|
||||
if (document.getElementById(parent))
|
||||
{
|
||||
document.getElementById(parent).appendChild(this.canvas);
|
||||
document.getElementById(parent).style.overflow = 'hidden';
|
||||
}
|
||||
else
|
||||
{
|
||||
document.body.appendChild(this.canvas);
|
||||
}
|
||||
|
||||
// Consume default actions on the canvas
|
||||
this.canvas.style.msTouchAction = 'none';
|
||||
this.canvas.style['touch-action'] = 'none';
|
||||
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
this.offset = this.getOffset(this.canvas);
|
||||
this.bounds = new Rectangle(this.offset.x, this.offset.y, width, height);
|
||||
this.aspectRatio = width / height;
|
||||
this.scaleMode = StageScaleMode.NO_SCALE;
|
||||
this.scale = new StageScaleMode(this._game);
|
||||
|
||||
//document.addEventListener('visibilitychange', (event) => this.visibilityChange(event), false);
|
||||
//document.addEventListener('webkitvisibilitychange', (event) => this.visibilityChange(event), false);
|
||||
window.onblur = (event) => this.visibilityChange(event);
|
||||
window.onfocus = (event) => this.visibilityChange(event);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _bgColor: string;
|
||||
|
||||
|
||||
public static ORIENTATION_LANDSCAPE: number = 0;
|
||||
public static ORIENTATION_PORTRAIT: number = 1;
|
||||
|
||||
public bounds: Rectangle;
|
||||
public aspectRatio: number;
|
||||
public clear: bool = true;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
public offset: Point;
|
||||
public scale: StageScaleMode;
|
||||
public scaleMode: number;
|
||||
|
||||
public minScaleX: number = null;
|
||||
public maxScaleX: number = null;
|
||||
public minScaleY: number = null;
|
||||
public maxScaleY: number = null;
|
||||
|
||||
public update() {
|
||||
|
||||
this.scale.update();
|
||||
|
||||
if (this.clear)
|
||||
{
|
||||
// implement dirty rect? could take up more cpu time than it saves. needs benching.
|
||||
this.context.clearRect(0, 0, this.width, this.height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo() {
|
||||
|
||||
this.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.context.fillText(Phaser.VERSION, 10, 20);
|
||||
this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 10, 40);
|
||||
this.context.fillText('x: ' + this.x + ' y: ' + this.y, 10, 60);
|
||||
|
||||
}
|
||||
|
||||
private visibilityChange(event) {
|
||||
|
||||
if (event.type == 'blur' && this._game.paused == false && this._game.isBooted == true)
|
||||
{
|
||||
this._game.paused = true;
|
||||
this.drawPauseScreen();
|
||||
}
|
||||
else if (event.type == 'focus')
|
||||
{
|
||||
this._game.paused = false;
|
||||
}
|
||||
|
||||
//if (document['hidden'] === true || document['webkitHidden'] === true)
|
||||
|
||||
}
|
||||
|
||||
public drawInitScreen() {
|
||||
|
||||
this.context.fillStyle = 'rgb(40, 40, 40)';
|
||||
this.context.fillRect(0, 0, this.width, this.height);
|
||||
|
||||
this.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.context.font = 'bold 18px Arial';
|
||||
this.context.textBaseline = 'top';
|
||||
this.context.fillText(Phaser.VERSION, 54, 32);
|
||||
this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 32, 64);
|
||||
this.context.fillText('www.photonstorm.com', 32, 96);
|
||||
this.context.font = '16px Arial';
|
||||
this.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 160);
|
||||
this.context.fillText('functions in the Game constructor, or use Game.loadState()', 32, 184);
|
||||
|
||||
var image = new Image();
|
||||
var that = this;
|
||||
|
||||
image.onload = function () {
|
||||
that.context.drawImage(image, 32, 32);
|
||||
};
|
||||
|
||||
image.src = this._logo;
|
||||
|
||||
}
|
||||
|
||||
private drawPauseScreen() {
|
||||
|
||||
this.saveCanvasValues();
|
||||
|
||||
this.context.fillStyle = 'rgba(0, 0, 0, 0.4)';
|
||||
this.context.fillRect(0, 0, this.width, this.height);
|
||||
|
||||
// Draw a 'play' arrow
|
||||
var arrowWidth = Math.round(this.width / 2);
|
||||
var arrowHeight = Math.round(this.height / 2);
|
||||
|
||||
var sx = this.centerX - arrowWidth / 2;
|
||||
var sy = this.centerY - arrowHeight / 2;
|
||||
|
||||
this.context.beginPath();
|
||||
this.context.moveTo(sx, sy);
|
||||
this.context.lineTo(sx, sy + arrowHeight);
|
||||
this.context.lineTo(sx + arrowWidth, this.centerY);
|
||||
this.context.fillStyle = 'rgba(255, 255, 255, 0.8)';
|
||||
this.context.fill();
|
||||
this.context.closePath();
|
||||
|
||||
this.restoreCanvasValues();
|
||||
|
||||
}
|
||||
|
||||
private getOffset(element): Point {
|
||||
|
||||
var box = element.getBoundingClientRect();
|
||||
|
||||
var clientTop = element.clientTop || document.body.clientTop || 0;
|
||||
var clientLeft = element.clientLeft || document.body.clientLeft || 0;
|
||||
var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
|
||||
|
||||
return new Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop);
|
||||
|
||||
}
|
||||
|
||||
public strokeStyle: string;
|
||||
public lineWidth: number;
|
||||
public fillStyle: string;
|
||||
|
||||
public saveCanvasValues() {
|
||||
|
||||
this.strokeStyle = this.context.strokeStyle;
|
||||
this.lineWidth = this.context.lineWidth;
|
||||
this.fillStyle = this.context.fillStyle;
|
||||
|
||||
}
|
||||
|
||||
public restoreCanvasValues() {
|
||||
|
||||
this.context.strokeStyle = this.strokeStyle;
|
||||
this.context.lineWidth = this.lineWidth;
|
||||
this.context.fillStyle = this.fillStyle;
|
||||
|
||||
}
|
||||
|
||||
public set backgroundColor(color: string) {
|
||||
this.canvas.style.backgroundColor = color;
|
||||
}
|
||||
|
||||
public get backgroundColor(): string {
|
||||
return this._bgColor;
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this.bounds.x;
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this.bounds.y;
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
public get centerX(): number {
|
||||
return this.bounds.halfWidth;
|
||||
}
|
||||
|
||||
public get centerY(): number {
|
||||
return this.bounds.halfHeight;
|
||||
}
|
||||
|
||||
public get randomX(): number {
|
||||
return Math.round(Math.random() * this.bounds.width);
|
||||
}
|
||||
|
||||
public get randomY(): number {
|
||||
return Math.round(Math.random() * this.bounds.height);
|
||||
}
|
||||
|
||||
private _logo: string = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAO1JREFUeNpi/P//PwM6YGRkxBQEAqBaRnQxFmwa10d6MAjrMqMofHv5L1we2SBGmAtAktg0ogOQQYHLd8ANYYFpPtTmzUAMAFmwnsEDrAdkCAvMZlIAsiFMMAEYsKvaSrQhIMCELkGsV2AAbIC8gCQYgwKIUABiNYBf9yoYH7n7n6CzN274g2IYEyFbsNmKLIaSkHpP7WSwUfbA0ASzFQRslBlxp0RcAF0TRhggA3zhAJIDpUKU5A9KyshpHDkjFZu5g2nJMFcwXVJSgqIGnBKx5bKenh4w/XzVbgbPtlIUcVgSxuoCUgHIIIAAAwArtXwJBABO6QAAAABJRU5ErkJggg==";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - State
|
||||
*
|
||||
* This is a base State class which can be extended if you are creating your game using TypeScript.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class State {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
this.camera = game.camera;
|
||||
this.cache = game.cache;
|
||||
this.collision = game.collision;
|
||||
this.input = game.input;
|
||||
this.loader = game.loader;
|
||||
this.math = game.math;
|
||||
this.motion = game.motion;
|
||||
this.sound = game.sound;
|
||||
this.stage = game.stage;
|
||||
this.time = game.time;
|
||||
this.tweens = game.tweens;
|
||||
this.world = game.world;
|
||||
|
||||
}
|
||||
|
||||
public game: Game;
|
||||
|
||||
public camera: Camera;
|
||||
public cache: Cache;
|
||||
public collision: Collision;
|
||||
public input: Input;
|
||||
public loader: Loader;
|
||||
public math: GameMath;
|
||||
public motion: Motion;
|
||||
public sound: SoundManager;
|
||||
public stage: Stage;
|
||||
public time: Time;
|
||||
public tweens: TweenManager;
|
||||
public world: World;
|
||||
|
||||
|
||||
// Overload these in your own States
|
||||
public init() { }
|
||||
public create() { }
|
||||
public update() { }
|
||||
public render() { }
|
||||
public paused() { }
|
||||
|
||||
// Handy Proxy methods
|
||||
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this.game.world.createCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
public createGeomSprite(x: number, y: number): GeomSprite {
|
||||
return this.world.createGeomSprite(x, y);
|
||||
}
|
||||
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return this.game.world.createSprite(x, y, key);
|
||||
}
|
||||
|
||||
public createDynamicTexture(key: string, width: number, height: number): DynamicTexture {
|
||||
return this.game.world.createDynamicTexture(key, width, height);
|
||||
}
|
||||
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return this.game.world.createGroup(MaxSize);
|
||||
}
|
||||
|
||||
public createParticle(): Particle {
|
||||
return this.game.world.createParticle();
|
||||
}
|
||||
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return this.game.world.createEmitter(x, y, size);
|
||||
}
|
||||
|
||||
public createTilemap(key: string, mapData: string, format: number, tileWidth?: number, tileHeight?: number): Tilemap {
|
||||
return this.game.world.createTilemap(key, mapData, format, tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
public createTween(obj): Tween {
|
||||
return this.game.tweens.create(obj);
|
||||
}
|
||||
|
||||
public collide(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null): bool {
|
||||
return this.collision.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, Collision.separate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Time
|
||||
*
|
||||
* This is the game clock and it manages elapsed time and calculation of delta values, used for game object motion.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Time {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._started = Date.now();
|
||||
this._timeLastSecond = this._started;
|
||||
this.time = this._started;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _started: number;
|
||||
|
||||
|
||||
public timeScale: number = 1.0;
|
||||
public elapsed: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property time
|
||||
* @type Number
|
||||
*/
|
||||
public time: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property now
|
||||
* @type Number
|
||||
*/
|
||||
public now: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property delta
|
||||
* @type Number
|
||||
*/
|
||||
public delta: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method totalElapsedSeconds
|
||||
* @return {Number}
|
||||
*/
|
||||
public get totalElapsedSeconds(): number {
|
||||
|
||||
return (this.now - this._started) * 0.001;
|
||||
|
||||
}
|
||||
|
||||
public fps: number = 0;
|
||||
public fpsMin: number = 1000;
|
||||
public fpsMax: number = 0;
|
||||
public msMin: number = 1000;
|
||||
public msMax: number = 0;
|
||||
public frames: number = 0;
|
||||
|
||||
private _timeLastSecond: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method update
|
||||
*/
|
||||
public update() {
|
||||
|
||||
// Can we use performance.now() ?
|
||||
this.now = Date.now(); // mark
|
||||
this.delta = this.now - this.time; // elapsedMS
|
||||
|
||||
this.msMin = Math.min(this.msMin, this.delta);
|
||||
this.msMax = Math.max(this.msMax, this.delta);
|
||||
|
||||
this.frames++;
|
||||
|
||||
if (this.now > this._timeLastSecond + 1000)
|
||||
{
|
||||
this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond));
|
||||
this.fpsMin = Math.min(this.fpsMin, this.fps);
|
||||
this.fpsMax = Math.max(this.fpsMax, this.fps);
|
||||
|
||||
this._timeLastSecond = this.now;
|
||||
this.frames = 0;
|
||||
}
|
||||
|
||||
this.time = this.now; // _total
|
||||
|
||||
//// Lock the delta at 0.1 to minimise fps tunneling
|
||||
//if (this.delta > 0.1)
|
||||
//{
|
||||
// this.delta = 0.1;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method elapsedSince
|
||||
* @param {Number} since
|
||||
* @return {Number}
|
||||
*/
|
||||
public elapsedSince(since: number): number {
|
||||
|
||||
return this.now - since;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method elapsedSecondsSince
|
||||
* @param {Number} since
|
||||
* @return {Number}
|
||||
*/
|
||||
public elapsedSecondsSince(since: number): number {
|
||||
|
||||
return (this.now - since) * 0.001;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method reset
|
||||
*/
|
||||
public reset() {
|
||||
|
||||
this._started = this.now;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
/// <reference path="system/Tween.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - TweenManager
|
||||
*
|
||||
* The Game has a single instance of the TweenManager through which all Tween objects are created and updated.
|
||||
* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
|
||||
* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com).
|
||||
* I converted it to TypeScript, swapped the callbacks for signals and patched a few issues with regard
|
||||
* to properties and completion errors. Please see https://github.com/sole/tween.js for a full list of contributors.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class TweenManager {
|
||||
|
||||
constructor(game: Phaser.Game) {
|
||||
|
||||
this._game = game;
|
||||
this._tweens = [];
|
||||
|
||||
}
|
||||
|
||||
private _game: Phaser.Game;
|
||||
private _tweens: Phaser.Tween[];
|
||||
|
||||
public getAll() {
|
||||
|
||||
return this._tweens;
|
||||
|
||||
}
|
||||
|
||||
public removeAll() {
|
||||
|
||||
this._tweens.length = 0;
|
||||
|
||||
}
|
||||
|
||||
public create(object): Phaser.Tween {
|
||||
|
||||
return new Phaser.Tween(object, this._game);
|
||||
|
||||
}
|
||||
|
||||
public add(tween: Phaser.Tween) {
|
||||
|
||||
tween.parent = this._game;
|
||||
|
||||
this._tweens.push(tween);
|
||||
|
||||
return tween;
|
||||
|
||||
}
|
||||
|
||||
public remove(tween: Phaser.Tween) {
|
||||
|
||||
var i = this._tweens.indexOf(tween);
|
||||
|
||||
if (i !== -1)
|
||||
{
|
||||
this._tweens.splice(i, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
if (this._tweens.length === 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var numTweens = this._tweens.length;
|
||||
|
||||
while (i < numTweens)
|
||||
{
|
||||
if (this._tweens[i].update(this._game.time.now))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._tweens.splice(i, 1);
|
||||
numTweens--;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-169
@@ -1,169 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - World
|
||||
*
|
||||
* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
|
||||
* by stage limits and can be any size or dimension. You look into the world via cameras and all game objects
|
||||
* live within the world at world-based coordinates. By default a world is created the same size as your Stage.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class World {
|
||||
|
||||
constructor(game: Game, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this._cameras = new CameraManager(this._game, 0, 0, width, height);
|
||||
|
||||
this._game.camera = this._cameras.current;
|
||||
|
||||
this.group = new Group(this._game, 0);
|
||||
|
||||
this.bounds = new Rectangle(0, 0, width, height);
|
||||
|
||||
this.worldDivisions = 6;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _cameras: CameraManager;
|
||||
|
||||
public group: Group;
|
||||
public bounds: Rectangle;
|
||||
public worldDivisions: number;
|
||||
|
||||
public update() {
|
||||
|
||||
this.group.preUpdate();
|
||||
this.group.update();
|
||||
this.group.postUpdate();
|
||||
|
||||
this._cameras.update();
|
||||
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
||||
// Unlike in flixel our render process is camera driven, not group driven
|
||||
this._cameras.render();
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
this.group.destroy();
|
||||
|
||||
this._cameras.destroy();
|
||||
|
||||
}
|
||||
|
||||
// World methods
|
||||
|
||||
public setSize(width: number, height: number, updateCameraBounds: bool = true) {
|
||||
|
||||
this.bounds.width = width;
|
||||
this.bounds.height = height;
|
||||
|
||||
if (updateCameraBounds == true)
|
||||
{
|
||||
this._game.camera.setBounds(0, 0, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
public set width(value: number) {
|
||||
this.bounds.width = value;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
public set height(value: number) {
|
||||
this.bounds.height = value;
|
||||
}
|
||||
|
||||
public get centerX(): number {
|
||||
return this.bounds.halfWidth;
|
||||
}
|
||||
|
||||
public get centerY(): number {
|
||||
return this.bounds.halfHeight;
|
||||
}
|
||||
|
||||
public get randomX(): number {
|
||||
return Math.round(Math.random() * this.bounds.width);
|
||||
}
|
||||
|
||||
public get randomY(): number {
|
||||
return Math.round(Math.random() * this.bounds.height);
|
||||
}
|
||||
|
||||
// Cameras
|
||||
|
||||
public addExistingCamera(cam: Camera): Camera {
|
||||
//return this._cameras.addCamera(x, y, width, height);
|
||||
return cam;
|
||||
}
|
||||
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this._cameras.addCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
public removeCamera(id: number): bool {
|
||||
return this._cameras.removeCamera(id);
|
||||
}
|
||||
|
||||
public getAllCameras(): Camera[] {
|
||||
return this._cameras.getAll();
|
||||
}
|
||||
|
||||
// Sprites
|
||||
|
||||
// Drop this?
|
||||
public addExistingSprite(sprite: Sprite): Sprite {
|
||||
return <Sprite> this.group.add(sprite);
|
||||
}
|
||||
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return <Sprite> this.group.add(new Sprite(this._game, x, y, key));
|
||||
}
|
||||
|
||||
public createGeomSprite(x: number, y: number): GeomSprite {
|
||||
return <GeomSprite> this.group.add(new GeomSprite(this._game, x, y));
|
||||
}
|
||||
|
||||
public createDynamicTexture(key: string, width: number, height: number): DynamicTexture {
|
||||
return new DynamicTexture(this._game, key, width, height);
|
||||
}
|
||||
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
return <Group> this.group.add(new Group(this._game, MaxSize));
|
||||
}
|
||||
|
||||
// Tilemaps
|
||||
|
||||
public createTilemap(key: string, mapData: string, format: number, tileWidth?: number, tileHeight?: number): Tilemap {
|
||||
return <Tilemap> this.group.add(new Tilemap(this._game, key, mapData, format, tileWidth, tileHeight));
|
||||
}
|
||||
|
||||
// Emitters
|
||||
|
||||
public createParticle(): Particle {
|
||||
return new Particle(this._game);
|
||||
}
|
||||
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return <Emitter> this.group.add(new Emitter(this._game, x, y, size));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,451 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Group.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Emitter
|
||||
*
|
||||
* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
|
||||
* continuous effects like rain and fire. All it really does is launch Particle objects out
|
||||
* at set intervals, and fixes their positions and velocities accorindgly.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Emitter extends Group {
|
||||
|
||||
/**
|
||||
* Creates a new <code>Emitter</code> object at a specific position.
|
||||
* Does NOT automatically generate or attach particles!
|
||||
*
|
||||
* @param X The X position of the emitter.
|
||||
* @param Y The Y position of the emitter.
|
||||
* @param Size Optional, specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
constructor(game: Game, X: number = 0, Y: number = 0, Size: number = 0) {
|
||||
super(game, Size);
|
||||
this.x = X;
|
||||
this.y = Y;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.minParticleSpeed = new Point(-100, -100);
|
||||
this.maxParticleSpeed = new Point(100, 100);
|
||||
this.minRotation = -360;
|
||||
this.maxRotation = 360;
|
||||
this.gravity = 0;
|
||||
this.particleClass = null;
|
||||
this.particleDrag = new Point();
|
||||
this.frequency = 0.1;
|
||||
this.lifespan = 3;
|
||||
this.bounce = 0;
|
||||
this._quantity = 0;
|
||||
this._counter = 0;
|
||||
this._explode = true;
|
||||
this.on = false;
|
||||
this._point = new Point();
|
||||
}
|
||||
|
||||
/**
|
||||
* The X position of the top left corner of the emitter in world space.
|
||||
*/
|
||||
public x: number;
|
||||
|
||||
/**
|
||||
* The Y position of the top left corner of emitter in world space.
|
||||
*/
|
||||
public y: number;
|
||||
|
||||
/**
|
||||
* The width of the emitter. Particles can be randomly generated from anywhere within this box.
|
||||
*/
|
||||
public width: number;
|
||||
|
||||
/**
|
||||
* The height of the emitter. Particles can be randomly generated from anywhere within this box.
|
||||
*/
|
||||
public height: number;
|
||||
|
||||
/**
|
||||
* The minimum possible velocity of a particle.
|
||||
* The default value is (-100,-100).
|
||||
*/
|
||||
public minParticleSpeed: Point;
|
||||
|
||||
/**
|
||||
* The maximum possible velocity of a particle.
|
||||
* The default value is (100,100).
|
||||
*/
|
||||
public maxParticleSpeed: Point;
|
||||
|
||||
/**
|
||||
* The X and Y drag component of particles launched from the emitter.
|
||||
*/
|
||||
public particleDrag: Point;
|
||||
|
||||
/**
|
||||
* The minimum possible angular velocity of a particle. The default value is -360.
|
||||
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
|
||||
*/
|
||||
public minRotation: number;
|
||||
|
||||
/**
|
||||
* The maximum possible angular velocity of a particle. The default value is 360.
|
||||
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
|
||||
*/
|
||||
public maxRotation: number;
|
||||
|
||||
/**
|
||||
* Sets the <code>acceleration.y</code> member of each particle to this value on launch.
|
||||
*/
|
||||
public gravity: number;
|
||||
|
||||
/**
|
||||
* Determines whether the emitter is currently emitting particles.
|
||||
* It is totally safe to directly toggle this.
|
||||
*/
|
||||
public on: bool;
|
||||
|
||||
/**
|
||||
* How often a particle is emitted (if emitter is started with Explode == false).
|
||||
*/
|
||||
public frequency: number;
|
||||
|
||||
/**
|
||||
* How long each particle lives once it is emitted.
|
||||
* Set lifespan to 'zero' for particles to live forever.
|
||||
*/
|
||||
public lifespan: number;
|
||||
|
||||
/**
|
||||
* How much each particle should bounce. 1 = full bounce, 0 = no bounce.
|
||||
*/
|
||||
public bounce: number;
|
||||
|
||||
/**
|
||||
* Set your own particle class type here.
|
||||
* Default is <code>Particle</code>.
|
||||
*/
|
||||
public particleClass;
|
||||
|
||||
/**
|
||||
* Internal helper for deciding how many particles to launch.
|
||||
*/
|
||||
private _quantity: number;
|
||||
|
||||
/**
|
||||
* Internal helper for the style of particle emission (all at once, or one at a time).
|
||||
*/
|
||||
private _explode: bool;
|
||||
|
||||
/**
|
||||
* Internal helper for deciding when to launch particles or kill them.
|
||||
*/
|
||||
private _timer: number;
|
||||
|
||||
/**
|
||||
* Internal counter for figuring out how many particles to launch.
|
||||
*/
|
||||
private _counter: number;
|
||||
|
||||
/**
|
||||
* Internal point object, handy for reusing for memory mgmt purposes.
|
||||
*/
|
||||
private _point: Point;
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
this.minParticleSpeed = null;
|
||||
this.maxParticleSpeed = null;
|
||||
this.particleDrag = null;
|
||||
this.particleClass = null;
|
||||
this._point = null;
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function generates a new array of particle sprites to attach to the emitter.
|
||||
*
|
||||
* @param Graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet.
|
||||
* @param Quantity The number of particles to generate when using the "create from image" option.
|
||||
* @param BakedRotations How many frames of baked rotation to use (boosts performance). Set to zero to not use baked rotations.
|
||||
* @param Multiple Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!).
|
||||
* @param Collide Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box.
|
||||
*
|
||||
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
|
||||
*/
|
||||
public makeParticles(Graphics, Quantity: number = 50, BakedRotations: number = 16, Multiple: bool = false, Collide: number = 0.8): Emitter {
|
||||
|
||||
this.maxSize = Quantity;
|
||||
|
||||
var totalFrames: number = 1;
|
||||
|
||||
/*
|
||||
if(Multiple)
|
||||
{
|
||||
var sprite:Sprite = new Sprite(this._game);
|
||||
sprite.loadGraphic(Graphics,true);
|
||||
totalFrames = sprite.frames;
|
||||
sprite.destroy();
|
||||
}
|
||||
*/
|
||||
|
||||
var randomFrame: number;
|
||||
var particle: Particle;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < Quantity)
|
||||
{
|
||||
if (this.particleClass == null)
|
||||
{
|
||||
particle = new Particle(this._game);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle = new this.particleClass(this._game);
|
||||
}
|
||||
|
||||
if (Multiple)
|
||||
{
|
||||
/*
|
||||
randomFrame = this._game.math.random()*totalFrames;
|
||||
if(BakedRotations > 0)
|
||||
particle.loadRotatedGraphic(Graphics,BakedRotations,randomFrame);
|
||||
else
|
||||
{
|
||||
particle.loadGraphic(Graphics,true);
|
||||
particle.frame = randomFrame;
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
if (BakedRotations > 0)
|
||||
particle.loadRotatedGraphic(Graphics,BakedRotations);
|
||||
else
|
||||
particle.loadGraphic(Graphics);
|
||||
*/
|
||||
|
||||
if (Graphics)
|
||||
{
|
||||
particle.loadGraphic(Graphics);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Collide > 0)
|
||||
{
|
||||
particle.width *= Collide;
|
||||
particle.height *= Collide;
|
||||
//particle.centerOffsets();
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.allowCollisions = Collision.NONE;
|
||||
}
|
||||
|
||||
particle.exists = false;
|
||||
|
||||
this.add(particle);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called automatically by the game loop, decides when to launch particles and when to "die".
|
||||
*/
|
||||
public update() {
|
||||
|
||||
if (this.on)
|
||||
{
|
||||
if (this._explode)
|
||||
{
|
||||
this.on = false;
|
||||
|
||||
var i: number = 0;
|
||||
var l: number = this._quantity;
|
||||
|
||||
if ((l <= 0) || (l > this.length))
|
||||
{
|
||||
l = this.length;
|
||||
}
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
this.emitParticle();
|
||||
i++;
|
||||
}
|
||||
|
||||
this._quantity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._timer += this._game.time.elapsed;
|
||||
|
||||
while ((this.frequency > 0) && (this._timer > this.frequency) && this.on)
|
||||
{
|
||||
this._timer -= this.frequency;
|
||||
this.emitParticle();
|
||||
|
||||
if ((this._quantity > 0) && (++this._counter >= this._quantity))
|
||||
{
|
||||
this.on = false;
|
||||
this._quantity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.update();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to turn off all the particles and the emitter.
|
||||
*/
|
||||
public kill() {
|
||||
|
||||
this.on = false;
|
||||
|
||||
super.kill();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to start emitting particles.
|
||||
*
|
||||
* @param Explode Whether the particles should all burst out at once.
|
||||
* @param Lifespan How long each particle lives once emitted. 0 = forever.
|
||||
* @param Frequency Ignored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds.
|
||||
* @param Quantity How many particles to launch. 0 = "all of the particles".
|
||||
*/
|
||||
public start(Explode: bool = true, Lifespan: number = 0, Frequency: number = 0.1, Quantity: number = 0) {
|
||||
|
||||
this.revive();
|
||||
|
||||
this.visible = true;
|
||||
this.on = true;
|
||||
|
||||
this._explode = Explode;
|
||||
this.lifespan = Lifespan;
|
||||
this.frequency = Frequency;
|
||||
this._quantity += Quantity;
|
||||
|
||||
this._counter = 0;
|
||||
this._timer = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function can be used both internally and externally to emit the next particle.
|
||||
*/
|
||||
public emitParticle() {
|
||||
|
||||
var particle: Particle = this.recycle(Particle);
|
||||
|
||||
particle.lifespan = this.lifespan;
|
||||
particle.elasticity = this.bounce;
|
||||
particle.reset(this.x - (particle.width >> 1) + this._game.math.random() * this.width, this.y - (particle.height >> 1) + this._game.math.random() * this.height);
|
||||
particle.visible = true;
|
||||
|
||||
if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
|
||||
{
|
||||
particle.velocity.x = this.minParticleSpeed.x + this._game.math.random() * (this.maxParticleSpeed.x - this.minParticleSpeed.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.velocity.x = this.minParticleSpeed.x;
|
||||
}
|
||||
|
||||
if (this.minParticleSpeed.y != this.maxParticleSpeed.y)
|
||||
{
|
||||
particle.velocity.y = this.minParticleSpeed.y + this._game.math.random() * (this.maxParticleSpeed.y - this.minParticleSpeed.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.velocity.y = this.minParticleSpeed.y;
|
||||
}
|
||||
|
||||
particle.acceleration.y = this.gravity;
|
||||
|
||||
if (this.minRotation != this.maxRotation)
|
||||
{
|
||||
particle.angularVelocity = this.minRotation + this._game.math.random() * (this.maxRotation - this.minRotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
particle.angularVelocity = this.minRotation;
|
||||
}
|
||||
|
||||
if (particle.angularVelocity != 0)
|
||||
{
|
||||
particle.angle = this._game.math.random() * 360 - 180;
|
||||
}
|
||||
|
||||
particle.drag.x = this.particleDrag.x;
|
||||
particle.drag.y = this.particleDrag.y;
|
||||
particle.onEmit();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the width and height of the emitter.
|
||||
*
|
||||
* @param Width The desired width of the emitter (particles are spawned randomly within these dimensions).
|
||||
* @param Height The desired height of the emitter.
|
||||
*/
|
||||
public setSize(Width: number, Height: number) {
|
||||
this.width = Width;
|
||||
this.height = Height;
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the X velocity range of the emitter.
|
||||
*
|
||||
* @param Min The minimum value for this range.
|
||||
* @param Max The maximum value for this range.
|
||||
*/
|
||||
public setXSpeed(Min: number = 0, Max: number = 0) {
|
||||
this.minParticleSpeed.x = Min;
|
||||
this.maxParticleSpeed.x = Max;
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the Y velocity range of the emitter.
|
||||
*
|
||||
* @param Min The minimum value for this range.
|
||||
* @param Max The maximum value for this range.
|
||||
*/
|
||||
public setYSpeed(Min: number = 0, Max: number = 0) {
|
||||
this.minParticleSpeed.y = Min;
|
||||
this.maxParticleSpeed.y = Max;
|
||||
}
|
||||
|
||||
/**
|
||||
* A more compact way of setting the angular velocity constraints of the emitter.
|
||||
*
|
||||
* @param Min The minimum value for this range.
|
||||
* @param Max The maximum value for this range.
|
||||
*/
|
||||
public setRotation(Min: number = 0, Max: number = 0) {
|
||||
this.minRotation = Min;
|
||||
this.maxRotation = Max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the emitter's midpoint to match the midpoint of a <code>Object</code>.
|
||||
*
|
||||
* @param Object The <code>Object</code> that you want to sync up with.
|
||||
*/
|
||||
public at(Object) {
|
||||
Object.getMidpoint(this._point);
|
||||
this.x = this._point.x - (this.width >> 1);
|
||||
this.y = this._point.y - (this.height >> 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,541 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Basic.ts" />
|
||||
/// <reference path="../Signal.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GameObject
|
||||
*
|
||||
* This is the base GameObject on which all other game objects are derived. It contains all the logic required for position,
|
||||
* motion, size, collision and input.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class GameObject extends Basic {
|
||||
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, width?: number = 16, height?: number = 16) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.bounds = new Rectangle(x, y, width, height);
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.alive = true;
|
||||
this.isGroup = false;
|
||||
this.alpha = 1;
|
||||
this.scale = new MicroPoint(1, 1);
|
||||
|
||||
this.last = new MicroPoint(x, y);
|
||||
this.origin = new MicroPoint(this.bounds.halfWidth, this.bounds.halfHeight);
|
||||
this.align = GameObject.ALIGN_TOP_LEFT;
|
||||
this.mass = 1.0;
|
||||
this.elasticity = 0.0;
|
||||
this.health = 1;
|
||||
this.immovable = false;
|
||||
this.moves = true;
|
||||
|
||||
this.touching = Collision.NONE;
|
||||
this.wasTouching = Collision.NONE;
|
||||
this.allowCollisions = Collision.ANY;
|
||||
|
||||
this.velocity = new MicroPoint();
|
||||
this.acceleration = new MicroPoint();
|
||||
this.drag = new MicroPoint();
|
||||
this.maxVelocity = new MicroPoint(10000, 10000);
|
||||
|
||||
this.angle = 0;
|
||||
this.angularVelocity = 0;
|
||||
this.angularAcceleration = 0;
|
||||
this.angularDrag = 0;
|
||||
this.maxAngular = 10000;
|
||||
|
||||
this.scrollFactor = new MicroPoint(1.0, 1.0);
|
||||
|
||||
}
|
||||
|
||||
private _angle: number = 0;
|
||||
|
||||
public static ALIGN_TOP_LEFT: number = 0;
|
||||
public static ALIGN_TOP_CENTER: number = 1;
|
||||
public static ALIGN_TOP_RIGHT: number = 2;
|
||||
public static ALIGN_CENTER_LEFT: number = 3;
|
||||
public static ALIGN_CENTER: number = 4;
|
||||
public static ALIGN_CENTER_RIGHT: number = 5;
|
||||
public static ALIGN_BOTTOM_LEFT: number = 6;
|
||||
public static ALIGN_BOTTOM_CENTER: number = 7;
|
||||
public static ALIGN_BOTTOM_RIGHT: number = 8;
|
||||
|
||||
public _point: MicroPoint;
|
||||
|
||||
public bounds: Rectangle;
|
||||
public align: number;
|
||||
public facing: number;
|
||||
public alpha: number;
|
||||
public scale: MicroPoint;
|
||||
public origin: MicroPoint;
|
||||
public z: number = 0;
|
||||
|
||||
// Physics properties
|
||||
public immovable: bool;
|
||||
|
||||
// Velocity is given in pixels per second. Therefore a velocity of
|
||||
// 100 will move at a rate of 100 pixels every 1000 ms (1sec). It's not balls-on
|
||||
// accurate due to the way timers work, but it's pretty close. Expect tolerance
|
||||
// of +- 10 px. Also that speed assumes no drag
|
||||
public velocity: MicroPoint;
|
||||
|
||||
public mass: number;
|
||||
public elasticity: number;
|
||||
public acceleration: MicroPoint;
|
||||
public drag: MicroPoint;
|
||||
public maxVelocity: MicroPoint;
|
||||
public angularVelocity: number;
|
||||
public angularAcceleration: number;
|
||||
public angularDrag: number;
|
||||
public maxAngular: number;
|
||||
public scrollFactor: MicroPoint;
|
||||
|
||||
public health: number;
|
||||
public moves: bool = true;
|
||||
public touching: number;
|
||||
public wasTouching: number;
|
||||
public allowCollisions: number;
|
||||
public last: MicroPoint;
|
||||
|
||||
// Input
|
||||
public inputEnabled: bool = false;
|
||||
private _inputOver: bool = false;
|
||||
|
||||
public onInputOver: Phaser.Signal;
|
||||
public onInputOut: Phaser.Signal;
|
||||
public onInputDown: Phaser.Signal;
|
||||
public onInputUp: Phaser.Signal;
|
||||
|
||||
public preUpdate() {
|
||||
|
||||
// flicker time
|
||||
|
||||
this.last.x = this.bounds.x;
|
||||
this.last.y = this.bounds.y;
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
}
|
||||
|
||||
public postUpdate() {
|
||||
|
||||
if (this.moves)
|
||||
{
|
||||
this.updateMotion();
|
||||
}
|
||||
|
||||
if (this.inputEnabled)
|
||||
{
|
||||
this.updateInput();
|
||||
}
|
||||
|
||||
this.wasTouching = this.touching;
|
||||
this.touching = Collision.NONE;
|
||||
|
||||
}
|
||||
|
||||
private updateInput() {
|
||||
}
|
||||
|
||||
private updateMotion() {
|
||||
|
||||
var delta: number;
|
||||
var velocityDelta: number;
|
||||
|
||||
velocityDelta = (this._game.motion.computeVelocity(this.angularVelocity, this.angularAcceleration, this.angularDrag, this.maxAngular) - this.angularVelocity) / 2;
|
||||
this.angularVelocity += velocityDelta;
|
||||
this._angle += this.angularVelocity * this._game.time.elapsed;
|
||||
this.angularVelocity += velocityDelta;
|
||||
|
||||
velocityDelta = (this._game.motion.computeVelocity(this.velocity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2;
|
||||
this.velocity.x += velocityDelta;
|
||||
delta = this.velocity.x * this._game.time.elapsed;
|
||||
this.velocity.x += velocityDelta;
|
||||
this.bounds.x += delta;
|
||||
|
||||
velocityDelta = (this._game.motion.computeVelocity(this.velocity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2;
|
||||
this.velocity.y += velocityDelta;
|
||||
delta = this.velocity.y * this._game.time.elapsed;
|
||||
this.velocity.y += velocityDelta;
|
||||
this.bounds.y += delta;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if some <code>GameObject</code> overlaps this <code>GameObject</code> or <code>Group</code>.
|
||||
* If the group has a LOT of things in it, it might be faster to use <code>G.overlaps()</code>.
|
||||
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
|
||||
*
|
||||
* @param ObjectOrGroup The object or group being tested.
|
||||
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether or not the two objects overlap.
|
||||
*/
|
||||
public overlaps(ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
|
||||
|
||||
if (ObjectOrGroup.isGroup)
|
||||
{
|
||||
var results: bool = false;
|
||||
var i: number = 0;
|
||||
var members = <Group> ObjectOrGroup.members;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
if (this.overlaps(members[i++], InScreenSpace, Camera))
|
||||
{
|
||||
results = true;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
if (typeof ObjectOrGroup === 'Tilemap')
|
||||
{
|
||||
//Since tilemap's have to be the caller, not the target, to do proper tile-based collisions,
|
||||
// we redirect the call to the tilemap overlap here.
|
||||
return ObjectOrGroup.overlaps(this, InScreenSpace, Camera);
|
||||
}
|
||||
*/
|
||||
|
||||
//var object: GameObject = ObjectOrGroup;
|
||||
|
||||
if (!InScreenSpace)
|
||||
{
|
||||
return (ObjectOrGroup.x + ObjectOrGroup.width > this.x) && (ObjectOrGroup.x < this.x + this.width) &&
|
||||
(ObjectOrGroup.y + ObjectOrGroup.height > this.y) && (ObjectOrGroup.y < this.y + this.height);
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
var objectScreenPos: Point = ObjectOrGroup.getScreenXY(null, Camera);
|
||||
|
||||
this.getScreenXY(this._point, Camera);
|
||||
|
||||
return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
|
||||
(objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this <code>GameObject</code> were located at the given position, would it overlap the <code>GameObject</code> or <code>Group</code>?
|
||||
* This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size numbero account.
|
||||
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
|
||||
*
|
||||
* @param X The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param Y The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param ObjectOrGroup The object or group being tested.
|
||||
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether or not the two objects overlap.
|
||||
*/
|
||||
public overlapsAt(X: number, Y: number, ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
|
||||
|
||||
if (ObjectOrGroup.isGroup)
|
||||
{
|
||||
var results: bool = false;
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
var members = ObjectOrGroup.members;
|
||||
|
||||
while (i < length)
|
||||
{
|
||||
if (this.overlapsAt(X, Y, members[i++], InScreenSpace, Camera))
|
||||
{
|
||||
results = true;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/*
|
||||
if (typeof ObjectOrGroup === 'Tilemap')
|
||||
{
|
||||
//Since tilemap's have to be the caller, not the target, to do proper tile-based collisions,
|
||||
// we redirect the call to the tilemap overlap here.
|
||||
//However, since this is overlapsAt(), we also have to invent the appropriate position for the tilemap.
|
||||
//So we calculate the offset between the player and the requested position, and subtract that from the tilemap.
|
||||
var tilemap: Tilemap = ObjectOrGroup;
|
||||
return tilemap.overlapsAt(tilemap.x - (X - this.x), tilemap.y - (Y - this.y), this, InScreenSpace, Camera);
|
||||
}
|
||||
*/
|
||||
|
||||
//var object: GameObject = ObjectOrGroup;
|
||||
|
||||
if (!InScreenSpace)
|
||||
{
|
||||
return (ObjectOrGroup.x + ObjectOrGroup.width > X) && (ObjectOrGroup.x < X + this.width) &&
|
||||
(ObjectOrGroup.y + ObjectOrGroup.height > Y) && (ObjectOrGroup.y < Y + this.height);
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
var objectScreenPos: Point = ObjectOrGroup.getScreenXY(null, Camera);
|
||||
|
||||
this._point.x = X - Camera.scroll.x * this.scrollFactor.x; //copied from getScreenXY()
|
||||
this._point.y = Y - Camera.scroll.y * this.scrollFactor.y;
|
||||
this._point.x += (this._point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
this._point.y += (this._point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
|
||||
(objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a point in 2D world space overlaps this <code>GameObject</code>.
|
||||
*
|
||||
* @param Point The point in world space you want to check.
|
||||
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap.
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether or not the point overlaps this object.
|
||||
*/
|
||||
public overlapsPoint(point: Point, InScreenSpace: bool = false, Camera: Camera = null): bool {
|
||||
|
||||
if (!InScreenSpace)
|
||||
{
|
||||
return (point.x > this.x) && (point.x < this.x + this.width) && (point.y > this.y) && (point.y < this.y + this.height);
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
var X: number = point.x - Camera.scroll.x;
|
||||
var Y: number = point.y - Camera.scroll.y;
|
||||
|
||||
this.getScreenXY(this._point, Camera);
|
||||
|
||||
return (X > this._point.x) && (X < this._point.x + this.width) && (Y > this._point.y) && (Y < this._point.y + this.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and see if this object is currently on screen.
|
||||
*
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return Whether the object is on screen or not.
|
||||
*/
|
||||
public onScreen(Camera: Camera = null): bool {
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
this.getScreenXY(this._point, Camera);
|
||||
|
||||
return (this._point.x + this.width > 0) && (this._point.x < Camera.width) && (this._point.y + this.height > 0) && (this._point.y < Camera.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to figure out the on-screen position of the object.
|
||||
*
|
||||
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
* @param Point Takes a <code>MicroPoint</code> object and assigns the post-scrolled X and Y values of this object to it.
|
||||
*
|
||||
* @return The <code>MicroPoint</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
|
||||
*/
|
||||
public getScreenXY(point: MicroPoint = null, Camera: Camera = null): MicroPoint {
|
||||
|
||||
if (point == null)
|
||||
{
|
||||
point = new MicroPoint();
|
||||
}
|
||||
|
||||
if (Camera == null)
|
||||
{
|
||||
Camera = this._game.camera;
|
||||
}
|
||||
|
||||
point.x = this.x - Camera.scroll.x * this.scrollFactor.x;
|
||||
point.y = this.y - Camera.scroll.y * this.scrollFactor.y;
|
||||
point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the object collides or not. For more control over what directions
|
||||
* the object will collide from, use collision constants (like LEFT, FLOOR, etc)
|
||||
* to set the value of allowCollisions directly.
|
||||
*/
|
||||
public get solid(): bool {
|
||||
return (this.allowCollisions & Collision.ANY) > Collision.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public set solid(Solid: bool) {
|
||||
|
||||
if (Solid)
|
||||
{
|
||||
this.allowCollisions = Collision.ANY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowCollisions = Collision.NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the midpoint of this object in world coordinates.
|
||||
*
|
||||
* @Point Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
|
||||
*
|
||||
* @return A <code>Point</code> object containing the midpoint of this object in world coordinates.
|
||||
*/
|
||||
public getMidpoint(point: MicroPoint = null): MicroPoint {
|
||||
|
||||
if (point == null)
|
||||
{
|
||||
point = new MicroPoint();
|
||||
}
|
||||
|
||||
point.copyFrom(this.bounds.center);
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for reviving game objects.
|
||||
* Resets their existence flags and position.
|
||||
*
|
||||
* @param X The new X position of this object.
|
||||
* @param Y The new Y position of this object.
|
||||
*/
|
||||
public reset(X: number, Y: number) {
|
||||
|
||||
this.revive();
|
||||
this.touching = Collision.NONE;
|
||||
this.wasTouching = Collision.NONE;
|
||||
this.x = X;
|
||||
this.y = Y;
|
||||
this.last.x = X;
|
||||
this.last.y = Y;
|
||||
this.velocity.x = 0;
|
||||
this.velocity.y = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for checking if this object is touching a particular surface.
|
||||
* For slightly better performance you can just & the value directly numbero <code>touching</code>.
|
||||
* However, this method is good for readability and accessibility.
|
||||
*
|
||||
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @return Whether the object is touching an object in (any of) the specified direction(s) this frame.
|
||||
*/
|
||||
public isTouching(Direction: number): bool {
|
||||
return (this.touching & Direction) > Collision.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for checking if this object is just landed on a particular surface.
|
||||
*
|
||||
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @return Whether the object just landed on (any of) the specified surface(s) this frame.
|
||||
*/
|
||||
public justTouched(Direction: number): bool {
|
||||
return ((this.touching & Direction) > Collision.NONE) && ((this.wasTouching & Direction) <= Collision.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces the "health" variable of this sprite by the amount specified in Damage.
|
||||
* Calls kill() if health drops to or below zero.
|
||||
*
|
||||
* @param Damage How much health to take away (use a negative number to give a health bonus).
|
||||
*/
|
||||
public hurt(Damage: number) {
|
||||
|
||||
this.health = this.health - Damage;
|
||||
|
||||
if (this.health <= 0)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this.bounds.x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this.bounds.x = value;
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this.bounds.y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this.bounds.y = value;
|
||||
}
|
||||
|
||||
public get rotation(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public set rotation(value: number) {
|
||||
this._angle = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
public get angle(): number {
|
||||
return this._angle;
|
||||
}
|
||||
|
||||
public set angle(value: number) {
|
||||
this._angle = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
public set width(value:number) {
|
||||
this.bounds.width = value;
|
||||
}
|
||||
|
||||
public set height(value:number) {
|
||||
this.bounds.height = value;
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,457 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GeomSprite
|
||||
*
|
||||
* A GeomSprite is a special kind of GameObject that contains a base geometry class (Circle, Line, Point, Rectangle).
|
||||
* They can be rendered in the game and used for collision just like any other game object. Display of them is controlled
|
||||
* via the lineWidth / lineColor / fillColor and renderOutline / renderFill properties.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class GeomSprite extends GameObject {
|
||||
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0) {
|
||||
|
||||
super(game, x, y);
|
||||
|
||||
this.type = GeomSprite.UNASSIGNED;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// local rendering related temp vars to help avoid gc spikes
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _dw: number = 0;
|
||||
private _dh: number = 0;
|
||||
|
||||
public type: number = 0;
|
||||
|
||||
public static UNASSIGNED: number = 0;
|
||||
public static CIRCLE: number = 1;
|
||||
public static LINE: number = 2;
|
||||
public static POINT: number = 3;
|
||||
public static RECTANGLE: number = 4;
|
||||
|
||||
public circle: Circle;
|
||||
public line: Line;
|
||||
public point: Point;
|
||||
public rect: Rectangle;
|
||||
|
||||
public renderOutline: bool = true;
|
||||
public renderFill: bool = true;
|
||||
|
||||
public lineWidth: number = 1;
|
||||
public lineColor: string = 'rgb(0,255,0)';
|
||||
public fillColor: string = 'rgb(0,100,0)';
|
||||
|
||||
loadCircle(circle:Circle): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.circle = circle;
|
||||
this.type = GeomSprite.CIRCLE;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
loadLine(line:Line): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.line = line;
|
||||
this.type = GeomSprite.LINE;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
loadPoint(point:Point): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.point = point;
|
||||
this.type = GeomSprite.POINT;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
loadRectangle(rect:Rectangle): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.rect = rect;
|
||||
this.type = GeomSprite.RECTANGLE;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
createCircle(diameter: number): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.circle = new Circle(this.x, this.y, diameter);
|
||||
this.type = GeomSprite.CIRCLE;
|
||||
this.bounds.setTo(this.circle.x - this.circle.radius, this.circle.y - this.circle.radius, this.circle.diameter, this.circle.diameter);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
createLine(x: number, y: number): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.line = new Line(this.x, this.y, x, y);
|
||||
this.type = GeomSprite.LINE;
|
||||
this.bounds.setTo(this.x, this.y, this.line.width, this.line.height);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
createPoint(): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.point = new Point(this.x, this.y);
|
||||
this.type = GeomSprite.POINT;
|
||||
this.bounds.width = 1;
|
||||
this.bounds.height = 1;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
createRectangle(width: number, height: number): GeomSprite {
|
||||
|
||||
this.refresh();
|
||||
this.rect = new Rectangle(this.x, this.y, width, height);
|
||||
this.type = GeomSprite.RECTANGLE;
|
||||
this.bounds.copyFrom(this.rect);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
refresh() {
|
||||
|
||||
this.circle = null;
|
||||
this.line = null;
|
||||
this.point = null;
|
||||
this.rect = null;
|
||||
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
// Update bounds and position?
|
||||
if (this.type == GeomSprite.UNASSIGNED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (this.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
this.circle.x = this.x;
|
||||
this.circle.y = this.y;
|
||||
this.bounds.width = this.circle.diameter;
|
||||
this.bounds.height = this.circle.diameter;
|
||||
}
|
||||
else if (this.type == GeomSprite.LINE)
|
||||
{
|
||||
this.line.x1 = this.x;
|
||||
this.line.y1 = this.y;
|
||||
this.bounds.setTo(this.x, this.y, this.line.width, this.line.height);
|
||||
}
|
||||
else if (this.type == GeomSprite.POINT)
|
||||
{
|
||||
this.point.x = this.x;
|
||||
this.point.y = this.y;
|
||||
}
|
||||
else if (this.type == GeomSprite.RECTANGLE)
|
||||
{
|
||||
this.rect.x = this.x;
|
||||
this.rect.y = this.y;
|
||||
this.bounds.copyFrom(this.rect);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public inCamera(camera: Rectangle): bool {
|
||||
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
{
|
||||
this._dx = this.bounds.x - (camera.x * this.scrollFactor.x);
|
||||
this._dy = this.bounds.y - (camera.y * this.scrollFactor.x);
|
||||
this._dw = this.bounds.width * this.scale.x;
|
||||
this._dh = this.bounds.height * this.scale.y;
|
||||
|
||||
return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh);
|
||||
}
|
||||
else
|
||||
{
|
||||
return camera.intersects(this.bounds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
// Render checks
|
||||
if (this.type == GeomSprite.UNASSIGNED || this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.inCamera(camera.worldView) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y);
|
||||
this._dw = this.bounds.width * this.scale.x;
|
||||
this._dh = this.bounds.height * this.scale.y;
|
||||
|
||||
// Circles are drawn center based
|
||||
if (this.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
this._dx += this.circle.radius;
|
||||
this._dy += this.circle.radius;
|
||||
}
|
||||
|
||||
// Apply camera difference
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
{
|
||||
this._dx -= (camera.worldView.x * this.scrollFactor.x);
|
||||
this._dy -= (camera.worldView.y * this.scrollFactor.y);
|
||||
}
|
||||
|
||||
// Rotation is disabled for now as I don't want it to be misleading re: collision
|
||||
/*
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2) - this.origin.x, this._dy + (this._dh / 2) - this.origin.y);
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
}
|
||||
*/
|
||||
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
this._dw = Math.round(this._dw);
|
||||
this._dh = Math.round(this._dh);
|
||||
|
||||
this._game.stage.saveCanvasValues();
|
||||
|
||||
// Debug
|
||||
//this._game.stage.context.fillStyle = 'rgba(255,0,0,0.5)';
|
||||
//this._game.stage.context.fillRect(this.bounds.x, this.bounds.y, this.bounds.width, this.bounds.height);
|
||||
|
||||
this._game.stage.context.lineWidth = this.lineWidth;
|
||||
this._game.stage.context.strokeStyle = this.lineColor;
|
||||
this._game.stage.context.fillStyle = this.fillColor;
|
||||
|
||||
if (this._game.stage.fillStyle !== this.fillColor)
|
||||
{
|
||||
}
|
||||
|
||||
// Primitive Renderer
|
||||
if (this.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.arc(this._dx, this._dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this._game.stage.context.stroke();
|
||||
|
||||
if (this.renderFill)
|
||||
{
|
||||
this._game.stage.context.fill();
|
||||
}
|
||||
|
||||
this._game.stage.context.closePath();
|
||||
}
|
||||
else if (this.type == GeomSprite.LINE)
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.moveTo(this._dx, this._dy);
|
||||
this._game.stage.context.lineTo(this.line.x2, this.line.y2);
|
||||
this._game.stage.context.stroke();
|
||||
this._game.stage.context.closePath();
|
||||
}
|
||||
else if (this.type == GeomSprite.POINT)
|
||||
{
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 2, 2);
|
||||
}
|
||||
else if (this.type == GeomSprite.RECTANGLE)
|
||||
{
|
||||
// We can use the faster fillRect if we don't need the outline
|
||||
if (this.renderOutline == false)
|
||||
{
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.rect(this._dx, this._dy, this.rect.width, this.rect.height);
|
||||
this._game.stage.context.stroke();
|
||||
|
||||
if (this.renderFill)
|
||||
{
|
||||
this._game.stage.context.fill();
|
||||
}
|
||||
|
||||
this._game.stage.context.closePath();
|
||||
}
|
||||
|
||||
// And now the edge points
|
||||
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
this.renderPoint(this._dx, this._dy, this.rect.topLeft, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.topCenter, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.topRight, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.leftCenter, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.center, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.rightCenter, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.bottomLeft, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.bottomCenter, 2);
|
||||
this.renderPoint(this._dx, this._dy, this.rect.bottomRight, 2);
|
||||
|
||||
}
|
||||
|
||||
this._game.stage.restoreCanvasValues();
|
||||
|
||||
if (this.rotation !== 0)
|
||||
{
|
||||
this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public renderPoint(offsetX, offsetY, point, size) {
|
||||
|
||||
offsetX = 0;
|
||||
offsetY = 0;
|
||||
this._game.stage.context.fillRect(offsetX + point.x, offsetY + point.y, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
//this._game.stage.context.fillStyle = color;
|
||||
//this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
//this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
//this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
//this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
// Gives a basic boolean response to a geometric collision.
|
||||
// If you need the details of the collision use the Collision functions instead and inspect the IntersectResult object.
|
||||
public collide(source: GeomSprite): bool {
|
||||
|
||||
// Circle vs. Circle
|
||||
if (this.type == GeomSprite.CIRCLE && source.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
return Collision.circleToCircle(this.circle, source.circle).result;
|
||||
}
|
||||
|
||||
// Circle vs. Rect
|
||||
if (this.type == GeomSprite.CIRCLE && source.type == GeomSprite.RECTANGLE)
|
||||
{
|
||||
return Collision.circleToRectangle(this.circle, source.rect).result;
|
||||
}
|
||||
|
||||
// Circle vs. Point
|
||||
if (this.type == GeomSprite.CIRCLE && source.type == GeomSprite.POINT)
|
||||
{
|
||||
return Collision.circleContainsPoint(this.circle, source.point).result;
|
||||
}
|
||||
|
||||
// Circle vs. Line
|
||||
if (this.type == GeomSprite.CIRCLE && source.type == GeomSprite.LINE)
|
||||
{
|
||||
return Collision.lineToCircle(source.line, this.circle).result;
|
||||
}
|
||||
|
||||
// Rect vs. Rect
|
||||
if (this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.RECTANGLE)
|
||||
{
|
||||
return Collision.rectangleToRectangle(this.rect, source.rect).result;
|
||||
}
|
||||
|
||||
// Rect vs. Circle
|
||||
if (this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
return Collision.circleToRectangle(source.circle, this.rect).result;
|
||||
}
|
||||
|
||||
// Rect vs. Point
|
||||
if (this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.POINT)
|
||||
{
|
||||
return Collision.pointToRectangle(source.point, this.rect).result;
|
||||
}
|
||||
|
||||
// Rect vs. Line
|
||||
if (this.type == GeomSprite.RECTANGLE && source.type == GeomSprite.LINE)
|
||||
{
|
||||
return Collision.lineToRectangle(source.line, this.rect).result;
|
||||
}
|
||||
|
||||
// Point vs. Point
|
||||
if (this.type == GeomSprite.POINT && source.type == GeomSprite.POINT)
|
||||
{
|
||||
return this.point.equals(source.point);
|
||||
}
|
||||
|
||||
// Point vs. Circle
|
||||
if (this.type == GeomSprite.POINT && source.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
return Collision.circleContainsPoint(source.circle, this.point).result;
|
||||
}
|
||||
|
||||
// Point vs. Rect
|
||||
if (this.type == GeomSprite.POINT && source.type == GeomSprite.RECTANGLE)
|
||||
{
|
||||
return Collision.pointToRectangle(this.point, source.rect).result;
|
||||
}
|
||||
|
||||
// Point vs. Line
|
||||
if (this.type == GeomSprite.POINT && source.type == GeomSprite.LINE)
|
||||
{
|
||||
return source.line.isPointOnLine(this.point.x, this.point.y);
|
||||
}
|
||||
|
||||
// Line vs. Line
|
||||
if (this.type == GeomSprite.LINE && source.type == GeomSprite.LINE)
|
||||
{
|
||||
return Collision.lineSegmentToLineSegment(this.line, source.line).result;
|
||||
}
|
||||
|
||||
// Line vs. Circle
|
||||
if (this.type == GeomSprite.LINE && source.type == GeomSprite.CIRCLE)
|
||||
{
|
||||
return Collision.lineToCircle(this.line, source.circle).result;
|
||||
}
|
||||
|
||||
// Line vs. Rect
|
||||
if (this.type == GeomSprite.LINE && source.type == GeomSprite.RECTANGLE)
|
||||
{
|
||||
return Collision.lineSegmentToRectangle(this.line, source.rect).result;
|
||||
}
|
||||
|
||||
// Line vs. Point
|
||||
if (this.type == GeomSprite.LINE && source.type == GeomSprite.POINT)
|
||||
{
|
||||
return this.line.isPointOnLine(source.point.x, source.point.y);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Sprite.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Particle
|
||||
*
|
||||
* This is a simple particle class that extends a Sprite to have a slightly more
|
||||
* specialised behaviour. It is used exclusively by the Emitter class and can be extended as required.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Particle extends Sprite {
|
||||
|
||||
/**
|
||||
* Instantiate a new particle. Like <code>Sprite</code>, all meaningful creation
|
||||
* happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.lifespan = 0;
|
||||
this.friction = 500;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long this particle lives before it disappears.
|
||||
* NOTE: this is a maximum, not a minimum; the object
|
||||
* could get recycled before its lifespan is up.
|
||||
*/
|
||||
public lifespan: number;
|
||||
|
||||
/**
|
||||
* Determines how quickly the particles come to rest on the ground.
|
||||
* Only used if the particle has gravity-like acceleration applied.
|
||||
* @default 500
|
||||
*/
|
||||
public friction: number;
|
||||
|
||||
/**
|
||||
* The particle's main update logic. Basically it checks to see if it should
|
||||
* be dead yet, and then has some special bounce behavior if there is some gravity on it.
|
||||
*/
|
||||
public update() {
|
||||
//lifespan behavior
|
||||
if (this.lifespan <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.lifespan -= this._game.time.elapsed;
|
||||
|
||||
if (this.lifespan <= 0)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
|
||||
//simpler bounce/spin behavior for now
|
||||
if (this.touching)
|
||||
{
|
||||
if (this.angularVelocity != 0)
|
||||
{
|
||||
this.angularVelocity = -this.angularVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.acceleration.y > 0) //special behavior for particles with gravity
|
||||
{
|
||||
if (this.touching & Collision.FLOOR)
|
||||
{
|
||||
this.drag.x = this.friction;
|
||||
|
||||
if (!(this.wasTouching & Collision.FLOOR))
|
||||
{
|
||||
if (this.velocity.y < -this.elasticity * 10)
|
||||
{
|
||||
if (this.angularVelocity != 0)
|
||||
{
|
||||
this.angularVelocity *= -this.elasticity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.velocity.y = 0;
|
||||
this.angularVelocity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drag.x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever this object is launched by a <code>Emitter</code>.
|
||||
* You can override this to add custom behavior like a sound or AI or something.
|
||||
*/
|
||||
public onEmit() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,351 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../AnimationManager.ts" />
|
||||
/// <reference path="GameObject.ts" />
|
||||
/// <reference path="../system/Camera.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Sprite
|
||||
*
|
||||
* The Sprite GameObject is an extension of the core GameObject that includes support for animation and dynamic textures.
|
||||
* It's probably the most used GameObject of all.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Sprite extends GameObject {
|
||||
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null) {
|
||||
|
||||
super(game, x, y);
|
||||
|
||||
this._texture = null;
|
||||
|
||||
this.animations = new AnimationManager(this._game, this);
|
||||
|
||||
if (key !== null)
|
||||
{
|
||||
this.loadGraphic(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.bounds.width = 16;
|
||||
this.bounds.height = 16;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _texture;
|
||||
private _dynamicTexture: bool = false;
|
||||
|
||||
// local rendering related temp vars to help avoid gc spikes
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
private _sw: number = 0;
|
||||
private _sh: number = 0;
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _dw: number = 0;
|
||||
private _dh: number = 0;
|
||||
|
||||
public animations: AnimationManager;
|
||||
|
||||
public renderDebug: bool = false;
|
||||
public renderDebugColor: string = 'rgba(0,255,0,0.5)';
|
||||
public renderDebugPointColor: string = 'rgba(255,255,255,1)';
|
||||
public flipped: bool = false;
|
||||
|
||||
public loadGraphic(key: string): Sprite {
|
||||
|
||||
if (this._game.cache.getImage(key) !== null)
|
||||
{
|
||||
if (this._game.cache.isSpriteSheet(key) == false)
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.bounds.width = this._texture.width;
|
||||
this.bounds.height = this._texture.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.animations.loadFrameData(this._game.cache.getFrameData(key));
|
||||
}
|
||||
|
||||
this._dynamicTexture = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public loadDynamicTexture(texture: DynamicTexture): Sprite {
|
||||
|
||||
this._texture = texture;
|
||||
|
||||
this.bounds.width = this._texture.width;
|
||||
this.bounds.height = this._texture.height;
|
||||
|
||||
this._dynamicTexture = true;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public makeGraphic(width: number, height: number, color: number = 0xffffffff): Sprite {
|
||||
|
||||
this._texture = null;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
this._dynamicTexture = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public inCamera(camera: Rectangle): bool {
|
||||
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
{
|
||||
this._dx = this.bounds.x - (camera.x * this.scrollFactor.x);
|
||||
this._dy = this.bounds.y - (camera.y * this.scrollFactor.x);
|
||||
this._dw = this.bounds.width * this.scale.x;
|
||||
this._dh = this.bounds.height * this.scale.y;
|
||||
|
||||
return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh);
|
||||
}
|
||||
else
|
||||
{
|
||||
return camera.intersects(this.bounds, this.bounds.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public postUpdate() {
|
||||
|
||||
this.animations.update();
|
||||
|
||||
super.postUpdate();
|
||||
|
||||
}
|
||||
|
||||
public set frame(value: number) {
|
||||
this.animations.frame = value;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this.animations.frame;
|
||||
}
|
||||
|
||||
public set frameName(value: string) {
|
||||
this.animations.frameName = value;
|
||||
}
|
||||
|
||||
public get frameName(): string {
|
||||
return this.animations.frameName;
|
||||
}
|
||||
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
// Render checks
|
||||
if (this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.inCamera(camera.worldView) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
this._sw = this.bounds.width;
|
||||
this._sh = this.bounds.height;
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
|
||||
this._dw = this.bounds.width * this.scale.x;
|
||||
this._dh = this.bounds.height * this.scale.y;
|
||||
|
||||
if (this.align == GameObject.ALIGN_TOP_CENTER)
|
||||
{
|
||||
this._dx -= this.bounds.halfWidth * this.scale.x;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_TOP_RIGHT)
|
||||
{
|
||||
this._dx -= this.bounds.width * this.scale.x;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER_LEFT)
|
||||
{
|
||||
this._dy -= this.bounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER)
|
||||
{
|
||||
this._dx -= this.bounds.halfWidth * this.scale.x;
|
||||
this._dy -= this.bounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER_RIGHT)
|
||||
{
|
||||
this._dx -= this.bounds.width * this.scale.x;
|
||||
this._dy -= this.bounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_LEFT)
|
||||
{
|
||||
this._dy -= this.bounds.height * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_CENTER)
|
||||
{
|
||||
this._dx -= this.bounds.halfWidth * this.scale.x;
|
||||
this._dy -= this.bounds.height * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_RIGHT)
|
||||
{
|
||||
this._dx -= this.bounds.width * this.scale.x;
|
||||
this._dy -= this.bounds.height * this.scale.y;
|
||||
}
|
||||
|
||||
if (this._dynamicTexture == false && this.animations.currentFrame !== null)
|
||||
{
|
||||
this._sx = this.animations.currentFrame.x;
|
||||
this._sy = this.animations.currentFrame.y;
|
||||
|
||||
if (this.animations.currentFrame.trimmed)
|
||||
{
|
||||
this._dx += this.animations.currentFrame.spriteSourceSizeX;
|
||||
this._dy += this.animations.currentFrame.spriteSourceSizeY;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply camera difference
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
{
|
||||
this._dx -= (camera.worldView.x * this.scrollFactor.x);
|
||||
this._dy -= (camera.worldView.y * this.scrollFactor.y);
|
||||
}
|
||||
|
||||
// Rotation - needs to work from origin point really, but for now from center
|
||||
if (this.angle !== 0 || this.flipped == true)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
|
||||
if (this.flipped == true)
|
||||
{
|
||||
this._game.stage.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this._sx = Math.round(this._sx);
|
||||
this._sy = Math.round(this._sy);
|
||||
this._sw = Math.round(this._sw);
|
||||
this._sh = Math.round(this._sh);
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
this._dw = Math.round(this._dw);
|
||||
this._dh = Math.round(this._dh);
|
||||
|
||||
if (this._texture != null)
|
||||
{
|
||||
if (this._dynamicTexture)
|
||||
{
|
||||
this._game.stage.context.drawImage(
|
||||
this._texture.canvas, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
this._sh, // Source Height
|
||||
this._dx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._dy, // Destination Y
|
||||
this._dw, // Destination Width (always same as Source Width unless scaled)
|
||||
this._dh // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.drawImage(
|
||||
this._texture, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._sw, // Source Width
|
||||
this._sh, // Source Height
|
||||
this._dx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._dy, // Destination Y
|
||||
this._dw, // Destination Width (always same as Source Width unless scaled)
|
||||
this._dh // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
|
||||
if (this.flipped === true || this.rotation !== 0)
|
||||
{
|
||||
//this._game.stage.context.translate(0, 0);
|
||||
this._game.stage.context.restore();
|
||||
}
|
||||
|
||||
if (this.renderDebug)
|
||||
{
|
||||
this.renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Renders the bounding box around this Sprite and the contact points. Useful for visually debugging.
|
||||
private renderBounds(camera:Camera, cameraOffsetX:number, cameraOffsetY:number) {
|
||||
|
||||
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
|
||||
|
||||
this._game.stage.context.fillStyle = this.renderDebugColor;
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
this._game.stage.context.fillStyle = this.renderDebugPointColor;
|
||||
|
||||
var hw = this.bounds.halfWidth * this.scale.x;
|
||||
var hh = this.bounds.halfHeight * this.scale.y;
|
||||
var sw = (this.bounds.width * this.scale.x) - 1;
|
||||
var sh = (this.bounds.height * this.scale.y) - 1;
|
||||
|
||||
this._game.stage.context.fillRect(this._dx, this._dy, 1, 1); // top left
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1); // top center
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1); // top right
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1); // left center
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); // center
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); // right center
|
||||
this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1); // bottom left
|
||||
this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
|
||||
this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
|
||||
this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
|
||||
this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="GameObject.ts" />
|
||||
/// <reference path="../system/Tile.ts" />
|
||||
/// <reference path="../system/TilemapBuffer.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Tilemap
|
||||
*
|
||||
* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size.
|
||||
* Internally it creates a TilemapBuffer for each camera in the world.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Tilemap extends GameObject {
|
||||
|
||||
constructor(game: Game, key: string, mapData: string, format: number, tileWidth?: number = 0, tileHeight?: number = 0) {
|
||||
|
||||
super(game);
|
||||
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this._tilemapBuffers = [];
|
||||
|
||||
this.isGroup = false;
|
||||
|
||||
this.tileWidth = tileWidth;
|
||||
this.tileHeight = tileHeight;
|
||||
this.boundsInTiles = new Rectangle();
|
||||
this.mapFormat = format;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case Tilemap.FORMAT_CSV:
|
||||
this.parseCSV(game.cache.getText(mapData));
|
||||
break;
|
||||
|
||||
case Tilemap.FORMAT_TILED_JSON:
|
||||
this.parseTiledJSON(game.cache.getText(mapData));
|
||||
break;
|
||||
}
|
||||
|
||||
this.parseTileOffsets();
|
||||
this.createTilemapBuffers();
|
||||
|
||||
}
|
||||
|
||||
private _texture;
|
||||
private _tileOffsets;
|
||||
private _tilemapBuffers: TilemapBuffer[];
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
|
||||
public static FORMAT_CSV: number = 0;
|
||||
public static FORMAT_TILED_JSON: number = 1;
|
||||
|
||||
public mapData;
|
||||
public mapFormat: number;
|
||||
public boundsInTiles: Rectangle;
|
||||
|
||||
public tileWidth: number;
|
||||
public tileHeight: number;
|
||||
|
||||
public widthInTiles: number = 0;
|
||||
public heightInTiles: number = 0;
|
||||
|
||||
public widthInPixels: number = 0;
|
||||
public heightInPixels: number = 0;
|
||||
|
||||
// How many extra tiles to draw around the edge of the screen (for fast scrolling games, or to optimise mobile performance try increasing this)
|
||||
// The number is the amount of extra tiles PER SIDE, so a value of 10 would be (10 tiles + screen size + 10 tiles)
|
||||
public tileBoundary: number = 10;
|
||||
|
||||
private parseCSV(data: string) {
|
||||
|
||||
//console.log('parseMapData');
|
||||
|
||||
this.mapData = [];
|
||||
|
||||
// Trim any rogue whitespace from the data
|
||||
data = data.trim();
|
||||
|
||||
var rows = data.split("\n");
|
||||
//console.log('rows', rows);
|
||||
|
||||
for (var i = 0; i < rows.length; i++)
|
||||
{
|
||||
var column = rows[i].split(",");
|
||||
//console.log('column', column);
|
||||
var output = [];
|
||||
|
||||
if (column.length > 0)
|
||||
{
|
||||
// Set the width based on the first row
|
||||
if (this.widthInTiles == 0)
|
||||
{
|
||||
// Maybe -1?
|
||||
this.widthInTiles = column.length;
|
||||
}
|
||||
|
||||
// We have a new row of tiles
|
||||
this.heightInTiles++;
|
||||
|
||||
// Parse it
|
||||
for (var c = 0; c < column.length; c++)
|
||||
{
|
||||
output[c] = parseInt(column[c]);
|
||||
}
|
||||
|
||||
this.mapData.push(output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//console.log('final map array');
|
||||
//console.log(this.mapData);
|
||||
|
||||
if (this.widthInTiles > 0)
|
||||
{
|
||||
this.widthInPixels = this.tileWidth * this.widthInTiles;
|
||||
}
|
||||
|
||||
if (this.heightInTiles > 0)
|
||||
{
|
||||
this.heightInPixels = this.tileHeight * this.heightInTiles;
|
||||
}
|
||||
|
||||
this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles);
|
||||
|
||||
}
|
||||
|
||||
private parseTiledJSON(data: string) {
|
||||
|
||||
//console.log('parseTiledJSON');
|
||||
|
||||
this.mapData = [];
|
||||
|
||||
// Trim any rogue whitespace from the data
|
||||
data = data.trim();
|
||||
|
||||
// We ought to change this soon, so we have layer support, but for now let's just get it working
|
||||
var json = JSON.parse(data);
|
||||
|
||||
// Right now we assume no errors at all with the parsing (safe I know)
|
||||
this.tileWidth = json.tilewidth;
|
||||
this.tileHeight = json.tileheight;
|
||||
|
||||
// Parse the first layer only
|
||||
this.widthInTiles = json.layers[0].width;
|
||||
this.heightInTiles = json.layers[0].height;
|
||||
this.widthInPixels = this.widthInTiles * this.tileWidth;
|
||||
this.heightInPixels = this.heightInTiles * this.tileHeight;
|
||||
this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles);
|
||||
|
||||
//console.log('width in tiles', this.widthInTiles);
|
||||
//console.log('height in tiles', this.heightInTiles);
|
||||
//console.log('width in px', this.widthInPixels);
|
||||
//console.log('height in px', this.heightInPixels);
|
||||
|
||||
// Now let's get the data
|
||||
|
||||
var c = 0;
|
||||
var row;
|
||||
|
||||
for (var i = 0; i < json.layers[0].data.length; i++)
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
row = [];
|
||||
}
|
||||
|
||||
row.push(json.layers[0].data[i]);
|
||||
|
||||
c++;
|
||||
|
||||
if (c == this.widthInTiles)
|
||||
{
|
||||
this.mapData.push(row);
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//console.log('mapData');
|
||||
//console.log(this.mapData);
|
||||
|
||||
}
|
||||
|
||||
public getMapSegment(area: Rectangle) {
|
||||
}
|
||||
|
||||
private createTilemapBuffers() {
|
||||
|
||||
var cams = this._game.world.getAllCameras();
|
||||
|
||||
for (var i = 0; i < cams.length; i++)
|
||||
{
|
||||
this._tilemapBuffers[cams[i].ID] = new TilemapBuffer(this._game, cams[i], this, this._texture, this._tileOffsets);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private parseTileOffsets() {
|
||||
|
||||
this._tileOffsets = [];
|
||||
|
||||
var i = 0;
|
||||
|
||||
if (this.mapFormat == Tilemap.FORMAT_TILED_JSON)
|
||||
{
|
||||
// For some reason Tiled counts from 1 not 0
|
||||
this._tileOffsets[0] = null;
|
||||
i = 1;
|
||||
}
|
||||
|
||||
for (var ty = 0; ty < this._texture.height; ty += this.tileHeight)
|
||||
{
|
||||
for (var tx = 0; tx < this._texture.width; tx += this.tileWidth)
|
||||
{
|
||||
this._tileOffsets[i] = { x: tx, y: ty };
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
// Use a Signal?
|
||||
public addTilemapBuffers(camera:Camera) {
|
||||
|
||||
console.log('added new camera to tilemap');
|
||||
this._tilemapBuffers[camera.ID] = new TilemapBuffer(this._game, camera, this, this._texture, this._tileOffsets);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public update() {
|
||||
|
||||
// Check if any of the cameras have scrolled far enough for us to need to refresh a TilemapBuffer
|
||||
this._tilemapBuffers[0].update();
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
this._tilemapBuffers[0].renderDebugInfo(x, y, color);
|
||||
}
|
||||
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
if (this.visible === false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this._dx = cameraOffsetX + (this.bounds.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.bounds.y - camera.worldView.y);
|
||||
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
|
||||
if (this._tilemapBuffers[camera.ID])
|
||||
{
|
||||
//this._tilemapBuffers[camera.ID].render(this._dx, this._dy);
|
||||
this._tilemapBuffers[camera.ID].render(cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - IntersectResult
|
||||
*
|
||||
* A light-weight result object to hold the results of an intersection. For when you need more than just true/false.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class IntersectResult {
|
||||
|
||||
/**
|
||||
* Did they intersect or not?
|
||||
* @property result
|
||||
* @type Boolean
|
||||
*/
|
||||
result: bool = false;
|
||||
|
||||
/**
|
||||
* @property x
|
||||
* @type Number
|
||||
*/
|
||||
x: number;
|
||||
|
||||
/**
|
||||
* @property y
|
||||
* @type Number
|
||||
*/
|
||||
y: number;
|
||||
|
||||
/**
|
||||
* @property x1
|
||||
* @type Number
|
||||
*/
|
||||
x1: number;
|
||||
|
||||
/**
|
||||
* @property y1
|
||||
* @type Number
|
||||
*/
|
||||
y1: number;
|
||||
|
||||
/**
|
||||
* @property x2
|
||||
* @type Number
|
||||
*/
|
||||
x2: number;
|
||||
|
||||
/**
|
||||
* @property y2
|
||||
* @type Number
|
||||
*/
|
||||
y2: number;
|
||||
|
||||
/**
|
||||
* @property width
|
||||
* @type Number
|
||||
*/
|
||||
width: number;
|
||||
|
||||
/**
|
||||
* @property height
|
||||
* @type Number
|
||||
*/
|
||||
height: number;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method setTo
|
||||
* @param {Number} x1
|
||||
* @param {Number} y1
|
||||
* @param {Number} [x2]
|
||||
* @param {Number} [y2]
|
||||
* @param {Number} [width]
|
||||
* @param {Number} [height]
|
||||
*/
|
||||
setTo(x1: number, y1: number, x2?: number = 0, y2?: number = 0, width?: number = 0, height?: number = 0) {
|
||||
|
||||
this.x = x1;
|
||||
this.y = y1;
|
||||
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - MicroPoint
|
||||
*
|
||||
* The MicroPoint object represents a location in a two-dimensional coordinate system,
|
||||
* where x represents the horizontal axis and y represents the vertical axis.
|
||||
* It is different to the Point class in that it doesn't contain any of the help methods like add/substract/distanceTo, etc.
|
||||
* Use a MicroPoint when all you literally need is a solid container for x and y (such as in the Rectangle class).
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class MicroPoint {
|
||||
|
||||
/**
|
||||
* Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
|
||||
* @class MicroPoint
|
||||
* @constructor
|
||||
* @param {Number} x The horizontal position of this point (default 0)
|
||||
* @param {Number} y The vertical position of this point (default 0)
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0, parent?:any = null) {
|
||||
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this.parent = parent;
|
||||
|
||||
}
|
||||
|
||||
private _x: number;
|
||||
private _y: number;
|
||||
|
||||
public parent: any;
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public get x(): number {
|
||||
|
||||
return this._x;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
public get y(): number {
|
||||
|
||||
return this._y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public set x(value: number) {
|
||||
|
||||
this._x = value;
|
||||
|
||||
if (this.parent)
|
||||
{
|
||||
this.parent.updateBounds();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
public set y(value:number) {
|
||||
|
||||
this._y = value;
|
||||
|
||||
if (this.parent)
|
||||
{
|
||||
this.parent.updateBounds();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the x and y values from any given object to this MicroPoint.
|
||||
* @method copyFrom
|
||||
* @param {any} source - The object to copy from.
|
||||
* @return {MicroPoint} This MicroPoint object. Useful for chaining method calls.
|
||||
**/
|
||||
public copyFrom(source: any): MicroPoint {
|
||||
|
||||
return this.setTo(source.x, source.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the x and y values from this MicroPoint to any given object.
|
||||
* @method copyTo
|
||||
* @param {any} target - The object to copy to.
|
||||
* @return {any} The target object.
|
||||
**/
|
||||
public copyTo(target: any): MicroPoint {
|
||||
|
||||
target.x = this._x;
|
||||
target.y = this._y;
|
||||
|
||||
return target;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x and y values of this MicroPoint object to the given coordinates.
|
||||
* @method setTo
|
||||
* @param {Number} x - The horizontal position of this point.
|
||||
* @param {Number} y - The vertical position of this point.
|
||||
* @return {MicroPoint} This MicroPoint object. Useful for chaining method calls.
|
||||
**/
|
||||
public setTo(x: number, y: number, callParent?:bool = true): MicroPoint {
|
||||
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
|
||||
if (this.parent != null && callParent == true)
|
||||
{
|
||||
this.parent.updateBounds();
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this MicroPoint object and the given object are equal. They are equal if they have the same x and y values.
|
||||
* @method equals
|
||||
* @param {any} point - The object to compare against. Must have x and y properties.
|
||||
* @return {Boolean} A value of true if the object is equal to this MicroPoin object; false if it is not equal.
|
||||
**/
|
||||
public equals(toCompare): bool {
|
||||
|
||||
if (this._x === toCompare.x && this._y === toCompare.y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
**/
|
||||
public toString(): string {
|
||||
|
||||
return '[{MicroPoint (x=' + this._x + ' y=' + this._y + ')}]';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Point
|
||||
*
|
||||
* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Point {
|
||||
|
||||
/**
|
||||
* Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
|
||||
* @class Point
|
||||
* @constructor
|
||||
* @param {Number} x The horizontal position of this point (default 0)
|
||||
* @param {Number} y The vertical position of this point (default 0)
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0) {
|
||||
|
||||
this.setTo(x, y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The horizontal position of this point (default 0)
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public x: number;
|
||||
|
||||
/**
|
||||
* The vertical position of this point (default 0)
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
public y: number;
|
||||
|
||||
/**
|
||||
* Adds the coordinates of another point to the coordinates of this point to create a new point.
|
||||
* @method add
|
||||
* @param {Point} point - The point to be added.
|
||||
* @return {Point} The new Point object.
|
||||
**/
|
||||
public add(toAdd: Point, output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this.x + toAdd.x, this.y + toAdd.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given values to the coordinates of this point and returns it
|
||||
* @method addTo
|
||||
* @param {Number} x - The amount to add to the x value of the point
|
||||
* @param {Number} y - The amount to add to the x value of the point
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public addTo(x?: number = 0, y?: number = 0): Point {
|
||||
|
||||
return this.setTo(this.x + x, this.y + y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given values to the coordinates of this point and returns it
|
||||
* @method addTo
|
||||
* @param {Number} x - The amount to add to the x value of the point
|
||||
* @param {Number} y - The amount to add to the x value of the point
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public subtractFrom(x?: number = 0, y?: number = 0): Point {
|
||||
|
||||
return this.setTo(this.x - x, this.y - y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverts the x and y values of this point
|
||||
* @method invert
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public invert(): Point {
|
||||
|
||||
return this.setTo(this.y, this.x);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps this Point object to be between the given min and max
|
||||
* @method clamp
|
||||
* @param {number} The minimum value to clamp this Point to
|
||||
* @param {number} The maximum value to clamp this Point to
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public clamp(min: number, max: number): Point {
|
||||
|
||||
this.clampX(min, max);
|
||||
this.clampY(min, max);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps the x value of this Point object to be between the given min and max
|
||||
* @method clampX
|
||||
* @param {number} The minimum value to clamp this Point to
|
||||
* @param {number} The maximum value to clamp this Point to
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public clampX(min: number, max: number): Point {
|
||||
|
||||
this.x = Math.max(Math.min(this.x, max), min);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamps the y value of this Point object to be between the given min and max
|
||||
* @method clampY
|
||||
* @param {number} The minimum value to clamp this Point to
|
||||
* @param {number} The maximum value to clamp this Point to
|
||||
* @return {Point} This Point object.
|
||||
**/
|
||||
public clampY(min: number, max: number): Point {
|
||||
|
||||
this.x = Math.max(Math.min(this.x, max), min);
|
||||
this.y = Math.max(Math.min(this.y, max), min);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this Point.
|
||||
* @method clone
|
||||
* @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
|
||||
* @return {Point} The new Point object.
|
||||
**/
|
||||
public clone(output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this.x, this.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the point data from the source Point object into this Point object.
|
||||
* @method copyFrom
|
||||
* @param {Point} source - The point to copy from.
|
||||
* @return {Point} This Point object. Useful for chaining method calls.
|
||||
**/
|
||||
public copyFrom(source: Point): Point {
|
||||
|
||||
return this.setTo(source.x, source.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the point data from this Point object to the given target Point object.
|
||||
* @method copyTo
|
||||
* @param {Point} target - The point to copy to.
|
||||
* @return {Point} The target Point object.
|
||||
**/
|
||||
public copyTo(target: Point): Point {
|
||||
|
||||
return target.setTo(this.x, this.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance from this Point object to the given Point object.
|
||||
* @method distanceFrom
|
||||
* @param {Point} target - The destination Point object.
|
||||
* @param {Boolean} round - Round the distance to the nearest integer (default false)
|
||||
* @return {Number} The distance between this Point object and the destination Point object.
|
||||
**/
|
||||
public distanceTo(target: Point, round?: bool = false): number {
|
||||
|
||||
var dx = this.x - target.x;
|
||||
var dy = this.y - target.y;
|
||||
|
||||
if (round === true)
|
||||
{
|
||||
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance between the two Point objects.
|
||||
* @method distanceBetween
|
||||
* @param {Point} pointA - The first Point object.
|
||||
* @param {Point} pointB - The second Point object.
|
||||
* @param {Boolean} round - Round the distance to the nearest integer (default false)
|
||||
* @return {Number} The distance between the two Point objects.
|
||||
**/
|
||||
public static distanceBetween(pointA: Point, pointB: Point, round?: bool = false): number {
|
||||
|
||||
var dx: number = pointA.x - pointB.x;
|
||||
var dy: number = pointA.y - pointB.y;
|
||||
|
||||
if (round === true)
|
||||
{
|
||||
return Math.round(Math.sqrt(dx * dx + dy * dy));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the distance between this point and a target point is greater than or equal a specified distance.
|
||||
* This avoids using a costly square root operation
|
||||
* @method distanceCompare
|
||||
* @param {Point} target - The Point object to use for comparison.
|
||||
* @param {Number} distance - The distance to use for comparison.
|
||||
* @return {Boolena} True if distance is >= specified distance.
|
||||
**/
|
||||
public distanceCompare(target: Point, distance: number): bool {
|
||||
|
||||
if (this.distanceTo(target) >= distance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this Point object and the given point object are equal. They are equal if they have the same x and y values.
|
||||
* @method equals
|
||||
* @param {Point} point - The point to compare against.
|
||||
* @return {Boolean} A value of true if the object is equal to this Point object; false if it is not equal.
|
||||
**/
|
||||
public equals(toCompare: Point): bool {
|
||||
|
||||
if (this.x === toCompare.x && this.y === toCompare.y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2.
|
||||
* The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2).
|
||||
* @method interpolate
|
||||
* @param {Point} pointA - The first Point object.
|
||||
* @param {Point} pointB - The second Point object.
|
||||
* @param {Number} f - The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
|
||||
* @return {Point} The new interpolated Point object.
|
||||
**/
|
||||
public interpolate(pointA, pointB, f) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value.
|
||||
* The value of dy is added to the original value of y to create the new y value.
|
||||
* @method offset
|
||||
* @param {Number} dx - The amount by which to offset the horizontal coordinate, x.
|
||||
* @param {Number} dy - The amount by which to offset the vertical coordinate, y.
|
||||
* @return {Point} This Point object. Useful for chaining method calls.
|
||||
**/
|
||||
public offset(dx: number, dy: number): Point {
|
||||
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a pair of polar coordinates to a Cartesian point coordinate.
|
||||
* @method polar
|
||||
* @param {Number} length - The length coordinate of the polar pair.
|
||||
* @param {Number} angle - The angle, in radians, of the polar pair.
|
||||
* @return {Point} The new Cartesian Point object.
|
||||
**/
|
||||
public polar(length, angle) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the x and y values of this Point object to the given coordinates.
|
||||
* @method setTo
|
||||
* @param {Number} x - The horizontal position of this point.
|
||||
* @param {Number} y - The vertical position of this point.
|
||||
* @return {Point} This Point object. Useful for chaining method calls.
|
||||
**/
|
||||
public setTo(x: number, y: number): Point {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts the coordinates of another point from the coordinates of this point to create a new point.
|
||||
* @method subtract
|
||||
* @param {Point} point - The point to be subtracted.
|
||||
* @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
|
||||
* @return {Point} The new Point object.
|
||||
**/
|
||||
public subtract(point: Point, output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this.x - point.x, this.y - point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
**/
|
||||
public toString(): string {
|
||||
|
||||
return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,809 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="MicroPoint.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Rectangle
|
||||
*
|
||||
* A Rectangle object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Rectangle {
|
||||
|
||||
/**
|
||||
* Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a rectangle with x, y, width, and height properties set to 0 is created.
|
||||
* @class Rectangle
|
||||
* @constructor
|
||||
* @param {Number} x The x coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} y The y coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} width The width of the rectangle in pixels.
|
||||
* @param {Number} height The height of the rectangle in pixels.
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
|
||||
|
||||
this._width = width;
|
||||
|
||||
if (width > 0)
|
||||
{
|
||||
this._halfWidth = Math.round(width / 2);
|
||||
}
|
||||
|
||||
this._height = height;
|
||||
|
||||
if (height > 0)
|
||||
{
|
||||
this._halfHeight = Math.round(height / 2);
|
||||
}
|
||||
|
||||
this.length = Math.max(this._width, this._height);
|
||||
|
||||
this.topLeft = new MicroPoint(x, y, this);
|
||||
this.topCenter = new MicroPoint(x + this._halfWidth, y, this);
|
||||
this.topRight = new MicroPoint(x + this._width - 1, y, this);
|
||||
this.leftCenter = new MicroPoint(x, y + this._halfHeight, this);
|
||||
this.center = new MicroPoint(x + this._halfWidth, y + this._halfHeight, this);
|
||||
this.rightCenter = new MicroPoint(x + this._width - 1, y + this._halfHeight, this);
|
||||
this.bottomLeft = new MicroPoint(x, y + this._height - 1, this);
|
||||
this.bottomCenter = new MicroPoint(x + this._halfWidth, y + this._height - 1, this);
|
||||
this.bottomRight = new MicroPoint(x + this._width - 1, y + this._height - 1, this);
|
||||
|
||||
}
|
||||
|
||||
private _tempX: number = null;
|
||||
private _tempY: number = null;
|
||||
private _tempWidth: number = null;
|
||||
private _tempHeight: number = null;
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public get x(): number {
|
||||
|
||||
return this.topLeft.x;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
public get y(): number {
|
||||
|
||||
return this.topLeft.y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public set x(value: number) {
|
||||
|
||||
this.topLeft.x = value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
public set y(value:number) {
|
||||
|
||||
this.topLeft.y = value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the top-left corner of the rectangle (same as x/y)
|
||||
* @property topLeft
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public topLeft: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the top-center of the rectangle
|
||||
* @property topCenter
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public topCenter: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the top-right corner of the rectangle
|
||||
* @property topRight
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public topRight: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the left-center of the rectangle
|
||||
* @property leftCenter
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public leftCenter: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the center of the rectangle
|
||||
* @property center
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public center: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the right-center of the rectangle
|
||||
* @property rightCenter
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public rightCenter: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the bottom-left corner of the rectangle
|
||||
* @property bottomLeft
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public bottomLeft: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the bottom-center of the rectangle
|
||||
* @property bottomCenter
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public bottomCenter: MicroPoint;
|
||||
|
||||
/**
|
||||
* The x and y coordinate of the bottom-right corner of the rectangle
|
||||
* @property bottomRight
|
||||
* @type MicroPoint
|
||||
**/
|
||||
public bottomRight: MicroPoint;
|
||||
|
||||
/**
|
||||
* The width of the rectangle
|
||||
* @property width
|
||||
* @type Number
|
||||
**/
|
||||
private _width: number = 0;
|
||||
|
||||
/**
|
||||
* The height of the rectangle
|
||||
* @property height
|
||||
* @type Number
|
||||
**/
|
||||
private _height: number = 0;
|
||||
|
||||
/**
|
||||
* Half of the width of the rectangle
|
||||
* @property halfWidth
|
||||
* @type Number
|
||||
**/
|
||||
private _halfWidth: number = 0;
|
||||
|
||||
/**
|
||||
* Half of the height of the rectangle
|
||||
* @property halfHeight
|
||||
* @type Number
|
||||
**/
|
||||
private _halfHeight: number = 0;
|
||||
|
||||
/**
|
||||
* The size of the longest side (width or height)
|
||||
* @property length
|
||||
* @type Number
|
||||
**/
|
||||
public length: number = 0;
|
||||
|
||||
/**
|
||||
* Updates all of the MicroPoints based on the values of width and height.
|
||||
* You should not normally call this directly.
|
||||
**/
|
||||
public updateBounds() {
|
||||
|
||||
if (this._tempWidth !== null)
|
||||
{
|
||||
this._width = this._tempWidth;
|
||||
this._halfWidth = 0;
|
||||
|
||||
if (this._width > 0)
|
||||
{
|
||||
this._halfWidth = Math.round(this._width / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (this._tempHeight !== null)
|
||||
{
|
||||
this._height = this._tempHeight;
|
||||
this._halfHeight = 0;
|
||||
|
||||
if (this._height > 0)
|
||||
{
|
||||
this._halfHeight = Math.round(this._height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
this.length = Math.max(this._width, this._height);
|
||||
|
||||
if (this._tempX !== null && this._tempY !== null)
|
||||
{
|
||||
this.topLeft.setTo(this._tempX, this._tempY, false);
|
||||
}
|
||||
else if (this._tempX !== null && this._tempY == null)
|
||||
{
|
||||
this.topLeft.setTo(this._tempX, this.topLeft.y, false);
|
||||
}
|
||||
else if (this._tempX == null && this._tempY !== null)
|
||||
{
|
||||
this.topLeft.setTo(this.topLeft.x, this._tempY, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.topLeft.setTo(this.x, this.y, false);
|
||||
}
|
||||
|
||||
this.topCenter.setTo(this.x + this._halfWidth, this.y, false);
|
||||
this.topRight.setTo(this.x + this._width - 1, this.y, false);
|
||||
|
||||
this.leftCenter.setTo(this.x, this.y + this._halfHeight, false);
|
||||
this.center.setTo(this.x + this._halfWidth, this.y + this._halfHeight, false);
|
||||
this.rightCenter.setTo(this.x + this._width - 1, this.y + this._halfHeight, false);
|
||||
|
||||
this.bottomLeft.setTo(this.x, this.y + this._height - 1, false);
|
||||
this.bottomCenter.setTo(this.x + this._halfWidth, this.y + this._height - 1, false);
|
||||
this.bottomRight.setTo(this.x + this._width - 1, this.y + this._height - 1, false);
|
||||
|
||||
this._tempX = null;
|
||||
this._tempY = null;
|
||||
this._tempWidth = null;
|
||||
this._tempHeight = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The width of the rectangle
|
||||
* @property width
|
||||
* @type Number
|
||||
**/
|
||||
public set width(value: number) {
|
||||
|
||||
this._width = value;
|
||||
this._halfWidth = Math.round(value / 2);
|
||||
this.updateBounds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The height of the rectangle
|
||||
* @property height
|
||||
* @type Number
|
||||
**/
|
||||
public set height(value: number) {
|
||||
|
||||
this._height = value;
|
||||
this._halfHeight = Math.round(value / 2);
|
||||
this.updateBounds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The width of the rectangle
|
||||
* @property width
|
||||
* @type Number
|
||||
**/
|
||||
public get width(): number {
|
||||
|
||||
return this._width;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The height of the rectangle
|
||||
* @property height
|
||||
* @type Number
|
||||
**/
|
||||
public get height(): number {
|
||||
|
||||
return this._height;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Half of the width of the rectangle
|
||||
* @property halfWidth
|
||||
* @type Number
|
||||
**/
|
||||
public get halfWidth(): number {
|
||||
|
||||
return this._halfWidth;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Half of the height of the rectangle
|
||||
* @property halfHeight
|
||||
* @type Number
|
||||
**/
|
||||
public get halfHeight(): number {
|
||||
|
||||
return this._halfHeight;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the y and height properties.
|
||||
* Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
|
||||
* @method bottom
|
||||
* @return {Number}
|
||||
**/
|
||||
public get bottom(): number {
|
||||
|
||||
return this.bottomCenter.y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the y and height properties.
|
||||
* Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
|
||||
* @method bottom
|
||||
* @param {Number} value
|
||||
**/
|
||||
public set bottom(value: number) {
|
||||
|
||||
if (value < this.y)
|
||||
{
|
||||
this._tempHeight = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._tempHeight = this.y + value;
|
||||
}
|
||||
|
||||
this.updateBounds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle.
|
||||
* Changing the left property of a Rectangle object has no effect on the y and height properties.
|
||||
* However it does affect the width property, whereas changing the x value does not affect the width property.
|
||||
* @method left
|
||||
* @ return {number}
|
||||
**/
|
||||
public get left(): number {
|
||||
|
||||
return this.x;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The x coordinate of the top-left corner of the rectangle.
|
||||
* Changing the left property of a Rectangle object has no effect on the y and height properties.
|
||||
* However it does affect the width property, whereas changing the x value does not affect the width property.
|
||||
* @method left
|
||||
* @param {Number} value
|
||||
**/
|
||||
public set left(value: number) {
|
||||
|
||||
var diff = this.x - value;
|
||||
|
||||
if (this._width + diff < 0)
|
||||
{
|
||||
this._tempWidth = 0;
|
||||
this._tempX = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._tempWidth = this._width + diff;
|
||||
this._tempX = value;
|
||||
}
|
||||
|
||||
this.updateBounds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the x and width properties.
|
||||
* Changing the right property of a Rectangle object has no effect on the x, y and height properties.
|
||||
* However it does affect the width property.
|
||||
* @method right
|
||||
* @return {Number}
|
||||
**/
|
||||
public get right(): number {
|
||||
|
||||
return this.rightCenter.x;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The sum of the x and width properties.
|
||||
* Changing the right property of a Rectangle object has no effect on the x, y and height properties.
|
||||
* However it does affect the width property.
|
||||
* @method right
|
||||
* @param {Number} value
|
||||
**/
|
||||
public set right(value: number) {
|
||||
|
||||
if (value < this.topLeft.x)
|
||||
{
|
||||
this._tempWidth = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._tempWidth = (value - this.topLeft.x);
|
||||
}
|
||||
|
||||
this.updateBounds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
|
||||
* @method size
|
||||
* @param {Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
|
||||
* @return {Point} The size of the Rectangle object
|
||||
**/
|
||||
public size(output?: Point = new Point): Point {
|
||||
|
||||
return output.setTo(this._width, this._height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The volume of the Rectangle object in pixels, derived from width * height
|
||||
* @method volume
|
||||
* @return {Number}
|
||||
**/
|
||||
public get volume(): number {
|
||||
|
||||
return this._width * this._height;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The perimeter size of the Rectangle object in pixels. This is the sum of all 4 sides.
|
||||
* @method perimeter
|
||||
* @return {Number}
|
||||
**/
|
||||
public get perimeter(): number {
|
||||
|
||||
return (this._width * 2) + (this._height * 2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle.
|
||||
* Changing the top property of a Rectangle object has no effect on the x and width properties.
|
||||
* However it does affect the height property, whereas changing the y value does not affect the height property.
|
||||
* @method top
|
||||
* @return {Number}
|
||||
**/
|
||||
public get top(): number {
|
||||
|
||||
return this.topCenter.y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The y coordinate of the top-left corner of the rectangle.
|
||||
* Changing the top property of a Rectangle object has no effect on the x and width properties.
|
||||
* However it does affect the height property, whereas changing the y value does not affect the height property.
|
||||
* @method top
|
||||
* @param {Number} value
|
||||
**/
|
||||
public set top(value: number) {
|
||||
|
||||
var diff = this.topCenter.y - value;
|
||||
|
||||
if (this._height + diff < 0)
|
||||
{
|
||||
this._tempHeight = 0;
|
||||
this._tempY = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._tempHeight = this._height + diff;
|
||||
this._tempY = value;
|
||||
}
|
||||
|
||||
this.updateBounds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
|
||||
* @method clone
|
||||
* @param {Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
|
||||
* @return {Rectangle}
|
||||
**/
|
||||
public clone(output?: Rectangle = new Rectangle): Rectangle {
|
||||
|
||||
return output.setTo(this.x, this.y, this.width, this.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
|
||||
* @method contains
|
||||
* @param {Number} x The x coordinate of the point to test.
|
||||
* @param {Number} y The y coordinate of the point to test.
|
||||
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
**/
|
||||
public contains(x: number, y: number): bool {
|
||||
|
||||
if (x >= this.topLeft.x && x <= this.topRight.x && y >= this.topLeft.y && y <= this.bottomRight.y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.
|
||||
* This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
|
||||
* @method containsPoint
|
||||
* @param {Point} point The point object being checked. Can be Point or any object with .x and .y values.
|
||||
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
**/
|
||||
public containsPoint(point: any): bool {
|
||||
|
||||
return this.contains(point.x, point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object.
|
||||
* A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
|
||||
* @method containsRect
|
||||
* @param {Rectangle} rect The rectangle object being checked.
|
||||
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
|
||||
**/
|
||||
public containsRect(rect: Rectangle): bool {
|
||||
|
||||
// If the given rect has a larger volume than this one then it can never contain it
|
||||
if (rect.volume > this.volume)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rect.x >= this.topLeft.x && rect.y >= this.topLeft.y && rect.rightCenter.x <= this.rightCenter.x && rect.bottomCenter.y <= this.bottomCenter.y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies all of rectangle data from the source Rectangle object into the calling Rectangle object.
|
||||
* @method copyFrom
|
||||
* @param {Rectangle} rect The source rectangle object to copy from
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
public copyFrom(source: Rectangle): Rectangle {
|
||||
|
||||
return this.setTo(source.x, source.y, source.width, source.height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copies all the rectangle data from this Rectangle object into the destination Rectangle object.
|
||||
* @method copyTo
|
||||
* @param {Rectangle} rect The destination rectangle object to copy in to
|
||||
* @return {Rectangle} The destination rectangle object
|
||||
**/
|
||||
public copyTo(target: Rectangle): Rectangle {
|
||||
|
||||
return target.copyFrom(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the object specified in the toCompare parameter is equal to this Rectangle object.
|
||||
* This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object.
|
||||
* @method equals
|
||||
* @param {Rectangle} toCompare The rectangle to compare to this Rectangle object.
|
||||
* @return {Boolean} A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false.
|
||||
**/
|
||||
public equals(toCompare: Rectangle): bool {
|
||||
|
||||
if (this.topLeft.equals(toCompare.topLeft) && this.bottomRight.equals(toCompare.bottomRight))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the size of the Rectangle object by the specified amounts.
|
||||
* The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value,
|
||||
* and to the top and the bottom by the dy value.
|
||||
* @method inflate
|
||||
* @param {Number} dx The amount to be added to the left side of this Rectangle.
|
||||
* @param {Number} dy The amount to be added to the bottom side of this Rectangle.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
public inflate(dx: number, dy: number): Rectangle {
|
||||
|
||||
this._tempX = this.topLeft.x - dx;
|
||||
this._tempWidth = this._width + (2 * dx);
|
||||
this._tempY = this.topLeft.y - dy;
|
||||
this._tempHeight = this._height + (2 * dy);
|
||||
|
||||
this.updateBounds();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the size of the Rectangle object.
|
||||
* This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.
|
||||
* @method inflatePoint
|
||||
* @param {Point} point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
public inflatePoint(point: Point): Rectangle {
|
||||
|
||||
return this.inflate(point.x, point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object,
|
||||
* returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method
|
||||
* returns an empty Rectangle object with its properties set to 0.
|
||||
* @method intersection
|
||||
* @param {Rectangle} toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object.
|
||||
* @param {Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
|
||||
* @return {Rectangle} A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0.
|
||||
**/
|
||||
public intersection(toIntersect: Rectangle, output?: Rectangle = new Rectangle): Rectangle {
|
||||
|
||||
if (this.intersects(toIntersect) === true)
|
||||
{
|
||||
output.x = Math.max(toIntersect.topLeft.x, this.topLeft.x);
|
||||
output.y = Math.max(toIntersect.topLeft.y, this.topLeft.y);
|
||||
output.width = Math.min(toIntersect.rightCenter.x, this.rightCenter.x) - output.x;
|
||||
output.height = Math.min(toIntersect.bottomCenter.y, this.bottomCenter.y) - output.y;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the object specified intersects (overlaps) with this Rectangle object.
|
||||
* This method checks the x, y, width, and height properties of the specified Rectangle object to see if it intersects with this Rectangle object.
|
||||
* @method intersects
|
||||
* @param {Rectangle} r2 The Rectangle object to compare against to see if it intersects with this Rectangle object.
|
||||
* @param {Number} t A tolerance value to allow for an intersection test with padding, default to 0
|
||||
* @return {Boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
|
||||
**/
|
||||
public intersects(r2: Rectangle, t?: number = 0): bool {
|
||||
|
||||
return !(r2.left > this.right + t || r2.right < this.left - t || r2.top > this.bottom + t || r2.bottom < this.top - t);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not this Rectangle object is empty.
|
||||
* @method isEmpty
|
||||
* @return {Boolean} A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false.
|
||||
**/
|
||||
public get isEmpty(): bool {
|
||||
|
||||
if (this.width < 1 || this.height < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
|
||||
* @method offset
|
||||
* @param {Number} dx Moves the x value of the Rectangle object by this amount.
|
||||
* @param {Number} dy Moves the y value of the Rectangle object by this amount.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
public offset(dx: number, dy: number): Rectangle {
|
||||
|
||||
if (!isNaN(dx) && !isNaN(dy))
|
||||
{
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.
|
||||
* @method offsetPoint
|
||||
* @param {Point} point A Point object to use to offset this Rectangle object.
|
||||
* @return {Rectangle} This Rectangle object.
|
||||
**/
|
||||
public offsetPoint(point: Point): Rectangle {
|
||||
|
||||
return this.offset(point.x, point.y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0.
|
||||
* @method setEmpty
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
public setEmpty() {
|
||||
|
||||
return this.setTo(0, 0, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the members of Rectangle to the specified values.
|
||||
* @method setTo
|
||||
* @param {Number} x The x coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} y The y coordinate of the top-left corner of the rectangle.
|
||||
* @param {Number} width The width of the rectangle in pixels.
|
||||
* @param {Number} height The height of the rectangle in pixels.
|
||||
* @return {Rectangle} This rectangle object
|
||||
**/
|
||||
public setTo(x: number, y: number, width: number, height: number): Rectangle {
|
||||
|
||||
this._tempX = x;
|
||||
this._tempY = y;
|
||||
this._tempWidth = width;
|
||||
this._tempHeight = height;
|
||||
|
||||
this.updateBounds();
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles.
|
||||
* @method union
|
||||
* @param {Rectangle} toUnion A Rectangle object to add to this Rectangle object.
|
||||
* @param {Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
|
||||
* @return {Rectangle} A Rectangle object that is the union of the two rectangles.
|
||||
**/
|
||||
public union(toUnion: Rectangle, output?: Rectangle = new Rectangle): Rectangle {
|
||||
|
||||
return output.setTo(
|
||||
Math.min(toUnion.x, this.x),
|
||||
Math.min(toUnion.y, this.y),
|
||||
Math.max(toUnion.right, this.right),
|
||||
Math.max(toUnion.bottom, this.bottom)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
**/
|
||||
public toString(): string {
|
||||
|
||||
return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.isEmpty + ")}]";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Phaser
|
||||
*
|
||||
* v0.9.2 - April 20th 2013
|
||||
*
|
||||
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
|
||||
*
|
||||
* Richard Davey (@photonstorm)
|
||||
*
|
||||
* Many thanks to Adam Saltsman (@ADAMATOMIC) for the original Flixel AS3 code on which Phaser is based.
|
||||
*
|
||||
* "If you want your children to be intelligent, read them fairy tales."
|
||||
* "If you want them to be more intelligent, read them more fairy tales."
|
||||
* -- Albert Einstein
|
||||
*/
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
Phaser.VERSION = 'Phaser version 0.9.2';
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -1,686 +0,0 @@
|
||||
/// <reference path="../gameobjects/Sprite.ts" />
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Camera
|
||||
*
|
||||
* A Camera is your view into the game world. It has a position, size, scale and rotation and renders only those objects
|
||||
* within its field of view. The game automatically creates a single Stage sized camera on boot, but it can be changed and
|
||||
* additional cameras created via the CameraManager.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Camera {
|
||||
|
||||
/**
|
||||
* Instantiates a new camera at the specified location, with the specified size and zoom level.
|
||||
*
|
||||
* @param X X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
|
||||
* @param Y Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
|
||||
* @param Width The width of the camera display in pixels.
|
||||
* @param Height The height of the camera display in pixels.
|
||||
* @param Zoom The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.
|
||||
*/
|
||||
constructor(game: Game, id: number, x: number, y: number, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.ID = id;
|
||||
this._stageX = x;
|
||||
this._stageY = y;
|
||||
|
||||
// The view into the world canvas we wish to render
|
||||
this.worldView = new Rectangle(0, 0, width, height);
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _clip: bool = false;
|
||||
private _stageX: number;
|
||||
private _stageY: number;
|
||||
private _rotation: number = 0;
|
||||
private _target: Sprite = null;
|
||||
private _sx: number = 0;
|
||||
private _sy: number = 0;
|
||||
|
||||
private _fxFlashColor: string;
|
||||
private _fxFlashComplete = null;
|
||||
private _fxFlashDuration: number = 0;
|
||||
private _fxFlashAlpha: number = 0;
|
||||
|
||||
private _fxFadeColor: string;
|
||||
private _fxFadeComplete = null;
|
||||
private _fxFadeDuration: number = 0;
|
||||
private _fxFadeAlpha: number = 0;
|
||||
|
||||
private _fxShakeIntensity: number = 0;
|
||||
private _fxShakeDuration: number = 0;
|
||||
private _fxShakeComplete = null;
|
||||
private _fxShakeOffset: Point = new Point(0, 0);
|
||||
private _fxShakeDirection: number = 0;
|
||||
private _fxShakePrevX: number = 0;
|
||||
private _fxShakePrevY: number = 0;
|
||||
|
||||
public static STYLE_LOCKON: number = 0;
|
||||
public static STYLE_PLATFORMER: number = 1;
|
||||
public static STYLE_TOPDOWN: number = 2;
|
||||
public static STYLE_TOPDOWN_TIGHT: number = 3;
|
||||
|
||||
public static SHAKE_BOTH_AXES: number = 0;
|
||||
public static SHAKE_HORIZONTAL_ONLY: number = 1;
|
||||
public static SHAKE_VERTICAL_ONLY: number = 2;
|
||||
|
||||
public ID: number;
|
||||
public worldView: Rectangle;
|
||||
public totalSpritesRendered: number;
|
||||
public scale: Point = new Point(1, 1);
|
||||
public scroll: Point = new Point(0, 0);
|
||||
public bounds: Rectangle = null;
|
||||
public deadzone: Rectangle = null;
|
||||
|
||||
// Camera Border
|
||||
public showBorder: bool = false;
|
||||
public borderColor: string = 'rgb(255,255,255)';
|
||||
|
||||
// Camera Background Color
|
||||
public opaque: bool = true;
|
||||
private _bgColor: string = 'rgb(0,0,0)';
|
||||
private _bgTexture;
|
||||
private _bgTextureRepeat: string = 'repeat';
|
||||
|
||||
// Camera Shadow
|
||||
public showShadow: bool = false;
|
||||
public shadowColor: string = 'rgb(0,0,0)';
|
||||
public shadowBlur: number = 10;
|
||||
public shadowOffset: Point = new Point(4, 4);
|
||||
|
||||
public visible: bool = true;
|
||||
public alpha: number = 1;
|
||||
|
||||
// The x/y position of the current input event in world coordinates
|
||||
public inputX: number = 0;
|
||||
public inputY: number = 0;
|
||||
|
||||
/**
|
||||
* The camera is filled with this color and returns to normal at the given duration.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
public flash(color: number = 0xffffff, duration: number = 1, onComplete = null, force: bool = false) {
|
||||
|
||||
if (force === false && this._fxFlashAlpha > 0)
|
||||
{
|
||||
// You can't flash again unless you force it
|
||||
return;
|
||||
}
|
||||
|
||||
if (duration <= 0)
|
||||
{
|
||||
duration = 1;
|
||||
}
|
||||
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
|
||||
this._fxFlashColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFlashDuration = duration;
|
||||
this._fxFlashAlpha = 1;
|
||||
this._fxFlashComplete = onComplete;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The camera is gradually filled with this color.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
public fade(color: number = 0x000000, duration: number = 1, onComplete = null, force: bool = false) {
|
||||
|
||||
if (force === false && this._fxFadeAlpha > 0)
|
||||
{
|
||||
// You can't fade again unless you force it
|
||||
return;
|
||||
}
|
||||
|
||||
if (duration <= 0)
|
||||
{
|
||||
duration = 1;
|
||||
}
|
||||
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
|
||||
this._fxFadeColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFadeDuration = duration;
|
||||
this._fxFadeAlpha = 0.01;
|
||||
this._fxFadeComplete = onComplete;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple screen-shake effect.
|
||||
*
|
||||
* @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
|
||||
* @param Duration The length in seconds that the shaking effect should last.
|
||||
* @param OnComplete A function you want to run when the shake effect finishes.
|
||||
* @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
|
||||
* @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
|
||||
*/
|
||||
public shake(intensity: number = 0.05, duration: number = 0.5, onComplete = null, force: bool = true, direction: number = Camera.SHAKE_BOTH_AXES) {
|
||||
|
||||
if (!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If a shake is not already running we need to store the offsets here
|
||||
if (this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0)
|
||||
{
|
||||
this._fxShakePrevX = this._stageX;
|
||||
this._fxShakePrevY = this._stageY;
|
||||
}
|
||||
|
||||
this._fxShakeIntensity = intensity;
|
||||
this._fxShakeDuration = duration;
|
||||
this._fxShakeComplete = onComplete;
|
||||
this._fxShakeDirection = direction;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Just turns off all the camera effects instantly.
|
||||
*/
|
||||
public stopFX() {
|
||||
|
||||
this._fxFlashAlpha = 0;
|
||||
this._fxFadeAlpha = 0;
|
||||
|
||||
if (this._fxShakeDuration !== 0)
|
||||
{
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
this._stageX = this._fxShakePrevX;
|
||||
this._stageY = this._fxShakePrevY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public follow(target: Sprite, style?: number = Camera.STYLE_LOCKON) {
|
||||
|
||||
this._target = target;
|
||||
var helper: number;
|
||||
|
||||
switch (style)
|
||||
{
|
||||
case Camera.STYLE_PLATFORMER:
|
||||
var w: number = this.width / 8;
|
||||
var h: number = this.height / 3;
|
||||
this.deadzone = new Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h);
|
||||
break;
|
||||
case Camera.STYLE_TOPDOWN:
|
||||
helper = Math.max(this.width, this.height) / 4;
|
||||
this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
|
||||
break;
|
||||
case Camera.STYLE_TOPDOWN_TIGHT:
|
||||
helper = Math.max(this.width, this.height) / 8;
|
||||
this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
|
||||
break;
|
||||
case Camera.STYLE_LOCKON:
|
||||
default:
|
||||
this.deadzone = null;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public focusOnXY(x: number, y: number) {
|
||||
|
||||
x += (x > 0) ? 0.0000001 : -0.0000001;
|
||||
y += (y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
this.scroll.x = Math.round(x - this.worldView.halfWidth);
|
||||
this.scroll.y = Math.round(y - this.worldView.halfHeight);
|
||||
|
||||
}
|
||||
|
||||
public focusOn(point: Point) {
|
||||
|
||||
point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
|
||||
point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
|
||||
|
||||
this.scroll.x = Math.round(point.x - this.worldView.halfWidth);
|
||||
this.scroll.y = Math.round(point.y - this.worldView.halfHeight);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the boundaries of the world or where the camera is allowed to move.
|
||||
*
|
||||
* @param X The smallest X value of your world (usually 0).
|
||||
* @param Y The smallest Y value of your world (usually 0).
|
||||
* @param Width The largest X value of your world (usually the world width).
|
||||
* @param Height The largest Y value of your world (usually the world height).
|
||||
* @param UpdateWorld Whether the global quad-tree's dimensions should be updated to match (default: false).
|
||||
*/
|
||||
public setBounds(X: number = 0, Y: number = 0, Width: number = 0, Height: number = 0, UpdateWorld: bool = false) {
|
||||
|
||||
if (this.bounds == null)
|
||||
{
|
||||
this.bounds = new Rectangle();
|
||||
}
|
||||
|
||||
this.bounds.setTo(X, Y, Width, Height);
|
||||
|
||||
//if(UpdateWorld)
|
||||
// G.worldBounds.copyFrom(bounds);
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
if (this._target !== null)
|
||||
{
|
||||
if (this.deadzone == null)
|
||||
{
|
||||
this.focusOnXY(this._target.x + this._target.origin.x, this._target.y + this._target.origin.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
var edge: number;
|
||||
var targetX: number = this._target.x + ((this._target.x > 0) ? 0.0000001 : -0.0000001);
|
||||
var targetY: number = this._target.y + ((this._target.y > 0) ? 0.0000001 : -0.0000001);
|
||||
|
||||
edge = targetX - this.deadzone.x;
|
||||
|
||||
if (this.scroll.x > edge)
|
||||
{
|
||||
this.scroll.x = edge;
|
||||
}
|
||||
|
||||
edge = targetX + this._target.width - this.deadzone.x - this.deadzone.width;
|
||||
|
||||
if (this.scroll.x < edge)
|
||||
{
|
||||
this.scroll.x = edge;
|
||||
}
|
||||
|
||||
edge = targetY - this.deadzone.y;
|
||||
|
||||
if (this.scroll.y > edge)
|
||||
{
|
||||
this.scroll.y = edge;
|
||||
}
|
||||
|
||||
edge = targetY + this._target.height - this.deadzone.y - this.deadzone.height;
|
||||
|
||||
if (this.scroll.y < edge)
|
||||
{
|
||||
this.scroll.y = edge;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Make sure we didn't go outside the camera's bounds
|
||||
if (this.bounds !== null)
|
||||
{
|
||||
if (this.scroll.x < this.bounds.left)
|
||||
{
|
||||
this.scroll.x = this.bounds.left;
|
||||
}
|
||||
|
||||
if (this.scroll.x > this.bounds.right - this.width)
|
||||
{
|
||||
this.scroll.x = this.bounds.right - this.width;
|
||||
}
|
||||
|
||||
if (this.scroll.y < this.bounds.top)
|
||||
{
|
||||
this.scroll.y = this.bounds.top;
|
||||
}
|
||||
|
||||
if (this.scroll.y > this.bounds.bottom - this.height)
|
||||
{
|
||||
this.scroll.y = this.bounds.bottom - this.height;
|
||||
}
|
||||
}
|
||||
|
||||
this.worldView.x = this.scroll.x;
|
||||
this.worldView.y = this.scroll.y;
|
||||
|
||||
// Input values
|
||||
this.inputX = this.worldView.x + this._game.input.x;
|
||||
this.inputY = this.worldView.y + this._game.input.y;
|
||||
|
||||
// Update the Flash effect
|
||||
if (this._fxFlashAlpha > 0)
|
||||
{
|
||||
this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration;
|
||||
this._fxFlashAlpha = this._game.math.roundTo(this._fxFlashAlpha, -2);
|
||||
|
||||
if (this._fxFlashAlpha <= 0)
|
||||
{
|
||||
this._fxFlashAlpha = 0;
|
||||
|
||||
if (this._fxFlashComplete !== null)
|
||||
{
|
||||
this._fxFlashComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the Fade effect
|
||||
if (this._fxFadeAlpha > 0)
|
||||
{
|
||||
this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration;
|
||||
this._fxFadeAlpha = this._game.math.roundTo(this._fxFadeAlpha, -2);
|
||||
|
||||
if (this._fxFadeAlpha >= 1)
|
||||
{
|
||||
this._fxFadeAlpha = 1;
|
||||
|
||||
if (this._fxFadeComplete !== null)
|
||||
{
|
||||
this._fxFadeComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the "shake" special effect
|
||||
if (this._fxShakeDuration > 0)
|
||||
{
|
||||
this._fxShakeDuration -= this._game.time.elapsed;
|
||||
this._fxShakeDuration = this._game.math.roundTo(this._fxShakeDuration, -2);
|
||||
|
||||
if (this._fxShakeDuration <= 0)
|
||||
{
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
this._stageX = this._fxShakePrevX;
|
||||
this._stageY = this._fxShakePrevY;
|
||||
|
||||
if (this._fxShakeComplete != null)
|
||||
{
|
||||
this._fxShakeComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_HORIZONTAL_ONLY))
|
||||
{
|
||||
//this._fxShakeOffset.x = ((this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width) * this._zoom;
|
||||
this._fxShakeOffset.x = (this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width);
|
||||
}
|
||||
|
||||
if ((this._fxShakeDirection == Camera.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Camera.SHAKE_VERTICAL_ONLY))
|
||||
{
|
||||
//this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height) * this._zoom;
|
||||
this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
||||
if (this.visible === false && this.alpha < 0.1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))
|
||||
{
|
||||
//this._stageX = this._fxShakePrevX + (this.worldView.halfWidth * this._zoom) + this._fxShakeOffset.x;
|
||||
//this._stageY = this._fxShakePrevY + (this.worldView.halfHeight * this._zoom) + this._fxShakeOffset.y;
|
||||
this._stageX = this._fxShakePrevX + (this.worldView.halfWidth) + this._fxShakeOffset.x;
|
||||
this._stageY = this._fxShakePrevY + (this.worldView.halfHeight) + this._fxShakeOffset.y;
|
||||
//console.log('shake', this._fxShakeDuration, this._fxShakeIntensity, this._fxShakeOffset.x, this._fxShakeOffset.y);
|
||||
}
|
||||
|
||||
//if (this._rotation !== 0 || this._clip || this.scale.x !== 1 || this.scale.y !== 1)
|
||||
//{
|
||||
//this._game.stage.context.save();
|
||||
//}
|
||||
|
||||
// It may be safe/quicker to just save the context every frame regardless
|
||||
this._game.stage.context.save();
|
||||
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = this._stageX;
|
||||
this._sy = this._stageY;
|
||||
|
||||
// Shadow
|
||||
if (this.showShadow)
|
||||
{
|
||||
this._game.stage.context.shadowColor = this.shadowColor;
|
||||
this._game.stage.context.shadowBlur = this.shadowBlur;
|
||||
this._game.stage.context.shadowOffsetX = this.shadowOffset.x;
|
||||
this._game.stage.context.shadowOffsetY = this.shadowOffset.y;
|
||||
}
|
||||
|
||||
// Scale on
|
||||
if (this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
this._game.stage.context.scale(this.scale.x, this.scale.y);
|
||||
this._sx = this._sx / this.scale.x;
|
||||
this._sy = this._sy / this.scale.y;
|
||||
}
|
||||
|
||||
// Rotation - translate to the mid-point of the camera
|
||||
if (this._rotation !== 0)
|
||||
{
|
||||
this._game.stage.context.translate(this._sx + this.worldView.halfWidth, this._sy + this.worldView.halfHeight);
|
||||
this._game.stage.context.rotate(this._rotation * (Math.PI / 180));
|
||||
|
||||
// now shift back to where that should actually render
|
||||
this._game.stage.context.translate(-(this._sx + this.worldView.halfWidth), -(this._sy + this.worldView.halfHeight));
|
||||
}
|
||||
|
||||
|
||||
// Background
|
||||
if (this.opaque == true)
|
||||
{
|
||||
if (this._bgTexture)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._bgTexture;
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._bgColor;
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
}
|
||||
|
||||
// Shadow off
|
||||
if (this.showShadow)
|
||||
{
|
||||
this._game.stage.context.shadowBlur = 0;
|
||||
this._game.stage.context.shadowOffsetX = 0;
|
||||
this._game.stage.context.shadowOffsetY = 0;
|
||||
}
|
||||
|
||||
// Clip the camera so we don't get sprites appearing outside the edges
|
||||
if (this._clip)
|
||||
{
|
||||
this._game.stage.context.beginPath();
|
||||
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.closePath();
|
||||
this._game.stage.context.clip();
|
||||
}
|
||||
|
||||
this._game.world.group.render(this, this._sx, this._sy);
|
||||
|
||||
if (this.showBorder)
|
||||
{
|
||||
this._game.stage.context.strokeStyle = this.borderColor;
|
||||
this._game.stage.context.lineWidth = 1;
|
||||
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
this._game.stage.context.stroke();
|
||||
}
|
||||
|
||||
// "Flash" FX
|
||||
if (this._fxFlashAlpha > 0)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
|
||||
// "Fade" FX
|
||||
if (this._fxFadeAlpha > 0)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
|
||||
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
|
||||
// Scale off
|
||||
if (this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
this._game.stage.context.scale(1, 1);
|
||||
}
|
||||
|
||||
if (this._rotation !== 0 || this._clip)
|
||||
{
|
||||
this._game.stage.context.translate(0, 0);
|
||||
//this._game.stage.context.restore();
|
||||
}
|
||||
|
||||
// maybe just do this every frame regardless?
|
||||
this._game.stage.context.restore();
|
||||
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public set backgroundColor(color: string) {
|
||||
|
||||
this._bgColor = color;
|
||||
|
||||
}
|
||||
|
||||
public get backgroundColor(): string {
|
||||
return this._bgColor;
|
||||
}
|
||||
|
||||
public setTexture(key: string, repeat?: string = 'repeat') {
|
||||
|
||||
this._bgTexture = this._game.stage.context.createPattern(this._game.cache.getImage(key), repeat);
|
||||
this._bgTextureRepeat = repeat;
|
||||
|
||||
}
|
||||
|
||||
public setPosition(x: number, y: number) {
|
||||
|
||||
this._stageX = x;
|
||||
this._stageY = y;
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
public setSize(width: number, height: number) {
|
||||
|
||||
this.worldView.width = width;
|
||||
this.worldView.height = height;
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Camera ID: ' + this.ID + ' (' + this.worldView.width + ' x ' + this.worldView.height + ')', x, y);
|
||||
this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14);
|
||||
this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28);
|
||||
|
||||
if (this.bounds)
|
||||
{
|
||||
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this._stageX;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this._stageX = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this._stageY;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this._stageY = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.worldView.width;
|
||||
}
|
||||
|
||||
public set width(value: number) {
|
||||
this.worldView.width = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.worldView.height;
|
||||
}
|
||||
|
||||
public set height(value: number) {
|
||||
this.worldView.height = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get rotation(): number {
|
||||
return this._rotation;
|
||||
}
|
||||
|
||||
public set rotation(value: number) {
|
||||
this._rotation = this._game.math.wrap(value, 360, 0);
|
||||
}
|
||||
|
||||
private checkClip() {
|
||||
|
||||
if (this._stageX !== 0 || this._stageY !== 0 || this.worldView.width < this._game.stage.width || this.worldView.height < this._game.stage.height)
|
||||
{
|
||||
this._clip = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._clip = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,772 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="LinkedList.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - QuadTree
|
||||
*
|
||||
* A fairly generic quad tree structure for rapid overlap checks. QuadTree is also configured for single or dual list operation.
|
||||
* You can add items either to its A list or its B list. When you do an overlap check, you can compare the A list to itself,
|
||||
* or the A list against the B list. Handy for different things!
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class QuadTree extends Rectangle {
|
||||
|
||||
/**
|
||||
* Instantiate a new Quad Tree node.
|
||||
*
|
||||
* @param X The X-coordinate of the point in space.
|
||||
* @param Y The Y-coordinate of the point in space.
|
||||
* @param Width Desired width of this node.
|
||||
* @param Height Desired height of this node.
|
||||
* @param Parent The parent branch or node. Pass null to create a root.
|
||||
*/
|
||||
constructor(X: number, Y: number, Width: number, Height: number, Parent: QuadTree = null) {
|
||||
|
||||
super(X, Y, Width, Height);
|
||||
|
||||
//console.log('-------- QuadTree',X,Y,Width,Height);
|
||||
|
||||
this._headA = this._tailA = new LinkedList();
|
||||
this._headB = this._tailB = new LinkedList();
|
||||
|
||||
//Copy the parent's children (if there are any)
|
||||
if (Parent != null)
|
||||
{
|
||||
//console.log('Parent not null');
|
||||
var iterator: LinkedList;
|
||||
var ot: LinkedList;
|
||||
|
||||
if (Parent._headA.object != null)
|
||||
{
|
||||
iterator = Parent._headA;
|
||||
//console.log('iterator set to parent headA');
|
||||
|
||||
while (iterator != null)
|
||||
{
|
||||
if (this._tailA.object != null)
|
||||
{
|
||||
ot = this._tailA;
|
||||
this._tailA = new LinkedList();
|
||||
ot.next = this._tailA;
|
||||
}
|
||||
|
||||
this._tailA.object = iterator.object;
|
||||
iterator = iterator.next;
|
||||
}
|
||||
}
|
||||
|
||||
if (Parent._headB.object != null)
|
||||
{
|
||||
iterator = Parent._headB;
|
||||
//console.log('iterator set to parent headB');
|
||||
|
||||
while (iterator != null)
|
||||
{
|
||||
if (this._tailB.object != null)
|
||||
{
|
||||
ot = this._tailB;
|
||||
this._tailB = new LinkedList();
|
||||
ot.next = this._tailB;
|
||||
}
|
||||
|
||||
this._tailB.object = iterator.object;
|
||||
iterator = iterator.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._min = (this.width + this.height) / (2 * QuadTree.divisions);
|
||||
}
|
||||
|
||||
this._canSubdivide = (this.width > QuadTree._min) || (this.height > QuadTree._min);
|
||||
|
||||
//console.log('canSubdivided', this._canSubdivide);
|
||||
|
||||
//Set up comparison/sort helpers
|
||||
this._northWestTree = null;
|
||||
this._northEastTree = null;
|
||||
this._southEastTree = null;
|
||||
this._southWestTree = null;
|
||||
this._leftEdge = this.x;
|
||||
this._rightEdge = this.x + this.width;
|
||||
this._halfWidth = this.width / 2;
|
||||
this._midpointX = this._leftEdge + this._halfWidth;
|
||||
this._topEdge = this.y;
|
||||
this._bottomEdge = this.y + this.height;
|
||||
this._halfHeight = this.height / 2;
|
||||
this._midpointY = this._topEdge + this._halfHeight;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag for specifying that you want to add an object to the A list.
|
||||
*/
|
||||
public static A_LIST: number = 0;
|
||||
|
||||
/**
|
||||
* Flag for specifying that you want to add an object to the B list.
|
||||
*/
|
||||
public static B_LIST: number = 1;
|
||||
|
||||
/**
|
||||
* Controls the granularity of the quad tree. Default is 6 (decent performance on large and small worlds).
|
||||
*/
|
||||
public static divisions: number;
|
||||
|
||||
/**
|
||||
* Whether this branch of the tree can be subdivided or not.
|
||||
*/
|
||||
private _canSubdivide: bool;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _headA: LinkedList;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _tailA: LinkedList;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _headB: LinkedList;
|
||||
|
||||
/**
|
||||
* Refers to the internal A and B linked lists,
|
||||
* which are used to store objects in the leaves.
|
||||
*/
|
||||
private _tailB: LinkedList;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private static _min: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _northWestTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _northEastTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _southEastTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _southWestTree: QuadTree;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _leftEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _rightEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _topEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _bottomEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _halfWidth: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _halfHeight: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _midpointX: number;
|
||||
|
||||
/**
|
||||
* Internal, governs and assists with the formation of the tree.
|
||||
*/
|
||||
private _midpointY: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _object;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectLeftEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectTopEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectRightEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used to reduce recursive method parameters during object placement and tree formation.
|
||||
*/
|
||||
private static _objectBottomEdge: number;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _list: number;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _useBothLists: bool;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _processingCallback;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _notifyCallback;
|
||||
|
||||
/**
|
||||
* Internal, used during tree processing and overlap checks.
|
||||
*/
|
||||
private static _iterator: LinkedList;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullX: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullY: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullWidth: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _objectHullHeight: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullX: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullY: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullWidth: number;
|
||||
|
||||
/**
|
||||
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
|
||||
*/
|
||||
private static _checkObjectHullHeight: number;
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this._tailA.destroy();
|
||||
this._tailB.destroy();
|
||||
this._headA.destroy();
|
||||
this._headB.destroy();
|
||||
|
||||
this._tailA = null;
|
||||
this._tailB = null;
|
||||
this._headA = null;
|
||||
this._headB = null;
|
||||
|
||||
if (this._northWestTree != null)
|
||||
{
|
||||
this._northWestTree.destroy();
|
||||
}
|
||||
|
||||
if (this._northEastTree != null)
|
||||
{
|
||||
this._northEastTree.destroy();
|
||||
}
|
||||
|
||||
if (this._southEastTree != null)
|
||||
{
|
||||
this._southEastTree.destroy();
|
||||
}
|
||||
|
||||
if (this._southWestTree != null)
|
||||
{
|
||||
this._southWestTree.destroy();
|
||||
}
|
||||
|
||||
this._northWestTree = null;
|
||||
this._northEastTree = null;
|
||||
this._southEastTree = null;
|
||||
this._southWestTree = null;
|
||||
|
||||
QuadTree._object = null;
|
||||
QuadTree._processingCallback = null;
|
||||
QuadTree._notifyCallback = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load objects and/or groups into the quad tree, and register notify and processing callbacks.
|
||||
*
|
||||
* @param ObjectOrGroup1 Any object that is or extends GameObject or Group.
|
||||
* @param ObjectOrGroup2 Any object that is or extends GameObject or Group. If null, the first parameter will be checked against itself.
|
||||
* @param NotifyCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject)</code> that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true.
|
||||
* @param ProcessCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject):bool</code> that is called whenever two objects are found to overlap in world space. The NotifyCallback is only called if this function returns true. See GameObject.separate().
|
||||
*/
|
||||
public load(ObjectOrGroup1: Basic, ObjectOrGroup2: Basic = null, NotifyCallback = null, ProcessCallback = null) {
|
||||
|
||||
//console.log('quadtree load', QuadTree.divisions, ObjectOrGroup1, ObjectOrGroup2);
|
||||
|
||||
this.add(ObjectOrGroup1, QuadTree.A_LIST);
|
||||
|
||||
if (ObjectOrGroup2 != null)
|
||||
{
|
||||
this.add(ObjectOrGroup2, QuadTree.B_LIST);
|
||||
QuadTree._useBothLists = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._useBothLists = false;
|
||||
}
|
||||
|
||||
QuadTree._notifyCallback = NotifyCallback;
|
||||
QuadTree._processingCallback = ProcessCallback;
|
||||
|
||||
//console.log('use both', QuadTree._useBothLists);
|
||||
//console.log('------------ end of load');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function to add an object to the root of the tree.
|
||||
* This function will recursively add all group members, but
|
||||
* not the groups themselves.
|
||||
*
|
||||
* @param ObjectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly.
|
||||
* @param List A <code>uint</code> flag indicating the list to which you want to add the objects. Options are <code>QuadTree.A_LIST</code> and <code>QuadTree.B_LIST</code>.
|
||||
*/
|
||||
public add(ObjectOrGroup: Basic, List: number) {
|
||||
|
||||
QuadTree._list = List;
|
||||
|
||||
if (ObjectOrGroup.isGroup == true)
|
||||
{
|
||||
var i: number = 0;
|
||||
var basic: Basic;
|
||||
var members = <Group> ObjectOrGroup['members'];
|
||||
var l: number = ObjectOrGroup['length'];
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
basic = members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists)
|
||||
{
|
||||
if (basic.isGroup)
|
||||
{
|
||||
this.add(basic, List);
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._object = basic;
|
||||
|
||||
if (QuadTree._object.exists && QuadTree._object.allowCollisions)
|
||||
{
|
||||
QuadTree._objectLeftEdge = QuadTree._object.x;
|
||||
QuadTree._objectTopEdge = QuadTree._object.y;
|
||||
QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width;
|
||||
QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height;
|
||||
this.addObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._object = ObjectOrGroup;
|
||||
|
||||
//console.log('add - not group:', ObjectOrGroup.name);
|
||||
|
||||
if (QuadTree._object.exists && QuadTree._object.allowCollisions)
|
||||
{
|
||||
QuadTree._objectLeftEdge = QuadTree._object.x;
|
||||
QuadTree._objectTopEdge = QuadTree._object.y;
|
||||
QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width;
|
||||
QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height;
|
||||
//console.log('object properties', QuadTree._objectLeftEdge, QuadTree._objectTopEdge, QuadTree._objectRightEdge, QuadTree._objectBottomEdge);
|
||||
this.addObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for recursively navigating and creating the tree
|
||||
* while adding objects to the appropriate nodes.
|
||||
*/
|
||||
private addObject() {
|
||||
|
||||
//console.log('addObject');
|
||||
|
||||
//If this quad (not its children) lies entirely inside this object, add it here
|
||||
if (!this._canSubdivide || ((this._leftEdge >= QuadTree._objectLeftEdge) && (this._rightEdge <= QuadTree._objectRightEdge) && (this._topEdge >= QuadTree._objectTopEdge) && (this._bottomEdge <= QuadTree._objectBottomEdge)))
|
||||
{
|
||||
//console.log('add To List');
|
||||
this.addToList();
|
||||
return;
|
||||
}
|
||||
|
||||
//See if the selected object fits completely inside any of the quadrants
|
||||
if ((QuadTree._objectLeftEdge > this._leftEdge) && (QuadTree._objectRightEdge < this._midpointX))
|
||||
{
|
||||
if ((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY))
|
||||
{
|
||||
//console.log('Adding NW tree');
|
||||
|
||||
if (this._northWestTree == null)
|
||||
{
|
||||
this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._northWestTree.addObject();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge))
|
||||
{
|
||||
//console.log('Adding SW tree');
|
||||
|
||||
if (this._southWestTree == null)
|
||||
{
|
||||
this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._southWestTree.addObject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((QuadTree._objectLeftEdge > this._midpointX) && (QuadTree._objectRightEdge < this._rightEdge))
|
||||
{
|
||||
if ((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY))
|
||||
{
|
||||
//console.log('Adding NE tree');
|
||||
|
||||
if (this._northEastTree == null)
|
||||
{
|
||||
this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._northEastTree.addObject();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge))
|
||||
{
|
||||
//console.log('Adding SE tree');
|
||||
|
||||
if (this._southEastTree == null)
|
||||
{
|
||||
this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
this._southEastTree.addObject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//If it wasn't completely contained we have to check out the partial overlaps
|
||||
if ((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY))
|
||||
{
|
||||
if (this._northWestTree == null)
|
||||
{
|
||||
this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to north west partial tree');
|
||||
this._northWestTree.addObject();
|
||||
}
|
||||
|
||||
if ((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY))
|
||||
{
|
||||
if (this._northEastTree == null)
|
||||
{
|
||||
this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to north east partial tree');
|
||||
this._northEastTree.addObject();
|
||||
}
|
||||
|
||||
if ((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge))
|
||||
{
|
||||
if (this._southEastTree == null)
|
||||
{
|
||||
this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to south east partial tree');
|
||||
this._southEastTree.addObject();
|
||||
}
|
||||
|
||||
if ((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge))
|
||||
{
|
||||
if (this._southWestTree == null)
|
||||
{
|
||||
this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
|
||||
}
|
||||
|
||||
//console.log('added to south west partial tree');
|
||||
this._southWestTree.addObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for recursively adding objects to leaf lists.
|
||||
*/
|
||||
private addToList() {
|
||||
|
||||
//console.log('Adding to List');
|
||||
|
||||
var ot: LinkedList;
|
||||
|
||||
if (QuadTree._list == QuadTree.A_LIST)
|
||||
{
|
||||
//console.log('A LIST');
|
||||
if (this._tailA.object != null)
|
||||
{
|
||||
ot = this._tailA;
|
||||
this._tailA = new LinkedList();
|
||||
ot.next = this._tailA;
|
||||
}
|
||||
|
||||
this._tailA.object = QuadTree._object;
|
||||
}
|
||||
else
|
||||
{
|
||||
//console.log('B LIST');
|
||||
if (this._tailB.object != null)
|
||||
{
|
||||
ot = this._tailB;
|
||||
this._tailB = new LinkedList();
|
||||
ot.next = this._tailB;
|
||||
}
|
||||
|
||||
this._tailB.object = QuadTree._object;
|
||||
}
|
||||
|
||||
if (!this._canSubdivide)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._northWestTree != null)
|
||||
{
|
||||
this._northWestTree.addToList();
|
||||
}
|
||||
|
||||
if (this._northEastTree != null)
|
||||
{
|
||||
this._northEastTree.addToList();
|
||||
}
|
||||
|
||||
if (this._southEastTree != null)
|
||||
{
|
||||
this._southEastTree.addToList();
|
||||
}
|
||||
|
||||
if (this._southWestTree != null)
|
||||
{
|
||||
this._southWestTree.addToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>QuadTree</code>'s other main function. Call this after adding objects
|
||||
* using <code>QuadTree.load()</code> to compare the objects that you loaded.
|
||||
*
|
||||
* @return Whether or not any overlaps were found.
|
||||
*/
|
||||
public execute(): bool {
|
||||
|
||||
//console.log('quadtree execute');
|
||||
|
||||
var overlapProcessed: bool = false;
|
||||
var iterator: LinkedList;
|
||||
|
||||
if (this._headA.object != null)
|
||||
{
|
||||
//console.log('---------------------------------------------------');
|
||||
//console.log('headA iterator');
|
||||
|
||||
iterator = this._headA;
|
||||
|
||||
while (iterator != null)
|
||||
{
|
||||
QuadTree._object = iterator.object;
|
||||
|
||||
if (QuadTree._useBothLists)
|
||||
{
|
||||
QuadTree._iterator = this._headB;
|
||||
}
|
||||
else
|
||||
{
|
||||
QuadTree._iterator = iterator.next;
|
||||
}
|
||||
|
||||
if (QuadTree._object.exists && (QuadTree._object.allowCollisions > 0) && (QuadTree._iterator != null) && (QuadTree._iterator.object != null) && QuadTree._iterator.object.exists && this.overlapNode())
|
||||
{
|
||||
//console.log('headA iterator overlapped true');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
iterator = iterator.next;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Advance through the tree by calling overlap on each child
|
||||
if ((this._northWestTree != null) && this._northWestTree.execute())
|
||||
{
|
||||
//console.log('NW quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._northEastTree != null) && this._northEastTree.execute())
|
||||
{
|
||||
//console.log('NE quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._southEastTree != null) && this._southEastTree.execute())
|
||||
{
|
||||
//console.log('SE quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if ((this._southWestTree != null) && this._southWestTree.execute())
|
||||
{
|
||||
//console.log('SW quadtree execute');
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
return overlapProcessed;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An private for comparing an object against the contents of a node.
|
||||
*
|
||||
* @return Whether or not any overlaps were found.
|
||||
*/
|
||||
private overlapNode(): bool {
|
||||
|
||||
//console.log('overlapNode');
|
||||
|
||||
//Walk the list and check for overlaps
|
||||
var overlapProcessed: bool = false;
|
||||
var checkObject;
|
||||
|
||||
while (QuadTree._iterator != null)
|
||||
{
|
||||
if (!QuadTree._object.exists || (QuadTree._object.allowCollisions <= 0))
|
||||
{
|
||||
//console.log('break 1');
|
||||
break;
|
||||
}
|
||||
|
||||
checkObject = QuadTree._iterator.object;
|
||||
|
||||
if ((QuadTree._object === checkObject) || !checkObject.exists || (checkObject.allowCollisions <= 0))
|
||||
{
|
||||
//console.log('break 2');
|
||||
QuadTree._iterator = QuadTree._iterator.next;
|
||||
continue;
|
||||
}
|
||||
|
||||
//calculate bulk hull for QuadTree._object
|
||||
QuadTree._objectHullX = (QuadTree._object.x < QuadTree._object.last.x) ? QuadTree._object.x : QuadTree._object.last.x;
|
||||
QuadTree._objectHullY = (QuadTree._object.y < QuadTree._object.last.y) ? QuadTree._object.y : QuadTree._object.last.y;
|
||||
QuadTree._objectHullWidth = QuadTree._object.x - QuadTree._object.last.x;
|
||||
QuadTree._objectHullWidth = QuadTree._object.width + ((QuadTree._objectHullWidth > 0) ? QuadTree._objectHullWidth : -QuadTree._objectHullWidth);
|
||||
QuadTree._objectHullHeight = QuadTree._object.y - QuadTree._object.last.y;
|
||||
QuadTree._objectHullHeight = QuadTree._object.height + ((QuadTree._objectHullHeight > 0) ? QuadTree._objectHullHeight : -QuadTree._objectHullHeight);
|
||||
|
||||
//calculate bulk hull for checkObject
|
||||
QuadTree._checkObjectHullX = (checkObject.x < checkObject.last.x) ? checkObject.x : checkObject.last.x;
|
||||
QuadTree._checkObjectHullY = (checkObject.y < checkObject.last.y) ? checkObject.y : checkObject.last.y;
|
||||
QuadTree._checkObjectHullWidth = checkObject.x - checkObject.last.x;
|
||||
QuadTree._checkObjectHullWidth = checkObject.width + ((QuadTree._checkObjectHullWidth > 0) ? QuadTree._checkObjectHullWidth : -QuadTree._checkObjectHullWidth);
|
||||
QuadTree._checkObjectHullHeight = checkObject.y - checkObject.last.y;
|
||||
QuadTree._checkObjectHullHeight = checkObject.height + ((QuadTree._checkObjectHullHeight > 0) ? QuadTree._checkObjectHullHeight : -QuadTree._checkObjectHullHeight);
|
||||
|
||||
//check for intersection of the two hulls
|
||||
if ((QuadTree._objectHullX + QuadTree._objectHullWidth > QuadTree._checkObjectHullX) && (QuadTree._objectHullX < QuadTree._checkObjectHullX + QuadTree._checkObjectHullWidth) && (QuadTree._objectHullY + QuadTree._objectHullHeight > QuadTree._checkObjectHullY) && (QuadTree._objectHullY < QuadTree._checkObjectHullY + QuadTree._checkObjectHullHeight))
|
||||
{
|
||||
//console.log('intersection!');
|
||||
|
||||
//Execute callback functions if they exist
|
||||
if ((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, checkObject))
|
||||
{
|
||||
overlapProcessed = true;
|
||||
}
|
||||
|
||||
if (overlapProcessed && (QuadTree._notifyCallback != null))
|
||||
{
|
||||
QuadTree._notifyCallback(QuadTree._object, checkObject);
|
||||
}
|
||||
}
|
||||
|
||||
QuadTree._iterator = QuadTree._iterator.next;
|
||||
|
||||
}
|
||||
|
||||
return overlapProcessed;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../SoundManager.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Sound
|
||||
*
|
||||
* A Sound file, used by the Game.SoundManager for playback.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Sound {
|
||||
|
||||
constructor(context, gainNode, data, volume?: number = 1, loop?: bool = false) {
|
||||
|
||||
this._context = context;
|
||||
this._gainNode = gainNode;
|
||||
this._buffer = data;
|
||||
this._volume = volume;
|
||||
this.loop = loop;
|
||||
|
||||
// Local volume control
|
||||
if (this._context !== null)
|
||||
{
|
||||
this._localGainNode = this._context.createGainNode();
|
||||
this._localGainNode.connect(this._gainNode);
|
||||
this._localGainNode.gain.value = this._volume;
|
||||
}
|
||||
|
||||
if (this._buffer === null)
|
||||
{
|
||||
this.isDecoding = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.play();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private _context;
|
||||
private _gainNode;
|
||||
private _localGainNode;
|
||||
private _buffer;
|
||||
private _volume: number;
|
||||
private _sound;
|
||||
|
||||
loop: bool = false;
|
||||
duration: number;
|
||||
isPlaying: bool = false;
|
||||
isDecoding: bool = false;
|
||||
|
||||
public setDecodedBuffer(data) {
|
||||
|
||||
this._buffer = data;
|
||||
this.isDecoding = false;
|
||||
this.play();
|
||||
|
||||
}
|
||||
|
||||
public play() {
|
||||
|
||||
if (this._buffer === null || this.isDecoding === true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._sound = this._context.createBufferSource();
|
||||
this._sound.buffer = this._buffer;
|
||||
this._sound.connect(this._localGainNode);
|
||||
|
||||
if (this.loop)
|
||||
{
|
||||
this._sound.loop = true;
|
||||
}
|
||||
|
||||
this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
|
||||
|
||||
this.duration = this._sound.buffer.duration;
|
||||
this.isPlaying = true;
|
||||
|
||||
}
|
||||
|
||||
public stop() {
|
||||
|
||||
if (this.isPlaying === true)
|
||||
{
|
||||
this.isPlaying = false;
|
||||
|
||||
this._sound.noteOff(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public mute() {
|
||||
|
||||
this._localGainNode.gain.value = 0;
|
||||
|
||||
}
|
||||
|
||||
public unmute() {
|
||||
|
||||
this._localGainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public set volume(value: number) {
|
||||
|
||||
this._volume = value;
|
||||
this._localGainNode.gain.value = this._volume;
|
||||
|
||||
}
|
||||
|
||||
public get volume(): number {
|
||||
return this._volume;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - StageScaleMode
|
||||
*
|
||||
* This class controls the scaling of your game. On mobile devices it will also remove the URL bar and allow
|
||||
* you to maintain proportion and aspect ratio.
|
||||
* It is based on a technique taken from Viewporter v2.0 by Zynga Inc. http://github.com/zynga/viewporter
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class StageScaleMode {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.orientation = window['orientation'];
|
||||
|
||||
window.addEventListener('orientationchange', (event) => this.checkOrientation(event), false);
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _startHeight: number = 0;
|
||||
private _iterations: number;
|
||||
private _check;
|
||||
|
||||
// Specifies that the game be visible in the specified area without trying to preserve the original aspect ratio.
|
||||
public static EXACT_FIT: number = 0;
|
||||
|
||||
// Specifies that the size of the game be fixed, so that it remains unchanged even if the size of the window changes.
|
||||
public static NO_SCALE: number = 1;
|
||||
|
||||
// Specifies that the entire game be visible in the specified area without distortion while maintaining the original aspect ratio.
|
||||
public static SHOW_ALL: number = 2;
|
||||
|
||||
public width: number = 0;
|
||||
public height: number = 0;
|
||||
|
||||
public orientation;
|
||||
|
||||
public update() {
|
||||
|
||||
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
|
||||
{
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get isLandscape(): bool {
|
||||
return window['orientation'] === 90 || window['orientation'] === -90;
|
||||
}
|
||||
|
||||
private checkOrientation(event) {
|
||||
|
||||
if (window['orientation'] !== this.orientation)
|
||||
{
|
||||
this.refresh();
|
||||
this.orientation = window['orientation'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private refresh() {
|
||||
|
||||
// We can't do anything about the status bars in iPads, web apps or desktops
|
||||
if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false)
|
||||
{
|
||||
document.documentElement.style.minHeight = '5000px';
|
||||
|
||||
this._startHeight = window.innerHeight;
|
||||
|
||||
if (this._game.device.android && this._game.device.chrome == false)
|
||||
{
|
||||
window.scrollTo(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (this._check == null)
|
||||
{
|
||||
this._iterations = 40;
|
||||
this._check = window.setInterval(() => this.setScreenSize(), 10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private setScreenSize() {
|
||||
|
||||
if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false)
|
||||
{
|
||||
if (this._game.device.android && this._game.device.chrome == false)
|
||||
{
|
||||
window.scrollTo(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
this._iterations--;
|
||||
|
||||
if (window.innerHeight > this._startHeight || this._iterations < 0)
|
||||
{
|
||||
// Set minimum height of content to new window height
|
||||
document.documentElement.style.minHeight = window.innerHeight + 'px';
|
||||
|
||||
if (this._game.stage.scaleMode == StageScaleMode.EXACT_FIT)
|
||||
{
|
||||
if (this._game.stage.maxScaleX && window.innerWidth > this._game.stage.maxScaleX)
|
||||
{
|
||||
this.width = this._game.stage.maxScaleX;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.width = window.innerWidth;
|
||||
}
|
||||
|
||||
if (this._game.stage.maxScaleY && window.innerHeight > this._game.stage.maxScaleY)
|
||||
{
|
||||
this.height = this._game.stage.maxScaleY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.height = window.innerHeight;
|
||||
}
|
||||
}
|
||||
else if (this._game.stage.scaleMode == StageScaleMode.SHOW_ALL)
|
||||
{
|
||||
var multiplier = Math.min((window.innerHeight / this._game.stage.height), (window.innerWidth / this._game.stage.width));
|
||||
|
||||
this.width = Math.round(this._game.stage.width * multiplier);
|
||||
this.height = Math.round(this._game.stage.height * multiplier);
|
||||
|
||||
if (this._game.stage.maxScaleX && this.width > this._game.stage.maxScaleX)
|
||||
{
|
||||
this.width = this._game.stage.maxScaleX;
|
||||
}
|
||||
|
||||
if (this._game.stage.maxScaleY && this.height > this._game.stage.maxScaleY)
|
||||
{
|
||||
this.height = this._game.stage.maxScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
this._game.stage.canvas.style.width = this.width + 'px';
|
||||
this._game.stage.canvas.style.height = this.height + 'px';
|
||||
|
||||
this._game.input.scaleX = this._game.stage.width / this.width;
|
||||
this._game.input.scaleY = this._game.stage.height / this.height;
|
||||
|
||||
clearInterval(this._check);
|
||||
|
||||
this._check = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Tile
|
||||
*
|
||||
* A simple helper object for <code>Tilemap</code> that helps expand collision opportunities and control.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Tile extends GameObject {
|
||||
|
||||
/**
|
||||
* Instantiate this new tile object. This is usually called from <code>Tilemap.loadMap()</code>.
|
||||
*
|
||||
* @param Tilemap A reference to the tilemap object creating the tile.
|
||||
* @param Index The actual core map data index for this tile type.
|
||||
* @param Width The width of the tile.
|
||||
* @param Height The height of the tile.
|
||||
* @param Visible Whether the tile is visible or not.
|
||||
* @param AllowCollisions The collision flags for the object. By default this value is ANY or NONE depending on the parameters sent to loadMap().
|
||||
*/
|
||||
constructor(game: Game, Tilemap: Tilemap, Index: number, Width: number, Height: number, Visible: bool, AllowCollisions: number) {
|
||||
|
||||
super(game, 0, 0, Width, Height);
|
||||
|
||||
this.immovable = true;
|
||||
this.moves = false;
|
||||
this.callback = null;
|
||||
this.filter = null;
|
||||
|
||||
this.tilemap = Tilemap;
|
||||
this.index = Index;
|
||||
this.visible = Visible;
|
||||
this.allowCollisions = AllowCollisions;
|
||||
|
||||
this.mapIndex = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called whenever an object hits a tile of this type.
|
||||
* This function should take the form <code>myFunction(Tile:Tile,Object:Object)</code>.
|
||||
* Defaults to null, set through <code>Tilemap.setTileProperties()</code>.
|
||||
*/
|
||||
public callback;
|
||||
|
||||
/**
|
||||
* Each tile can store its own filter class for their callback functions.
|
||||
* That is, the callback will only be triggered if an object with a class
|
||||
* type matching the filter touched it.
|
||||
* Defaults to null, set through <code>Tilemap.setTileProperties()</code>.
|
||||
*/
|
||||
public filter;
|
||||
|
||||
/**
|
||||
* A reference to the tilemap this tile object belongs to.
|
||||
*/
|
||||
public tilemap: Tilemap;
|
||||
|
||||
/**
|
||||
* The index of this tile type in the core map data.
|
||||
* For example, if your map only has 16 kinds of tiles in it,
|
||||
* this number is usually between 0 and 15.
|
||||
*/
|
||||
public index: number;
|
||||
|
||||
/**
|
||||
* The current map index of this tile object at this moment.
|
||||
* You can think of tile objects as moving around the tilemap helping with collisions.
|
||||
* This value is only reliable and useful if used from the callback function.
|
||||
*/
|
||||
public mapIndex: number;
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
super.destroy();
|
||||
this.callback = null;
|
||||
this.tilemap = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - TilemapBuffer
|
||||
*
|
||||
* Responsible for rendering a portion of a tilemap to the given Camera.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class TilemapBuffer {
|
||||
|
||||
constructor(game: Game, camera: Camera, tilemap: Tilemap, texture, tileOffsets) {
|
||||
|
||||
//console.log('New TilemapBuffer created for Camera ' + camera.ID);
|
||||
|
||||
this._game = game;
|
||||
this.camera = camera;
|
||||
this._tilemap = tilemap;
|
||||
this._texture = texture;
|
||||
this._tileOffsets = tileOffsets;
|
||||
|
||||
//this.createCanvas();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _tilemap: Tilemap;
|
||||
private _texture;
|
||||
private _tileOffsets;
|
||||
|
||||
private _startX: number = 0;
|
||||
private _maxX: number = 0;
|
||||
private _startY: number = 0;
|
||||
private _maxY: number = 0;
|
||||
private _tx: number = 0;
|
||||
private _ty: number = 0;
|
||||
private _dx: number = 0;
|
||||
private _dy: number = 0;
|
||||
private _oldCameraX: number = 0;
|
||||
private _oldCameraY: number = 0;
|
||||
private _dirty: bool = true;
|
||||
private _columnData;
|
||||
|
||||
public camera: Camera;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
private createCanvas() {
|
||||
|
||||
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this.canvas.width = this._game.stage.width;
|
||||
this.canvas.height = this._game.stage.height;
|
||||
this.context = this.canvas.getContext('2d');
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
/*
|
||||
if (this.camera.worldView.x !== this._oldCameraX || this.camera.worldView.y !== this._oldCameraY)
|
||||
{
|
||||
this._dirty = true;
|
||||
}
|
||||
|
||||
this._oldCameraX = this.camera.worldView.x;
|
||||
this._oldCameraY = this.camera.worldView.y;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('TilemapBuffer', x, y);
|
||||
this._game.stage.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
|
||||
this._game.stage.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
|
||||
this._game.stage.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
|
||||
this._game.stage.context.fillText('Dirty: ' + this._dirty, x, y + 56);
|
||||
|
||||
}
|
||||
|
||||
public render(dx, dy): bool {
|
||||
|
||||
/*
|
||||
if (this._dirty == false)
|
||||
{
|
||||
this._game.stage.context.drawImage(this.canvas, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
// Work out how many tiles we can fit into our camera and round it up for the edges
|
||||
this._maxX = this._game.math.ceil(this.camera.width / this._tilemap.tileWidth) + 1;
|
||||
this._maxY = this._game.math.ceil(this.camera.height / this._tilemap.tileHeight) + 1;
|
||||
|
||||
// And now work out where in the tilemap the camera actually is
|
||||
this._startX = this._game.math.floor(this.camera.worldView.x / this._tilemap.tileWidth);
|
||||
this._startY = this._game.math.floor(this.camera.worldView.y / this._tilemap.tileHeight);
|
||||
|
||||
// Tilemap bounds check
|
||||
if (this._startX < 0)
|
||||
{
|
||||
this._startX = 0;
|
||||
}
|
||||
|
||||
if (this._startY < 0)
|
||||
{
|
||||
this._startY = 0;
|
||||
}
|
||||
|
||||
if (this._startX + this._maxX > this._tilemap.widthInTiles)
|
||||
{
|
||||
this._startX = this._tilemap.widthInTiles - this._maxX;
|
||||
}
|
||||
|
||||
if (this._startY + this._maxY > this._tilemap.heightInTiles)
|
||||
{
|
||||
this._startY = this._tilemap.heightInTiles - this._maxY;
|
||||
}
|
||||
|
||||
// Finally get the offset to avoid the blocky movement
|
||||
this._dx = dx;
|
||||
this._dy = dy;
|
||||
|
||||
this._dx += -(this.camera.worldView.x - (this._startX * this._tilemap.tileWidth));
|
||||
this._dy += -(this.camera.worldView.y - (this._startY * this._tilemap.tileHeight));
|
||||
|
||||
this._tx = this._dx;
|
||||
this._ty = this._dy;
|
||||
|
||||
for (var row = this._startY; row < this._startY + this._maxY; row++)
|
||||
{
|
||||
this._columnData = this._tilemap.mapData[row];
|
||||
|
||||
for (var tile = this._startX; tile < this._startX + this._maxX; tile++)
|
||||
{
|
||||
if (this._tileOffsets[this._columnData[tile]])
|
||||
{
|
||||
//this.context.drawImage(
|
||||
this._game.stage.context.drawImage(
|
||||
this._texture, // Source Image
|
||||
this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image)
|
||||
this._tileOffsets[this._columnData[tile]].y, // Source Y
|
||||
this._tilemap.tileWidth, // Source Width
|
||||
this._tilemap.tileHeight, // Source Height
|
||||
this._tx, // Destination X (where on the canvas it'll be drawn)
|
||||
this._ty, // Destination Y
|
||||
this._tilemap.tileWidth, // Destination Width (always same as Source Width unless scaled)
|
||||
this._tilemap.tileHeight // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
|
||||
this._tx += this._tilemap.tileWidth;
|
||||
}
|
||||
}
|
||||
|
||||
this._tx = this._dx;
|
||||
this._ty += this._tilemap.tileHeight;
|
||||
|
||||
}
|
||||
|
||||
//this._game.stage.context.drawImage(this.canvas, 0, 0);
|
||||
//console.log('dirty cleaned');
|
||||
//this._dirty = false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="easing/Back.ts" />
|
||||
/// <reference path="easing/Bounce.ts" />
|
||||
/// <reference path="easing/Circular.ts" />
|
||||
/// <reference path="easing/Cubic.ts" />
|
||||
/// <reference path="easing/Elastic.ts" />
|
||||
/// <reference path="easing/Exponential.ts" />
|
||||
/// <reference path="easing/Linear.ts" />
|
||||
/// <reference path="easing/Quadratic.ts" />
|
||||
/// <reference path="easing/Quartic.ts" />
|
||||
/// <reference path="easing/Quintic.ts" />
|
||||
/// <reference path="easing/Sinusoidal.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Tween
|
||||
*
|
||||
* Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Tween {
|
||||
|
||||
constructor(object, game:Phaser.Game) {
|
||||
|
||||
this._object = object;
|
||||
|
||||
this._game = game;
|
||||
this._manager = this._game.tweens;
|
||||
this._interpolationFunction = this._game.math.linearInterpolation;
|
||||
this._easingFunction = Phaser.Easing.Linear.None;
|
||||
|
||||
this.onStart = new Phaser.Signal();
|
||||
this.onUpdate = new Phaser.Signal();
|
||||
this.onComplete = new Phaser.Signal();
|
||||
|
||||
}
|
||||
|
||||
private _game: Phaser.Game;
|
||||
private _manager: Phaser.TweenManager;
|
||||
private _object = null;
|
||||
private _pausedTime: number = 0;
|
||||
|
||||
private _valuesStart = {};
|
||||
private _valuesEnd = {};
|
||||
private _duration = 1000;
|
||||
private _delayTime = 0;
|
||||
private _startTime = null;
|
||||
private _easingFunction;
|
||||
private _interpolationFunction;
|
||||
private _chainedTweens = [];
|
||||
|
||||
public onStart: Phaser.Signal;
|
||||
public onUpdate: Phaser.Signal;
|
||||
public onComplete: Phaser.Signal;
|
||||
|
||||
public to(properties, duration?: number = 1000, ease?: any = null, autoStart?: bool = false) {
|
||||
|
||||
this._duration = duration;
|
||||
|
||||
// If properties isn't an object this will fail, sanity check it here somehow?
|
||||
this._valuesEnd = properties;
|
||||
|
||||
if (ease !== null)
|
||||
{
|
||||
this._easingFunction = ease;
|
||||
}
|
||||
|
||||
if (autoStart === true)
|
||||
{
|
||||
return this.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public start() {
|
||||
|
||||
if (this._game === null || this._object === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._manager.add(this);
|
||||
|
||||
this.onStart.dispatch(this._object);
|
||||
|
||||
this._startTime = this._game.time.now + this._delayTime;
|
||||
|
||||
for (var property in this._valuesEnd)
|
||||
{
|
||||
// This prevents the interpolation of null values or of non-existing properties
|
||||
if (this._object[property] === null || !(property in this._object))
|
||||
{
|
||||
throw Error('Phaser.Tween interpolation of null value of non-existing property');
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if an Array was provided as property value
|
||||
if (this._valuesEnd[property] instanceof Array)
|
||||
{
|
||||
if (this._valuesEnd[property].length === 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// create a local copy of the Array with the start value at the front
|
||||
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]);
|
||||
}
|
||||
|
||||
this._valuesStart[property] = this._object[property];
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public stop() {
|
||||
|
||||
if (this._manager !== null)
|
||||
{
|
||||
this._manager.remove(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public set parent(value:Phaser.Game) {
|
||||
|
||||
this._game = value;
|
||||
this._manager = this._game.tweens;
|
||||
|
||||
}
|
||||
|
||||
public set delay(amount:number) {
|
||||
this._delayTime = amount;
|
||||
}
|
||||
|
||||
public get delay(): number {
|
||||
return this._delayTime;
|
||||
}
|
||||
|
||||
public set easing(easing) {
|
||||
this._easingFunction = easing;
|
||||
}
|
||||
|
||||
public get easing():any {
|
||||
return this._easingFunction;
|
||||
}
|
||||
|
||||
public set interpolation(interpolation) {
|
||||
this._interpolationFunction = interpolation;
|
||||
}
|
||||
|
||||
public get interpolation():any {
|
||||
return this._interpolationFunction;
|
||||
}
|
||||
|
||||
public chain(tween:Phaser.Tween) {
|
||||
|
||||
this._chainedTweens.push(tween);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public debugValue;
|
||||
|
||||
public update(time) {
|
||||
|
||||
if (this._game.paused == true)
|
||||
{
|
||||
if (this._pausedTime == 0)
|
||||
{
|
||||
this._pausedTime = time;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ok we aren't paused, but was there some time gained?
|
||||
if (this._pausedTime > 0)
|
||||
{
|
||||
this._startTime += (time - this._pausedTime);
|
||||
this._pausedTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (time < this._startTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var elapsed = (time - this._startTime) / this._duration;
|
||||
elapsed = elapsed > 1 ? 1 : elapsed;
|
||||
|
||||
var value = this._easingFunction(elapsed);
|
||||
|
||||
for (var property in this._valuesStart)
|
||||
{
|
||||
// Add checks for object, array, numeric up front
|
||||
if (this._valuesEnd[property] instanceof Array)
|
||||
{
|
||||
this._object[property] = this._interpolationFunction(this._valuesEnd[property], value);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._object[property] = this._valuesStart[property] + (this._valuesEnd[property] - this._valuesStart[property]) * value;
|
||||
}
|
||||
}
|
||||
|
||||
this.onUpdate.dispatch(this._object, value);
|
||||
|
||||
if (elapsed == 1)
|
||||
{
|
||||
this.onComplete.dispatch(this._object);
|
||||
|
||||
for (var i = 0; i < this._chainedTweens.length; i++)
|
||||
{
|
||||
this._chainedTweens[i].start();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Animation
|
||||
*
|
||||
* An Animation is a single animation. It is created by the AnimationManager and belongs to Sprite objects.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Animation {
|
||||
|
||||
constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
this._frames = frames;
|
||||
this._frameData = frameData;
|
||||
|
||||
this.name = name;
|
||||
this.delay = 1000 / delay;
|
||||
this.looped = looped;
|
||||
|
||||
this.isFinished = false;
|
||||
this.isPlaying = false;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Sprite;
|
||||
private _frames: number[];
|
||||
private _frameData: FrameData;
|
||||
private _frameIndex: number;
|
||||
|
||||
private _timeLastFrame: number;
|
||||
private _timeNextFrame: number;
|
||||
|
||||
public name: string;
|
||||
public currentFrame: Frame;
|
||||
|
||||
public isFinished: bool;
|
||||
public isPlaying: bool;
|
||||
public looped: bool;
|
||||
public delay: number;
|
||||
|
||||
public get frameTotal(): number {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
||||
public get frame(): number {
|
||||
return this._frameIndex;
|
||||
}
|
||||
|
||||
public set frame(value: number) {
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
{
|
||||
this._parent.bounds.width = this.currentFrame.width;
|
||||
this._parent.bounds.height = this.currentFrame.height;
|
||||
this._frameIndex = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public play(frameRate?: number = null, loop?: bool) {
|
||||
|
||||
if (frameRate !== null)
|
||||
{
|
||||
this.delay = 1000 / frameRate;
|
||||
}
|
||||
|
||||
if (loop !== undefined)
|
||||
{
|
||||
this.looped = loop;
|
||||
}
|
||||
|
||||
this.isPlaying = true;
|
||||
this.isFinished = false;
|
||||
|
||||
this._timeLastFrame = this._game.time.now;
|
||||
this._timeNextFrame = this._game.time.now + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
}
|
||||
|
||||
public restart() {
|
||||
|
||||
this.isPlaying = true;
|
||||
this.isFinished = false;
|
||||
|
||||
this._timeLastFrame = this._game.time.now;
|
||||
this._timeNextFrame = this._game.time.now + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
}
|
||||
|
||||
public stop() {
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
|
||||
}
|
||||
|
||||
public update(): bool {
|
||||
|
||||
if (this.isPlaying == true && this._game.time.now >= this._timeNextFrame)
|
||||
{
|
||||
this._frameIndex++;
|
||||
|
||||
if (this._frameIndex == this._frames.length)
|
||||
{
|
||||
if (this.looped)
|
||||
{
|
||||
this._frameIndex = 0;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.onComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
}
|
||||
|
||||
this._timeLastFrame = this._game.time.now;
|
||||
this._timeNextFrame = this._game.time.now + this.delay;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
|
||||
this._game = null;
|
||||
this._parent = null;
|
||||
this._frames = null;
|
||||
this._frameData = null;
|
||||
this.currentFrame = null;
|
||||
this.isPlaying = false;
|
||||
|
||||
}
|
||||
|
||||
private onComplete() {
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
// callback
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - AnimationLoader
|
||||
*
|
||||
* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class AnimationLoader {
|
||||
|
||||
public static parseSpriteSheet(game: Game, key: string, frameWidth: number, frameHeight: number, frameMax: number): FrameData {
|
||||
|
||||
// How big is our image?
|
||||
|
||||
var img = game.cache.getImage(key);
|
||||
|
||||
if (img == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var width = img.width;
|
||||
var height = img.height;
|
||||
|
||||
var row = Math.round(width / frameWidth);
|
||||
var column = Math.round(height / frameHeight);
|
||||
var total = row * column;
|
||||
|
||||
if (frameMax !== -1)
|
||||
{
|
||||
total = frameMax;
|
||||
}
|
||||
|
||||
// Zero or smaller than frame sizes?
|
||||
if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Let's create some frames then
|
||||
var data: FrameData = new FrameData();
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
for (var i = 0; i < total; i++)
|
||||
{
|
||||
data.addFrame(new Frame(x, y, frameWidth, frameHeight, ''));
|
||||
|
||||
x += frameWidth;
|
||||
|
||||
if (x === width)
|
||||
{
|
||||
x = 0;
|
||||
y += frameHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
public static parseJSONData(game: Game, json): FrameData {
|
||||
|
||||
// Let's create some frames then
|
||||
var data: FrameData = new FrameData();
|
||||
|
||||
// By this stage frames is a fully parsed array
|
||||
var frames = json;
|
||||
|
||||
var newFrame: Frame;
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
newFrame = data.addFrame(new Frame(frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h, frames[i].filename));
|
||||
newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Frame
|
||||
*
|
||||
* A Frame is a single frame of an animation and is part of a FrameData collection.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Frame {
|
||||
|
||||
constructor(x: number, y: number, width: number, height: number, name: string) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.name = name;
|
||||
|
||||
this.rotated = false;
|
||||
this.trimmed = false;
|
||||
|
||||
}
|
||||
|
||||
// Position within the image to cut from
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
|
||||
// Useful for Sprite Sheets
|
||||
public index: number;
|
||||
|
||||
// Useful for Texture Atlas files (is set to the filename value)
|
||||
public name: string = '';
|
||||
|
||||
// Rotated? (not yet implemented)
|
||||
public rotated: bool = false;
|
||||
|
||||
// Either cw or ccw, rotation is always 90 degrees
|
||||
public rotationDirection: string = 'cw';
|
||||
|
||||
// Was it trimmed when packed?
|
||||
public trimmed: bool;
|
||||
|
||||
// The coordinates of the trimmed sprite inside the original sprite
|
||||
public sourceSizeW: number;
|
||||
public sourceSizeH: number;
|
||||
public spriteSourceSizeX: number;
|
||||
public spriteSourceSizeY: number;
|
||||
public spriteSourceSizeW: number;
|
||||
public spriteSourceSizeH: number;
|
||||
|
||||
public setRotation(rotated: bool, rotationDirection: string) {
|
||||
// Not yet supported
|
||||
}
|
||||
|
||||
public setTrim(trimmed: bool, actualWidth, actualHeight, destX, destY, destWidth, destHeight, ) {
|
||||
|
||||
this.trimmed = trimmed;
|
||||
|
||||
this.sourceSizeW = actualWidth;
|
||||
this.sourceSizeH = actualHeight;
|
||||
this.spriteSourceSizeX = destX;
|
||||
this.spriteSourceSizeY = destY;
|
||||
this.spriteSourceSizeW = destWidth;
|
||||
this.spriteSourceSizeH = destHeight;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FrameData
|
||||
*
|
||||
* FrameData is a container for Frame objects, the internal representation of animation data in Phaser.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class FrameData {
|
||||
|
||||
constructor() {
|
||||
|
||||
this._frames = [];
|
||||
this._frameNames = [];
|
||||
|
||||
}
|
||||
|
||||
private _frames: Frame[];
|
||||
private _frameNames;
|
||||
|
||||
public get total(): number {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
||||
public addFrame(frame: Frame): Frame {
|
||||
|
||||
frame.index = this._frames.length;
|
||||
|
||||
this._frames.push(frame);
|
||||
|
||||
if (frame.name !== '')
|
||||
{
|
||||
this._frameNames[frame.name] = frame.index;
|
||||
}
|
||||
|
||||
return frame;
|
||||
|
||||
}
|
||||
|
||||
public getFrame(index: number): Frame {
|
||||
|
||||
if (this._frames[index])
|
||||
{
|
||||
return this._frames[index];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public getFrameByName(name: string): Frame {
|
||||
|
||||
if (this._frameNames[name] >= 0)
|
||||
{
|
||||
return this._frames[this._frameNames[name]];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public checkFrameName(name: string): bool {
|
||||
|
||||
if (this._frameNames[name] >= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public getFrameRange(start: number, end: number, output?: Frame[] = []): Frame[] {
|
||||
|
||||
for (var i = start; i <= end; i++)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
public getFrameIndexes(output?: number[] = []): number[] {
|
||||
|
||||
output.length = 0;
|
||||
|
||||
for (var i = 0; i < this._frames.length; i++)
|
||||
{
|
||||
output.push(i);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
public getFrameIndexesByName(input: string[]): number[] {
|
||||
|
||||
var output: number[] = [];
|
||||
|
||||
for (var i = 0; i < input.length; i++)
|
||||
{
|
||||
if (this.getFrameByName(input[i]))
|
||||
{
|
||||
output.push(this.getFrameByName(input[i]).index);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
public getAllFrames(): Frame[] {
|
||||
return this._frames;
|
||||
}
|
||||
|
||||
public getFrames(range: number[]) {
|
||||
|
||||
var output: Frame[] = [];
|
||||
|
||||
for (var i = 0; i < range.length; i++)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Back
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Back {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
var s = 1.70158;
|
||||
return k * k * ((s + 1) * k - s);
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
var s = 1.70158;
|
||||
return --k * k * ((s + 1) * k + s) + 1;
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
var s = 1.70158 * 1.525;
|
||||
if ((k *= 2) < 1) return 0.5 * (k * k * ((s + 1) * k - s));
|
||||
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Bounce
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Bounce {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
return 1 - Phaser.Easing.Bounce.Out(1 - k);
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
if (k < (1 / 2.75))
|
||||
{
|
||||
return 7.5625 * k * k;
|
||||
}
|
||||
else if (k < (2 / 2.75))
|
||||
{
|
||||
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
|
||||
}
|
||||
else if (k < (2.5 / 2.75))
|
||||
{
|
||||
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
if (k < 0.5) return Phaser.Easing.Bounce.In(k * 2) * 0.5;
|
||||
return Phaser.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Cubic
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Cubic {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
return k * k * k;
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
return --k * k * k + 1;
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
if ((k *= 2) < 1) return 0.5 * k * k * k;
|
||||
return 0.5 * ((k -= 2) * k * k + 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Exponential
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Exponential {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
return k === 0 ? 0 : Math.pow(1024, k - 1);
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
if (k === 0) return 0;
|
||||
if (k === 1) return 1;
|
||||
if ((k *= 2) < 1) return 0.5 * Math.pow(1024, k - 1);
|
||||
return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Linear
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Linear {
|
||||
|
||||
public static None(k) {
|
||||
|
||||
return k;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Quadratic
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Quadratic {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
return k * k;
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
return k * (2 - k);
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
if ((k *= 2) < 1) return 0.5 * k * k;
|
||||
return -0.5 * (--k * (k - 2) - 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Quartic
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Quartic {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
return k * k * k * k;
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
return 1 - (--k * k * k * k);
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
if ((k *= 2) < 1) return 0.5 * k * k * k * k;
|
||||
return -0.5 * ((k -= 2) * k * k * k - 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Quintic
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Quintic {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
return k * k * k * k * k;
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
return --k * k * k * k * k + 1;
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
if ((k *= 2) < 1) return 0.5 * k * k * k * k * k;
|
||||
return 0.5 * ((k -= 2) * k * k * k * k + 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Easing - Sinusoidal
|
||||
*
|
||||
* For use with Phaser.Tween
|
||||
*/
|
||||
|
||||
module Phaser.Easing {
|
||||
|
||||
export class Sinusoidal {
|
||||
|
||||
public static In(k) {
|
||||
|
||||
return 1 - Math.cos(k * Math.PI / 2);
|
||||
|
||||
}
|
||||
|
||||
public static Out(k) {
|
||||
|
||||
return Math.sin(k * Math.PI / 2);
|
||||
|
||||
}
|
||||
|
||||
public static InOut(k) {
|
||||
|
||||
return 0.5 * (1 - Math.cos(Math.PI * k));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,319 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Finger
|
||||
*
|
||||
* A Finger object is used by the Touch manager and represents a single finger on the touch screen.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Finger {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param {Phaser.Game} game.
|
||||
* @return {Phaser.Finger} This object.
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.active = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @property _game
|
||||
* @type Phaser.Game
|
||||
* @private
|
||||
**/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* An identification number for each touch point. When a touch point becomes active, it must be assigned an identifier that is distinct from any other active touch point. While the touch point remains active, all events that refer to it must assign it the same identifier.
|
||||
* @property identifier
|
||||
* @type Number
|
||||
*/
|
||||
public identifier: number;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property active
|
||||
* @type Boolean
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property point
|
||||
* @type Point
|
||||
**/
|
||||
public point: Point = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property circle
|
||||
* @type Circle
|
||||
**/
|
||||
public circle: Circle = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property withinGame
|
||||
* @type Boolean
|
||||
*/
|
||||
public withinGame: bool = false;
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset
|
||||
* @property clientX
|
||||
* @type Number
|
||||
*/
|
||||
public clientX: number = -1;
|
||||
|
||||
//
|
||||
/**
|
||||
* The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset
|
||||
* @property clientY
|
||||
* @type Number
|
||||
*/
|
||||
public clientY: number = -1;
|
||||
|
||||
//
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset
|
||||
* @property pageX
|
||||
* @type Number
|
||||
*/
|
||||
public pageX: number = -1;
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the viewport in pixels, including any scroll offset
|
||||
* @property pageY
|
||||
* @type Number
|
||||
*/
|
||||
public pageY: number = -1;
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the screen in pixels
|
||||
* @property screenX
|
||||
* @type Number
|
||||
*/
|
||||
public screenX: number = -1;
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the screen in pixels
|
||||
* @property screenY
|
||||
* @type Number
|
||||
*/
|
||||
public screenY: number = -1;
|
||||
|
||||
/**
|
||||
* The horizontal coordinate of point relative to the game element
|
||||
* @property x
|
||||
* @type Number
|
||||
*/
|
||||
public x: number = -1;
|
||||
|
||||
/**
|
||||
* The vertical coordinate of point relative to the game element
|
||||
* @property y
|
||||
* @type Number
|
||||
*/
|
||||
public y: number = -1;
|
||||
|
||||
/**
|
||||
* The Element on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element.
|
||||
* @property target
|
||||
* @type Any
|
||||
*/
|
||||
public target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property isDown
|
||||
* @type Boolean
|
||||
**/
|
||||
public isDown: bool = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property isUp
|
||||
* @type Boolean
|
||||
**/
|
||||
public isUp: bool = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property timeDown
|
||||
* @type Number
|
||||
**/
|
||||
public timeDown: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property duration
|
||||
* @type Number
|
||||
**/
|
||||
public duration: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property timeUp
|
||||
* @type Number
|
||||
**/
|
||||
public timeUp: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property justPressedRate
|
||||
* @type Number
|
||||
**/
|
||||
public justPressedRate: number = 200;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property justReleasedRate
|
||||
* @type Number
|
||||
**/
|
||||
public justReleasedRate: number = 200;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method start
|
||||
* @param {Any} event
|
||||
*/
|
||||
public start(event) {
|
||||
|
||||
this.identifier = event.identifier;
|
||||
this.target = event.target;
|
||||
|
||||
// populate geom objects
|
||||
if (this.point === null)
|
||||
{
|
||||
this.point = new Point();
|
||||
}
|
||||
|
||||
if (this.circle === null)
|
||||
{
|
||||
this.circle = new Circle(0, 0, 44);
|
||||
}
|
||||
|
||||
this.move(event);
|
||||
|
||||
this.active = true;
|
||||
this.withinGame = true;
|
||||
this.isDown = true;
|
||||
this.isUp = false;
|
||||
this.timeDown = this._game.time.now;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method move
|
||||
* @param {Any} event
|
||||
*/
|
||||
public move(event) {
|
||||
|
||||
this.clientX = event.clientX;
|
||||
this.clientY = event.clientY;
|
||||
this.pageX = event.pageX;
|
||||
this.pageY = event.pageY;
|
||||
this.screenX = event.screenX;
|
||||
this.screenY = event.screenY;
|
||||
|
||||
this.x = this.pageX - this._game.stage.offset.x;
|
||||
this.y = this.pageY - this._game.stage.offset.y;
|
||||
|
||||
this.point.setTo(this.x, this.y);
|
||||
this.circle.setTo(this.x, this.y, 44);
|
||||
|
||||
// Droppings history (used for gestures and motion tracking)
|
||||
|
||||
this.duration = this._game.time.now - this.timeDown;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method leave
|
||||
* @param {Any} event
|
||||
*/
|
||||
public leave(event) {
|
||||
|
||||
this.withinGame = false;
|
||||
this.move(event);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method stop
|
||||
* @param {Any} event
|
||||
*/
|
||||
public stop(event) {
|
||||
|
||||
this.active = false;
|
||||
this.withinGame = false;
|
||||
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = this._game.time.now;
|
||||
this.duration = this.timeUp - this.timeDown;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method justPressed
|
||||
* @param {Number} [duration].
|
||||
* @return {Boolean}
|
||||
*/
|
||||
public justPressed(duration?: number = this.justPressedRate): bool {
|
||||
|
||||
if (this.isDown === true && (this.timeDown + duration) > this._game.time.now)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method justReleased
|
||||
* @param {Number} [duration].
|
||||
* @return {Boolean}
|
||||
*/
|
||||
public justReleased(duration?: number = this.justReleasedRate): bool {
|
||||
|
||||
if (this.isUp === true && (this.timeUp + duration) > this._game.time.now)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the instance.
|
||||
**/
|
||||
public toString(): string {
|
||||
|
||||
return "[{Finger (identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="../../Signal.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Input
|
||||
*
|
||||
* A game specific Input manager that looks after the mouse, keyboard and touch objects. This is updated by the core game loop.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Input {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.mouse = new Mouse(this._game);
|
||||
this.keyboard = new Keyboard(this._game);
|
||||
this.touch = new Touch(this._game);
|
||||
|
||||
this.onDown = new Phaser.Signal();
|
||||
this.onUp = new Phaser.Signal();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
public mouse: Mouse;
|
||||
public keyboard: Keyboard;
|
||||
public touch: Touch;
|
||||
|
||||
public x: number = 0;
|
||||
public y: number = 0;
|
||||
|
||||
public scaleX: number = 1;
|
||||
public scaleY: number = 1;
|
||||
|
||||
public worldX: number = 0;
|
||||
public worldY: number = 0;
|
||||
|
||||
public onDown: Phaser.Signal;
|
||||
public onUp: Phaser.Signal;
|
||||
|
||||
public update() {
|
||||
|
||||
this.x = Math.round(this.x);
|
||||
this.y = Math.round(this.y);
|
||||
|
||||
this.worldX = this._game.camera.worldView.x + this.x;
|
||||
this.worldY = this._game.camera.worldView.y + this.y;
|
||||
|
||||
this.mouse.update();
|
||||
this.touch.update();
|
||||
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
this.mouse.reset();
|
||||
this.keyboard.reset();
|
||||
this.touch.reset();
|
||||
|
||||
}
|
||||
|
||||
public getWorldX(camera?: Camera = this._game.camera) {
|
||||
|
||||
return camera.worldView.x + this.x;
|
||||
|
||||
}
|
||||
|
||||
public getWorldY(camera?: Camera = this._game.camera) {
|
||||
|
||||
return camera.worldView.y + this.y;
|
||||
|
||||
}
|
||||
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Input', x, y);
|
||||
this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14);
|
||||
this._game.stage.context.fillText('World X: ' + this.worldX + ' World Y: ' + this.worldY, x, y + 28);
|
||||
this._game.stage.context.fillText('Scale X: ' + this.scaleX.toFixed(1) + ' Scale Y: ' + this.scaleY.toFixed(1), x, y + 42);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Mouse
|
||||
*
|
||||
* The Mouse class handles mouse interactions with the game and the resulting events.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Mouse {
|
||||
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.start();
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
|
||||
private _x: number = 0;
|
||||
private _y: number = 0;
|
||||
|
||||
public button: number;
|
||||
|
||||
public static LEFT_BUTTON: number = 0;
|
||||
public static MIDDLE_BUTTON: number = 1;
|
||||
public static RIGHT_BUTTON: number = 2;
|
||||
|
||||
public isDown: bool = false;
|
||||
public isUp: bool = true;
|
||||
public timeDown: number = 0;
|
||||
public duration: number = 0;
|
||||
public timeUp: number = 0;
|
||||
|
||||
public start() {
|
||||
|
||||
this._game.stage.canvas.addEventListener('mousedown', (event: MouseEvent) => this.onMouseDown(event), true);
|
||||
this._game.stage.canvas.addEventListener('mousemove', (event: MouseEvent) => this.onMouseMove(event), true);
|
||||
this._game.stage.canvas.addEventListener('mouseup', (event: MouseEvent) => this.onMouseUp(event), true);
|
||||
|
||||
}
|
||||
|
||||
public reset() {
|
||||
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
|
||||
}
|
||||
|
||||
public onMouseDown(event: MouseEvent) {
|
||||
|
||||
this.button = event.button;
|
||||
|
||||
this._x = event.clientX - this._game.stage.x;
|
||||
this._y = event.clientY - this._game.stage.y;
|
||||
|
||||
this._game.input.x = this._x * this._game.input.scaleX;
|
||||
this._game.input.y = this._y * this._game.input.scaleY;
|
||||
|
||||
this.isDown = true;
|
||||
this.isUp = false;
|
||||
this.timeDown = this._game.time.now;
|
||||
|
||||
this._game.input.onDown.dispatch(this._game.input.x, this._game.input.y, this.timeDown);
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
//this._game.input.x = this._x * this._game.input.scaleX;
|
||||
//this._game.input.y = this._y * this._game.input.scaleY;
|
||||
|
||||
if (this.isDown)
|
||||
{
|
||||
this.duration = this._game.time.now - this.timeDown;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public onMouseMove(event: MouseEvent) {
|
||||
|
||||
this.button = event.button;
|
||||
|
||||
this._x = event.clientX - this._game.stage.x;
|
||||
this._y = event.clientY - this._game.stage.y;
|
||||
|
||||
this._game.input.x = this._x * this._game.input.scaleX;
|
||||
this._game.input.y = this._y * this._game.input.scaleY;
|
||||
|
||||
}
|
||||
|
||||
public onMouseUp(event: MouseEvent) {
|
||||
|
||||
this.button = event.button;
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = this._game.time.now;
|
||||
this.duration = this.timeUp - this.timeDown;
|
||||
|
||||
this._x = event.clientX - this._game.stage.x;
|
||||
this._y = event.clientY - this._game.stage.y;
|
||||
|
||||
this._game.input.x = this._x * this._game.input.scaleX;
|
||||
this._game.input.y = this._y * this._game.input.scaleY;
|
||||
|
||||
this._game.input.onUp.dispatch(this._game.input.x, this._game.input.y, this.timeDown);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,451 +0,0 @@
|
||||
/// <reference path="../../Game.ts" />
|
||||
/// <reference path="Finger.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Touch
|
||||
*
|
||||
* The Touch class handles touch interactions with the game and the resulting Finger objects.
|
||||
* http://www.w3.org/TR/touch-events/
|
||||
* https://developer.mozilla.org/en-US/docs/DOM/TouchList
|
||||
* http://www.html5rocks.com/en/mobile/touchandmouse/
|
||||
* Note: Android 2.x only supports 1 touch event at once, no multi-touch
|
||||
*
|
||||
* @todo Try and resolve update lag in Chrome/Android
|
||||
* Gestures (pinch, zoom, swipe)
|
||||
* GameObject Touch
|
||||
* Touch point within GameObject
|
||||
* Input Zones (mouse and touch) - lock entities within them + axis aligned drags
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Touch {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param {Game} game.
|
||||
* @return {Touch} This object.
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.finger1 = new Finger(this._game);
|
||||
this.finger2 = new Finger(this._game);
|
||||
this.finger3 = new Finger(this._game);
|
||||
this.finger4 = new Finger(this._game);
|
||||
this.finger5 = new Finger(this._game);
|
||||
this.finger6 = new Finger(this._game);
|
||||
this.finger7 = new Finger(this._game);
|
||||
this.finger8 = new Finger(this._game);
|
||||
this.finger9 = new Finger(this._game);
|
||||
this.finger10 = new Finger(this._game);
|
||||
|
||||
this._fingers = [this.finger1, this.finger2, this.finger3, this.finger4, this.finger5, this.finger6, this.finger7, this.finger8, this.finger9, this.finger10];
|
||||
|
||||
this.touchDown = new Signal();
|
||||
this.touchUp = new Signal();
|
||||
|
||||
this.start();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @property _game
|
||||
* @type Game
|
||||
* @private
|
||||
**/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public x: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property y
|
||||
* @type Number
|
||||
**/
|
||||
public y: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property _fingers
|
||||
* @type Array
|
||||
* @private
|
||||
**/
|
||||
private _fingers: Finger[];
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger1
|
||||
* @type Finger
|
||||
**/
|
||||
public finger1: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger2
|
||||
* @type Finger
|
||||
**/
|
||||
public finger2: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger3
|
||||
* @type Finger
|
||||
**/
|
||||
public finger3: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger4
|
||||
* @type Finger
|
||||
**/
|
||||
public finger4: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger5
|
||||
* @type Finger
|
||||
**/
|
||||
public finger5: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger6
|
||||
* @type Finger
|
||||
**/
|
||||
public finger6: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger7
|
||||
* @type Finger
|
||||
**/
|
||||
public finger7: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger8
|
||||
* @type Finger
|
||||
**/
|
||||
public finger8: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger9
|
||||
* @type Finger
|
||||
**/
|
||||
public finger9: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property finger10
|
||||
* @type Finger
|
||||
**/
|
||||
public finger10: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property latestFinger
|
||||
* @type Finger
|
||||
**/
|
||||
public latestFinger: Finger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property isDown
|
||||
* @type Boolean
|
||||
**/
|
||||
public isDown: bool = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property isUp
|
||||
* @type Boolean
|
||||
**/
|
||||
public isUp: bool = true;
|
||||
|
||||
public touchDown: Signal;
|
||||
public touchUp: Signal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method start
|
||||
*/
|
||||
public start() {
|
||||
|
||||
this._game.stage.canvas.addEventListener('touchstart', (event) => this.onTouchStart(event), false);
|
||||
this._game.stage.canvas.addEventListener('touchmove', (event) => this.onTouchMove(event), false);
|
||||
this._game.stage.canvas.addEventListener('touchend', (event) => this.onTouchEnd(event), false);
|
||||
this._game.stage.canvas.addEventListener('touchenter', (event) => this.onTouchEnter(event), false);
|
||||
this._game.stage.canvas.addEventListener('touchleave', (event) => this.onTouchLeave(event), false);
|
||||
this._game.stage.canvas.addEventListener('touchcancel', (event) => this.onTouchCancel(event), false);
|
||||
|
||||
document.addEventListener('touchmove', (event) => this.consumeTouchMove(event), false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent iOS bounce-back (doesn't work?)
|
||||
* @method consumeTouchMove
|
||||
* @param {Any} event
|
||||
**/
|
||||
private consumeTouchMove(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method onTouchStart
|
||||
* @param {Any} event
|
||||
**/
|
||||
private onTouchStart(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// A list of all the touch points that BECAME active with the current event
|
||||
// https://developer.mozilla.org/en-US/docs/DOM/TouchList
|
||||
|
||||
// event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
|
||||
// event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
|
||||
// event.changedTouches = the touches that CHANGED in this event, not the total number of them
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
for (var f = 0; f < this._fingers.length; f++)
|
||||
{
|
||||
if (this._fingers[f].active === false)
|
||||
{
|
||||
this._fingers[f].start(event.changedTouches[i]);
|
||||
this.x = this._fingers[f].x;
|
||||
this.y = this._fingers[f].y;
|
||||
this._game.input.x = this.x * this._game.input.scaleX;
|
||||
this._game.input.y = this.y * this._game.input.scaleY;
|
||||
this.touchDown.dispatch(this._fingers[f].x, this._fingers[f].y, this._fingers[f].timeDown, this._fingers[f].timeUp, this._fingers[f].duration);
|
||||
this._game.input.onDown.dispatch(this._game.input.x, this._game.input.y, this._fingers[f].timeDown);
|
||||
this.isDown = true;
|
||||
this.isUp = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Doesn't appear to be supported by most browsers yet
|
||||
* @method onTouchCancel
|
||||
* @param {Any} event
|
||||
**/
|
||||
private onTouchCancel(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome)
|
||||
// http://www.w3.org/TR/touch-events/#dfn-touchcancel
|
||||
// event.changedTouches = the touches that CHANGED in this event, not the total number of them
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
for (var f = 0; f < this._fingers.length; f++)
|
||||
{
|
||||
if (this._fingers[f].identifier === event.changedTouches[i].identifier)
|
||||
{
|
||||
this._fingers[f].stop(event.changedTouches[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Doesn't appear to be supported by most browsers yet
|
||||
* @method onTouchEnter
|
||||
* @param {Any} event
|
||||
**/
|
||||
private onTouchEnter(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// For touch enter and leave its a list of the touch points that have entered or left the target
|
||||
|
||||
// event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
|
||||
// event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
|
||||
// event.changedTouches = the touches that CHANGED in this event, not the total number of them
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
for (var f = 0; f < this._fingers.length; f++)
|
||||
{
|
||||
if (this._fingers[f].active === false)
|
||||
{
|
||||
this._fingers[f].start(event.changedTouches[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Doesn't appear to be supported by most browsers yet
|
||||
* @method onTouchLeave
|
||||
* @param {Any} event
|
||||
**/
|
||||
private onTouchLeave(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// For touch enter and leave its a list of the touch points that have entered or left the target
|
||||
|
||||
// event.changedTouches = the touches that CHANGED in this event, not the total number of them
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
for (var f = 0; f < this._fingers.length; f++)
|
||||
{
|
||||
if (this._fingers[f].identifier === event.changedTouches[i].identifier)
|
||||
{
|
||||
this._fingers[f].leave(event.changedTouches[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method onTouchMove
|
||||
* @param {Any} event
|
||||
**/
|
||||
private onTouchMove(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
|
||||
// event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
|
||||
// event.changedTouches = the touches that CHANGED in this event, not the total number of them
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
for (var f = 0; f < this._fingers.length; f++)
|
||||
{
|
||||
if (this._fingers[f].identifier === event.changedTouches[i].identifier)
|
||||
{
|
||||
this._fingers[f].move(event.changedTouches[i]);
|
||||
this.x = this._fingers[f].x;
|
||||
this.y = this._fingers[f].y;
|
||||
this._game.input.x = this.x * this._game.input.scaleX;
|
||||
this._game.input.y = this.y * this._game.input.scaleY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method onTouchEnd
|
||||
* @param {Any} event
|
||||
**/
|
||||
private onTouchEnd(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// For touch end its a list of the touch points that have been removed from the surface
|
||||
// https://developer.mozilla.org/en-US/docs/DOM/TouchList
|
||||
|
||||
// event.changedTouches = the touches that CHANGED in this event, not the total number of them
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
for (var f = 0; f < this._fingers.length; f++)
|
||||
{
|
||||
if (this._fingers[f].identifier === event.changedTouches[i].identifier)
|
||||
{
|
||||
this._fingers[f].stop(event.changedTouches[i]);
|
||||
this.x = this._fingers[f].x;
|
||||
this.y = this._fingers[f].y;
|
||||
this._game.input.x = this.x * this._game.input.scaleX;
|
||||
this._game.input.y = this.y * this._game.input.scaleY;
|
||||
this.touchUp.dispatch(this._fingers[f].x, this._fingers[f].y, this._fingers[f].timeDown, this._fingers[f].timeUp, this._fingers[f].duration);
|
||||
this._game.input.onUp.dispatch(this._game.input.x, this._game.input.y, this._fingers[f].timeUp);
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method calculateDistance
|
||||
* @param {Finger} finger1
|
||||
* @param {Finger} finger2
|
||||
**/
|
||||
public calculateDistance(finger1: Finger, finger2: Finger) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method calculateAngle
|
||||
* @param {Finger} finger1
|
||||
* @param {Finger} finger2
|
||||
**/
|
||||
public calculateAngle(finger1: Finger, finger2: Finger) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method checkOverlap
|
||||
* @param {Finger} finger1
|
||||
* @param {Finger} finger2
|
||||
**/
|
||||
public checkOverlap(finger1: Finger, finger2: Finger) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method update
|
||||
*/
|
||||
public update() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method stop
|
||||
*/
|
||||
public stop() {
|
||||
|
||||
//this._domElement.addEventListener('touchstart', (event) => this.onTouchStart(event), false);
|
||||
//this._domElement.addEventListener('touchmove', (event) => this.onTouchMove(event), false);
|
||||
//this._domElement.addEventListener('touchend', (event) => this.onTouchEnd(event), false);
|
||||
//this._domElement.addEventListener('touchenter', (event) => this.onTouchEnter(event), false);
|
||||
//this._domElement.addEventListener('touchleave', (event) => this.onTouchLeave(event), false);
|
||||
//this._domElement.addEventListener('touchcancel', (event) => this.onTouchCancel(event), false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @method reset
|
||||
**/
|
||||
public reset() {
|
||||
|
||||
this.isDown = false;
|
||||
this.isUp = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,230 +1,451 @@
|
||||
Phaser
|
||||
======
|
||||

|
||||
|
||||
Version 0.9.2
|
||||
Phaser 1.1.4
|
||||
============
|
||||
|
||||
20th April 2013
|
||||
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering.
|
||||
|
||||
Version: 1.1.4 "Kandor" - Released: February 5th 2014
|
||||
|
||||
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
|
||||
|
||||
Phaser is a 2D JavaScript/TypeScript HTML5 Game Framework based heavily on [Flixel](http://www.flixel.org).
|
||||
* View the [Official Website](http://phaser.io)
|
||||
* Follow on [Twitter](https://twitter.com/photonstorm)
|
||||
* Join the [Forum](http://www.html5gamedevs.com/forum/14-phaser/)
|
||||
* Try out 220+ [Phaser Examples](http://examples.phaser.io)
|
||||
* Read the [documentation online](http://docs.phaser.io)
|
||||
|
||||
Follow us on [twitter](https://twitter.com/photonstorm) and our [blog](http://www.photonstorm.com) for development updates.
|
||||
[Subscribe to our new Phaser Newsletter](https://confirmsubscription.com/h/r/369DE48E3E86AF1E). We'll email you when new versions are released as well as send you our regular Phaser game making magazine.
|
||||
|
||||
For support post to the Phaser board on the [HTML5 Game Devs forum](http://www.html5gamedevs.com/forum/14-phaser/)
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
|
||||
Welcome to Phaser
|
||||
-----------------
|
||||
|
||||
As you may know we had planned to release 1.1.4 at the end of 2013. For various reasons this didn't quite happen, but we're happy to announce it's finally out! There have been some dramatic changes internally, and if you make use of either the physics systems or tilemaps then you are going to need to update your code. Hopefully only a little bit, but there have been a number of core API changes which we detail below. There are also a host of new features, the headliners being:
|
||||
|
||||
* New Physics system. Uses SAT.js internally so physics bodies can now be rectangles, circles or polygons and support rotation.
|
||||
* New Tilemap system. Brand new collision system for tiles, much more advanced layer handling, tile properties, multiple tilesets of layer and more.
|
||||
* New Timer. This handy new class lets you create timed events easily.
|
||||
* Your Game can now be configured from an external configuration object.
|
||||
* Over 150 new features and updates and over 30 reported bug fixes.
|
||||
|
||||
This release also brings the TypeScript definitions file as bang up to date as possible. There are still a few areas that need looking at, but with your help hopefully we can iron those final few bits out and have a 100% accruate defs file on offer.
|
||||
|
||||
There is a new Contributors Guide which we'd urge you to follow if you wish to help with Phaser development, and we've updated the doc files and added lots more details into key areas. The Examples have grown too! Now over 220 of them including several great ones from the community.
|
||||
|
||||
We're going to settle on this build for a short while as we do some quick iteration bug fixing, so expect to see some small point releases very soon that do nothing but address any issues you may find. But in parallel to this we are also now rebuilding our core to bring it in-line with the latest version of Pixi.js, which has had some dramatic changes under the hood, changes will impact a lot of what Phaser does internally. But the changes are all for the better and once we upgrade Pixi you'll have a significantly faster renderer and a smaller codebase too, as we do away with stacks of linked list code :)
|
||||
|
||||
As always we offer a heart-felt "Thank you!" to everyone who has encouraged us along the way. To those of you who worked with Phaser during its various incarnations. The number of games being released that were made with Phaser is staggering and we really love to see how you use it! You are our heroes. It's your kind words and enthusiasm that has keeps us going.
|
||||
|
||||
Phaser is everything we ever wanted from an HTML5 game framework. It powers all of our client work in build today and remains our single most important product, and we've still only just scratched the surface of what we have planned for it.
|
||||
|
||||

|
||||
|
||||
|
||||
Getting Started Guides
|
||||
----------------------
|
||||
|
||||
We have a new [Getting Started Guide](http://phaser.io/getting-started-js.php) which covers all you need to begin developing games with Phaser. From setting up a web server to picking an IDE. If you're new to HTML5 game development, or are coming from another language like AS3, then we recommend starting there.
|
||||
|
||||
There is a comprehensive [How to Learn Phaser](http://gamedevelopment.tutsplus.com/articles/how-to-learn-the-phaser-html5-game-engine--gamedev-13643) guide on the GameDevTuts+ site which is a great place to learn where to find tutorials, examples and support.
|
||||
|
||||
There is also an [un-official Getting Started Guide](http://www.antonoffplus.com/coding-an-html5-game-for-30-minutes-or-an-introduction-to-the-phaser-framework).
|
||||
|
||||

|
||||
|
||||
Change Log
|
||||
----------
|
||||
|
||||
V0.9.2
|
||||
Version 1.1.4 - "Kandor" - February 5th 2014
|
||||
|
||||
Fixed issue with create not being called if there was an empty init method.<br />
|
||||
Added ability to flip a sprite (Sprite.flipped = true) + a test case for it.<br />
|
||||
Added ability to restart a sprite animation.<br />
|
||||
Sprite animations don't restart if you call play on them when they are already running.<br />
|
||||
Significant API changes:
|
||||
|
||||
V0.9.1
|
||||
* Loader.tileset has been removed as it's no longer required, this was as part of the Tilemap system overhaul.
|
||||
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
|
||||
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
|
||||
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.
|
||||
* Button.forceOut default value has changed from true to false, so Buttons will revert to an Up state (if set) when pressed and released.
|
||||
* The way the collision process callback works has changed significantly and now works as originally intended.
|
||||
* The World level quadtree is no longer created, they are now built and ripped down each time you collide a Group, this helps collision accuracy.
|
||||
* A SAT system has been integrated for Body collision and separation.
|
||||
* Bodies are no longer added to a world quadtree, so have had all of their quadtree properties removed such as skipQuadtree, quadTreeIndex, etc.
|
||||
* Body.drag has been removed. Please use the new Body.linearDamping value instead (which is a number value, not a Point object)
|
||||
* Body.embedded and Body.wasTouching have been removed as they are no longer required.
|
||||
* Body.customSeparateX/Y have been removed as you should now use Body.customSeparateCallback.
|
||||
* Body.maxVelocity defaults have been removed from 10,000 to 2000.
|
||||
* Body.customSeparateCallback allows you to set your own callback when two Bodies need to separate rather than using the built-in method.
|
||||
* Body.collideCallback allows you to set a callback that is fired whenever the Body is hit on any of its active faces.
|
||||
* Body.allowCollision has been renamed to Body.checkCollision.
|
||||
* Body.rebound is a boolean that controls if a body will exchange velocity on collision. Set to false to allow it to be 'pushed' (see new examples).
|
||||
* Removed Body.deltaAbsX and deltaAbsY as they are no longer used internally.
|
||||
* Body.screenX and screenY moved to getters, no longer calculated every frame.
|
||||
* ArcadePhysics now has setBounds and setBoundsToWorld, and you can specify which walls are created or not (left, right, up, down)
|
||||
* Removed: Debug.renderSpriteTouching, Debug.renderLocalTransformInfo, Debug.renderWorldTransformInfo, Debug.renderSpriteCollision and Debug.dumpLinkedList.
|
||||
* Body.setSize has been removed. Please use Body.setCircle, setRectangle or setPolygon instead.
|
||||
|
||||
Added the new align property to GameObjects that controls placement when rendering.<br />
|
||||
Added an align example to the Sprites test group (click the mouse to change alignment position)<br />
|
||||
Added a new MicroPoint class. Same as Point but much smaller / less functions, updated GameObject to use it.<br />
|
||||
Completely rebuilt the Rectangle class to use MicroPoints and store the values of the 9 points around the edges, to be used
|
||||
for new collision system.<br />
|
||||
Game.Input now has 2 signals you can subscribe to for down/up events, see the Sprite align example for use.<br />
|
||||
Updated the States examples to bring in-line with 0.9 release.
|
||||
|
||||
V0.9
|
||||
New features:
|
||||
|
||||
Large refactoring. Everything now lives inside the Phaser module, so all code and all tests have been updated to reflect this. Makes coding a tiny bit
|
||||
more verbose but stops the framework from globbing up the global namespace. Also should make code-insight work in WebStorm and similar editors.<br />
|
||||
Added the new GeomSprite object. This is a sprite that uses a geometry class for display (Circle, Rectangle, Point, Line). It's extremely flexible!<br />
|
||||
Added Geometry intersection results objects.<br />
|
||||
Added new Collision class and moved some functions there. Contains all the Game Object and Geometry Intersection methods.<br />
|
||||
Can now create a sprite animation based on frame names rather than indexes. Useful when you've an animation inside a texture atlas. Added test to show.<br />
|
||||
Added addKeyCapture(), removeKeyCapture() and clearCaptures() to Input.Keyboard. Calls event.preventDefault() on any keycode set to capture, allowing you to avoid page scrolling when using the cursor keys in a game for example.<br />
|
||||
Added new Motion class which contains lots of handy functions like 'moveTowardsObject', 'velocityFromAngle' and more.<br />
|
||||
Tween Manager added. You can now create tweens via Game.createTween (or for more control game.tweens). All the usual suspects are here: Bounce, Elastic, Quintic, etc and it's hooked into the core game clock, so if your game pauses and resumes your tweens adjust accordingly.
|
||||
* Phaser.Timer is now feature complete and fully documented. You can create Phaser.TimerEvents on a Timer and lots of new examples have been provided.
|
||||
* Gamepad API support has been added with lots of new examples (thanks Karl Macklin)
|
||||
* Phaser.Game constructor can now be passed a single object containing all of your game settings + Stage settings. Useful for advanced configurations.
|
||||
* The width/height given to Phaser.Game can now be percentages, i.e. "100%" will set the width to the maximum window innerWidth.
|
||||
* Added a stage.fullScreenScaleMode property to determine scaling when fullscreen (thanks oysterCrusher)
|
||||
* Added support for margin and spacing around a frame in Loader.spritesheet.
|
||||
* Added Device.vibration to check if the Vibration API is available or not.
|
||||
* Added Device.trident and Device.tridentVersion for testing IE11.
|
||||
* Added Device.silk for detecting a Kindle Fire and updated desktop OS check to exclude Kindles (thanks LuckieLordie)
|
||||
* TilemapLayers now have debug and debugAlpha values, this turns on the drawing of the collision edges (very handy for debugging, as the name implies!)
|
||||
* Tweens have a new event: onLoop.
|
||||
* You can now load any binary file via the Loader: game.load.binary(key, url, callback) - the optional callback allows for post-load processing before entering the Cache.
|
||||
* Group.set will let you deep set a new propery on a single child of the Group.
|
||||
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
|
||||
* Added Ejecta detection to Device (thanks endel)
|
||||
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value.
|
||||
* Buttons now properly use their upFrame if set.
|
||||
* InputHandler now has snapOffsetX and snapOffsetY properties so your snap grid doesn't have to be 0,0 aligned (thanks srmeier)
|
||||
* Loader.progressFloat contains the actual non-rounded progress value, where-as Loader.progress contains a rounded value. Use progressFloat if you've > 100 files to load.
|
||||
* Groups can now be added to other Groups as children via group.add() and group.addAt()
|
||||
* Groups now have an 'alive' property, which can be useful when iterating through child groups with functions like forEachAlive.
|
||||
* Added a new Project Template "Full Screen Mobile" which you can find in the resources folder. Contains html / css / layout needed for a deployed Phaser game.
|
||||
* Body.speed - the current speed of the body.
|
||||
* Body.angle - the current angle the Body is facing based on its velocity. This is not the same as the Sprite angle that may own the body.
|
||||
* Body.linearDamping - This now replaces Body.drag and provides for a much smoother damping (friction) experience.
|
||||
* Body.minBounceVelocity - If a Body has bounce set, this threshold controls if it should rebound or not. Use it to stop 'jittering' on bounds/tiles with super-low velocities.
|
||||
* QuadTree.populate - you can pass it a Group and it'll automatically insert all of the children ready for inspection.
|
||||
* Input.setMoveCallback allows you to set a callback that will be fired each time the activePointer receives a DOM move event.
|
||||
* Math.distancePow(x1,y1,x2,y2,power) returns the distance between two coordinates at the given power.
|
||||
* Physics.collide now supports the 2nd parameter as an array, for when you want to collide an object against a number of sprites that aren't all in the same Group.
|
||||
* Physics.overlap now supports the 2nd parameter as an array, for when you want to overlap test an object against a number of sprites that aren't all in the same Group.
|
||||
* Math.reverseAngle - reverses an angle (in radians).
|
||||
* Math.normalizeAngle - normalises an angle, now in radians only.
|
||||
* Math.normalizeLatitude - Normalizes a latitude to the [-90,90] range.
|
||||
* Math.normalizeLongitude - Normalizes a longitude to the [-180,180] range.
|
||||
* Phaser.Line added to the geometry classes, with full point on line/segment and intersection tests (see new examples)
|
||||
* Phaser.CANVAS_PX_ROUND is a boolean. If 'true' the Canvas renderer will Math.floor() all coordinates before drawImage, stopping pixel interpolation. Defaults to false.
|
||||
* Phaser.CANVAS_CLEAR_RECT is a boolean. If 'true' (the default) it will context.clearRect() every frame. If false this is skipped (useful if you know you don't need it)
|
||||
* Collision now works between Sprites positioned via sprite.x/y, sprite.body.x/y or sprite.body.velocity.
|
||||
* If you are tweening a sprite and still want physics collision, set `sprite.body.moves = false` otherwise it will fight against the tween motion.
|
||||
* Game.enableStep will enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?), very useful for debugging!
|
||||
* Game.disableStep turns core update loop stepping off.
|
||||
* Debug.renderPhysicsBody(body, color) is extremely useful for debugging the new physics bodies. Will draw the outline + points in the color given.
|
||||
* Debug.renderBodyInfo(sprite, x, y, color) will display lots of Sprite body data.
|
||||
* Sprite.events.onBeginContact will be fired when a Body makes contact with another Body. Once contact is over an onEndContact event will be dispatched.
|
||||
|
||||
V0.8
|
||||
|
||||
Added ability to set Sprite frame by name (sprite.frameName), useful when you've loaded a Texture Atlas with filename values set rather than using frame indexes.<br />
|
||||
Updated texture atlas 4 demo to show this.<br />
|
||||
Fixed a bug that would cause a run-time error if you tried to create a sprite using an invalid texture key.<br />
|
||||
Added in DynamicTexture support and a test case for it.<br />
|
||||
New Examples:
|
||||
|
||||
V0.7
|
||||
* Physics - Bounce by Patrick OReilly.
|
||||
* Physics - Bounce with gravity by Patrick OReilly.
|
||||
* Physics - Bounce accelerator (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Bounce knock (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Snake (use the keyboard to control the snake like creature) by Patrick OReilly and Richard Davey.
|
||||
* Physics - Launcher - Angry Birds style ball launcher demo by Patrick OReilly.
|
||||
* Physics - Launcher Follow - throw the sprite anywhere in the world by Patrick OReilly.
|
||||
* Physics - Launcher Follow World - an advanced version of the Launcher Follow example by Patrick OReilly.
|
||||
* Input - Touch Joystick example showing how to use the clay.io virtual game controller (thanks gabehollombe)
|
||||
* Games - Matching Pairs by Patrick OReilly.
|
||||
* Games - Simon Says by Patrick OReilly.
|
||||
* Tweens - Example showing how to use the tween events, onStart, onLoop and onComplete.
|
||||
* Display - Pixi Render Texture. A Phaser conversion of the Pixi.js Render Texture example.
|
||||
* Input - 5 new examples showing how to use the Gamepad API (thanks Karl Macklin)
|
||||
* Animation - Group Creation, showing how to create animations across all Group children in one call.
|
||||
* Particles - Rain by Jens Anders Bakke.
|
||||
* Particles - Snow by Jens Anders Bakke.
|
||||
* Groups - Nested Groups - showing how to embed one Group into another Group.
|
||||
* Time - Lots of new examples showing how to use the updated Phaser.Timer class.
|
||||
|
||||
Renamed FullScreen to StageScaleMode as it's much more fitting. Tested across Android and iOS with the various scale modes.<br />
|
||||
Added in world x/y coordinates to the input class, and the ability to get world x/y input coordinates from any Camera.<br />
|
||||
Added the RandomDataGenerator for seeded random number generation.<br />
|
||||
Setting the game world size now resizes the default camera (optional bool flag)
|
||||
|
||||
V0.6
|
||||
Updates:
|
||||
|
||||
Added in Touch support for mobile devices (and desktops that enable it) and populated x/y coords in Input with common values from touch and mouse.<br />
|
||||
Added new Circle geometry class (used by Touch) and moved them into a Geom folder.<br />
|
||||
Added in Device class for device inspection.<br />
|
||||
Added FullScreen class to enable full-screen support on mobile devices (scrolls URL bar out of the way on iOS and Android)
|
||||
* Updated to latest Pixi.js dev branch build (pre 1.4 release)
|
||||
* When a Sprite is destroyed any active filters are removed at the same time.
|
||||
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
|
||||
* Phaser.Canvas.create updated so it can be given an ID as the 3rd parameter (can also be set via new Game configuration object).
|
||||
* Updated display/fullscreen example to reflect new full screen change.
|
||||
* Loads of updates to the TypeScript definitions files - games fully compile now and lots of missing classes added :) (thanks Niondir)
|
||||
* Removed 'null parent' check from Group constructor. Will parent to game.world only if parent value is undefined.
|
||||
* The tutorials have now been translated into Spanish - thanks feiss :)
|
||||
* separateY updated to re-implement the 'riding platforms' special condition (thanks cocoademon)
|
||||
* SoundManager.onSoundDecode now dispatches the key followed by the sound object, also now dispatched by the Cache when doing an auto-decode on load.
|
||||
* Switch method of using trimmed sprites to support scaling and rotation (thanks cocoademon)
|
||||
* Most of the GameObjectFactory functions now have a group parameter, so you can do: game.add.sprite(x, y, frame, frameName, group) rather than defaulting to the World group.
|
||||
* Group.countLiving and countDead used to return -1 if the Group was empty, but now return 0.
|
||||
* Text can now be fixedToCamera, updated world/fixed to camera example to show this.
|
||||
* ArcadePhysics.overlap and collide now recognise TileSprites in the collision checks.
|
||||
* Lots of documentation fixes in the Tween class.
|
||||
* Tweens fire an onLoop event if they are set to repeat. onComplete is now only fired for the final repeat (or never if the repeat is infinite)
|
||||
* Pointer used to un-pause a paused game every time it was clicked/touched (this avoided some rogue browser plugins). Now only happens if Stage.disableVisibilityChange is true.
|
||||
* Input doesn't set the cursor to default if it's already set to none.
|
||||
* You can now collide a group against itself. This will check all children against each other, but not themselves (thanks cocoademon)
|
||||
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
|
||||
* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata)
|
||||
* Group.destroy has a new parameter: destroyChildren (boolean) which will optionally call the destroy method of all Group children.
|
||||
* Button.clearFrames method has been added.
|
||||
* Device.quirksMode is a boolean that informs you if the page is in strict (false) or quirks (true) mode.
|
||||
* Canvas.getOffset now runs a strict/quirks check and uses document.documentElement when calculating scrollTop and scrollLeft to avoid Chrome console warnings.
|
||||
* The Time class now has its own Phaser.Timer which you can access through game.time.events. See the new Timer examples to show how to use them.
|
||||
* Added StateManager.getCurrentState to return the currently running State object (thanks Niondir)
|
||||
* Removed the console.log redirect from Utils as it was messing with Firefox.
|
||||
* Body.acceleration is now much smoother and less eratic at high speeds.
|
||||
* Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system.
|
||||
* Removed ArcadePhysics.preUpdate and postUpdate as neither are needed any more.
|
||||
* Body.bottom and Body.right are no longer rounded, so will give accurate sub-pixel values.
|
||||
* Fixed lots of documentation in the Emitter class.
|
||||
* The delta timer value used for physics calculations has had its cap limit modified from 1.0 to 0.05 in line with the core updates.
|
||||
* Phaser.Math.min enhanced so you can now pass in either an array of numbers or lots of numbers as parameters to get the lowest.
|
||||
* Phaser.Math.max added as the opposite of Math.min.
|
||||
* Phaser.Math.minProperty and maxProperty added. Like Math.min/max but can be given a property an an array or list of objects to inspect.
|
||||
* Added 'full' paramter to Body.reset, allowing you to control if motion or all data is reset or not.
|
||||
* Exposed Group.pivot and Sprite.pivot to allow you to directly set the pivot points for rotation.
|
||||
* Swapped to using the native and faster Array.isArray check.
|
||||
* Added callback context parameter to Tween.onUpdateCallback(callback, context) to avoid having to bind or create anonymous functions.
|
||||
* Updated TweenManager.removeAll so it flags all tweens as pendingDelete rather than nuking the array, to avoid tween callback array size errors (thanks DarkDev)
|
||||
|
||||
V0.5
|
||||
|
||||
Initial release
|
||||
Bug Fixes:
|
||||
|
||||
* Cache.getImageKeys returned __missing in the array, now excluded.
|
||||
* Fixed Group.scale so you can now scale a Group directly.
|
||||
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
|
||||
* Moved 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
|
||||
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group has no children.
|
||||
* Switch Camera.setBoundsToWorld to match world.bounds instead of world (thanks cocoademon)
|
||||
* Fixed an issue where passing null as the Group parent wouldn't set it to game.world as it should have (thanks tito100)
|
||||
* Fixed Pixi bug (#425) incorrect width property for multi-line BitmapText (thanks jcd-as)
|
||||
* Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma)
|
||||
* Sprites that are fixedToCamera can now be input dragged regardless of world position (thanks RafaelOliveira)
|
||||
* RenderTexture now displays correctly in Canvas games.
|
||||
* Canvas.addToDOM is now more robust when applying the overflowHidden style.
|
||||
* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital)
|
||||
* Patched desyrel.xml so it doesn't contain any zero width/height characters, as they broke Firefox 25.
|
||||
* Cache.addSound now implements a locked attribute (thanks haden)
|
||||
* Sound now checks for CocoonJS during playback to avoid readyState clash (thanks haden)
|
||||
* Buttons now clear previously set frames correctly if you call setFrames.
|
||||
* Sounds will now loop correctly if they are paused and resumed (thanks haden)
|
||||
* InputHandler.checkBoundsRect and checkBoundsSprite now take into account if the Sprite is fixedToCamera or not.
|
||||
* Removed the frame property from TileSprites as it cannot use them, it tiles the whole image only, not just a section of it.
|
||||
* Fixed WebGLRenderer updateGraphics bug (thanks theadam)
|
||||
* Removed duplicate Timer.create line (thanks hstolte)
|
||||
* Fixed issue with the camera being slightly out of sync with 'fixedToCamera' sprites.
|
||||
* 1px camera jitter issue fixed where map is same size, or smaller than the game size.
|
||||
|
||||
|
||||
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||
|
||||
|
||||
How to Build
|
||||
------------
|
||||
|
||||
We provide a fully compiled version of Phaser in the `build` directory, in both plain and minified formats.
|
||||
|
||||
We also provide a Grunt script that will build Phaser from source along with all the examples.
|
||||
|
||||
Run `grunt` in the phaser folder for a list of command-line options.
|
||||
|
||||
|
||||
Koding
|
||||
------
|
||||
|
||||
You can [][koding] and then start editing and previewing code right away using their web based VM development system.
|
||||
|
||||
|
||||
Bower
|
||||
-----
|
||||
|
||||
If you use bowser you can install phaser with:
|
||||
|
||||
`bower install phaser`
|
||||
|
||||
Nice and easy :)
|
||||
|
||||

|
||||
|
||||
|
||||
CDNJS
|
||||
-----
|
||||
|
||||
Thanks to a community member Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html:
|
||||
|
||||
`http://cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js`
|
||||
|
||||
Or if you prefer you can leave the protocol off, so it works via http and https:
|
||||
|
||||
`//cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js`
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Games created with Phaser require a modern web browser that supports the canvas tag. This includes Internet Explorer 9+, Firefox, Chrome, Safari and Opera. It also works on mobile web browsers including stock Android 2.x browser and above and iOS5 Mobile Safari and above.
|
||||
|
||||
For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/). We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you.
|
||||
For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/) using the provided TypeScript definitions file. We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you.
|
||||
|
||||
Phaser is 321 KB minified and 72 KB gzipped.
|
||||
|
||||
|
||||
Learn By Example
|
||||
----------------
|
||||
|
||||
Phaser comes with an ever growing suite of Examples. Personally I feel that we learn better by looking at small refined code examples, so we created over 200 of them and create new ones to test every new feature added. Inside the `examples` folder you'll find the current set. If you write a particularly good example then please send it to us.
|
||||
|
||||
The examples need to be run through a local web server (in order to avoid file access permission errors from your browser). You can use your own web server, or start the included web server using grunt.
|
||||
|
||||
Using a locally installed web server browse to the examples folder:
|
||||
|
||||
examples/index.html
|
||||
|
||||
Alternatively in order to start the included web server, after you've cloned the repo, run `npm install` to install all dependencies, then `grunt connect` to start a local server. After running this command you should be able to access your local webserver at `http://127.0.0.1:8000`. Then browse to the examples folder: `http://127.0.0.1:8000/examples/index.html`
|
||||
|
||||
There is a new 'Side View' example viewer as well. This loads all the examples into a left-hand frame for faster navigation.
|
||||
|
||||
You can also browse all [Phaser Examples](http://gametest.mobi/phaser/) online.
|
||||
|
||||
Phaser is 147KB minified and just 30KB gzipped (sizes accurate as of version 0.7)
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Phaser was born from a cross-polination of the AS3 Flixel game library and our own internal HTML5 game framework. The objective was to allow you to make games _really_ quickly and remove some of the speed barriers HTML5 puts in your way.
|
||||
**WebGL & Canvas**
|
||||
|
||||
Phaser fully or partially supports the following features. This list is growing constantly and we are aware there are still a number of essential features missing:
|
||||
Phaser uses both a Canvas and WebGL renderer internally and can automatically swap between them based on browser support. This allows for lightning fast rendering across Desktop and Mobile. When running under WebGL Phaser now supports shaders, allowing for some incredible in-game effects. Phaser uses and contributes towards the excellent Pixi.js library for rendering.
|
||||
|
||||
* Asset Loading<br />
|
||||
**Preloader**
|
||||
|
||||
Images, Sprite Sheets, Texture Packer Data, JSON, Text Files, Audio File.
|
||||
We've made the loading of assets as simple as one line of code. Images, Sounds, Sprite Sheets, Tilemaps, JSON data, XML and JavaScrtip files - all parsed and handled automatically, ready for use in game and stored in a global Cache for Sprites to share.
|
||||
|
||||
* Cameras<br />
|
||||
**Physics**
|
||||
|
||||
Multiple world cameras, camera scale, zoom, rotation, deadzones and Sprite following.
|
||||
Phaser ships with our Arcade Physics system. A SAT based collision and physics library perfect for low-powered devices and fast collision response. Control velocity, acceleration, bounce, damping and full collision and separation control. As of version 1.1.4 we now support rectangles, circles and polygon collision with full rotation.
|
||||
|
||||
* Sprites<br />
|
||||
**Sprites**
|
||||
|
||||
All sprites have physics properties including velocity, acceleration, bounce and drag.
|
||||
ScrollFactor allows them to re-act to cameras at different rates.
|
||||
Sprites are the life-blood of your game. Position them, tween them, rotate them, scale them, animate them, collide them, paint them onto custom textures and so much more!
|
||||
Sprites also have full Input support: click them, touch them, drag them around, snap them - even pixel perfect click detection if needed.
|
||||
|
||||
* Groups<br />
|
||||
**Groups**
|
||||
|
||||
Group sprites together for collision checks, visibility toggling and function iteration.
|
||||
Group bundles of Sprites together for easy pooling and recycling, avoiding constant object creation. Groups can also be collided: for example a "Bullets" group checking for collision against the "Aliens" group, with a custom collision callback to handle the outcome.
|
||||
|
||||
* Animation<br />
|
||||
**Animation**
|
||||
|
||||
Sprites can be animated by a sprite sheet or Texture Atlas (JSON Array format supported).
|
||||
Animation playback controls, looping, fps based timer and custom frames.
|
||||
Phaser supports classic Sprite Sheets with a fixed frame size, Texture Packer and Flash CS6/CC JSON files (both Hash and Array formats) and Starling XML files. All of these can be used to easily create animation for Sprites.
|
||||
|
||||
* Collision<br />
|
||||
**Particles**
|
||||
|
||||
A QuadTree based Sprite to Sprite, Sprite to Group or Group to Group collision system.
|
||||
An Arcade Particle system is built-in, which allows you to create fun particle effects easily. Create explosions or constant streams for effects like rain or fire. Or attach the Emitter to a Sprite for a jet trail.
|
||||
|
||||
* Particles<br />
|
||||
**Camera**
|
||||
|
||||
An Emitter can emit Sprites in a burst or at a constant rate, setting physics properties.
|
||||
Phaser has a built-in Game World. Objects can be placed anywhere within the world and you've got access to a powerful Camera to look into that world. Pan around and follow Sprites with ease.
|
||||
|
||||
* Input<br />
|
||||
**Input**
|
||||
|
||||
Keyboard, Mouse and Touch handling supported (MSPointer events coming soon)
|
||||
Talk to a Phaser.Pointer and it doesn't matter if the input came from a touch-screen or mouse, it can even change mid-game without dropping a beat. Multi-touch, Mouse, Keyboard and lots of useful functions allow you to code custom gesture recognition.
|
||||
|
||||
* Stage<br />
|
||||
**Sound**
|
||||
|
||||
Easily change properties about your game via the stage, such as background color, position, size and scale.
|
||||
Phaser supports both Web Audio and legacy HTML Audio. It automatically handles mobile device locking, easy Audio Sprite creation, looping, streaming and volume. We know how much of a pain dealing with audio on mobile is, so we did our best to resolve that!
|
||||
|
||||
* World<br />
|
||||
**Tilemaps**
|
||||
|
||||
The game world can be any size and Sprites and collision happens within it.
|
||||
Phaser can load, render and collide with a tilemap with just a couple of lines of code. We support CSV and Tiled map data formats with multiple tile layers. There are lots of powerful tile manipulation functions: swap tiles, replace them, delete them, add them and update the map in realtime.
|
||||
|
||||
* Sound<br />
|
||||
**Device Scaling**
|
||||
|
||||
Currently uses WebAudio for playback. A lot more work needs to be done in this area.
|
||||
Phaser has a built-in Scale Manager which allows you to scale your game to fit any size screen. Control aspect ratios, minimum and maximum scales and full-screen support.
|
||||
|
||||
* State Management<br />
|
||||
**Plugin system**
|
||||
|
||||
For larger games it's useful to break your game down into States, i.e. MainMenu, Level1, GameOver, etc.
|
||||
The state manager makes swapping states easy, but the use of a state is completely optional.
|
||||
We are trying hard to keep the core of Phaser limited to only essential classes, so we built a smart Plugin system to handle everything else. Create your own plugins easily and share them with the community.
|
||||
|
||||
* Cache<br />
|
||||
**Mobile Browser**
|
||||
|
||||
All loaded resources are stored in an easy to access cache, which can be cleared between State changes
|
||||
or persist through-out the whole game.
|
||||
Phaser was built specifically for Mobile web browsers. Of course it works blazingly fast on Desktop too, but unlike lots of frameworks mobile was our main focus. If it doesn't perform well on mobile then we don't add it into the Core.
|
||||
|
||||
* Tilemaps<br />
|
||||
**Developer Support**
|
||||
|
||||
Support for CSV and Tiled JSON format tile maps is implemented but currently limited.
|
||||
We use Phaser every day on our many client projects. As a result it's constantly evolving and improving and we jump on bugs and pull requests quickly. This is a living, breathing framework maintained by a commercial company with custom feature development and support packages available. We live and breathe HTML5 games.
|
||||
|
||||
* Game Scaling<br />
|
||||
**Battle Tested**
|
||||
|
||||
Game scaling under your control. Removes URL/status bar on mobile (iOS and Android) and allows proportional scaling, fixed size and orientation checks.
|
||||
Although Phaser 1.0 is a brand new release it is born from years of experience building some of the biggest mobile HTML5 games out there. We're not saying it is 100% bug free, but we use it for our client work every day, so issues get resolved <em>fast</em> and we stay on-top of the changing browser landscape.
|
||||
|
||||

|
||||

|
||||
|
||||
Work in Progress
|
||||
----------------
|
||||
|
||||
We've a number of features that we know Phaser is lacking, here is our current priority list:
|
||||
Road Map
|
||||
--------
|
||||
|
||||
* Tilemap collision and layers
|
||||
* Better sound controls
|
||||
* MSPointer support
|
||||
* Text Rendering
|
||||
* Buttons
|
||||
Here is what's on our road map for the coming months:
|
||||
|
||||
Beyond this there are lots of other things we plan to add such as WebGL support, Spline animation format support, sloped collision tiles, path finding and support for custom plugins. But the list above are more priority items and is by no means exhaustive either! However we do feel that the core structure of Phaser is now pretty locked down, so safe to use for small scale production games.
|
||||
Version 1.1.5 ("Saldaea")
|
||||
|
||||
Test Suite
|
||||
----------
|
||||
* A fast turn-around point release that will focus on addressing any bugs that occured as a result of the large changes that took place in 1.1.4.
|
||||
|
||||
Phaser comes with an ever growing Test Suite. Personally we learn better by looking at small refined code examples, so we create lots of them to test each new feature we add. Inside the Tests folder you'll find the current set. If you write a particuarly good test then please send it to us.
|
||||
Version 1.2 ("Shienar")
|
||||
|
||||
The tests need running through a local web server (to avoid file access permission errors from your browser).
|
||||
* Update to Pixi 1.4 - this newly released build has lots of internal changes and new features we want to take advantage of.
|
||||
|
||||
Make sure you can browse to the Tests folder via your web server. If you've got php installed then launch:
|
||||
Version 1.3 ("Tarabon")
|
||||
|
||||
Tests/index.php
|
||||
* Enhance the State Management, so you can perform non-destructive State swaps and persistence.
|
||||
* Dedicated CocoonJS packaging features (screencanvas, etc)
|
||||
* A more advanced Particle system, one that can render to a single canvas (rather than spawn hundreds of Sprites), more advanced effects, etc.
|
||||
* Ability to control DOM elements from the core game and layer them into the game.
|
||||
* Touch Gestures.
|
||||
* Support for parallel asset loading.
|
||||
* Fixed width bitmap font support, plus enhanced Bitmap font rendering.
|
||||
|
||||
Version 2.0 ("Aes Sedai")
|
||||
|
||||
* Integrate p2.js physics system completely.
|
||||
* Comprehensive testing across Firefox OS devices, CocoonJS and Ejecta.
|
||||
* Integration with third party services like Google Play Game Services and Amazon JS SDK.
|
||||
* Flash CC HTML5 export integration.
|
||||
* Massively enhance the audio side of Phaser. Although it does what it does well, it could do with taking more advantage of Web Audio - echo effects, positional sound, etc.
|
||||
|
||||
Beyond version 2.0
|
||||
|
||||
* Test out packaging with Node-webkit.
|
||||
* Game parameters stored in Google Docs.
|
||||
* Look at HiDPI Canvas settings.
|
||||
* Multiple Camera support.
|
||||
|
||||
Right now the Test Suite requires PHP, but we will remove this requirement soon.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Phaser is in early stages and although we've still got a lot to add to it, we wanted to just get it out there and share it with the world.
|
||||
We now have a full [Contributors Guide][contribute] which goes into the process in more detail, but here are the headlines:
|
||||
|
||||
If you find a bug (highly likely!) then please report it on github.
|
||||
- If you find a bug then please report it on [GitHub Issues][issues] or our [Support Forum][forum].
|
||||
|
||||
If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you.
|
||||
- If you have a feature request, or have written a game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you! Either post to our [forum][forum] or email: rich@photonstorm.com
|
||||
|
||||
- If you issue a Pull Request for Phaser, please only do so againt the `dev` branch and *not* against the `master` branch.
|
||||
|
||||
- Before submitting a Pull Request please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, first install it by running `npm install jshint`, then test your code by running `jshint src`. This isn't a strict requirement and we are happy to receive Pull Requests that haven't been JSHinted, so don't let it put you off contributing, but do know that we'll reformat your source before going live with it.
|
||||
|
||||
You can do this on the Phased board on the [HTML5 Game Devs forum](http://www.html5gamedevs.com/forum/14-phaser/) or email: rich@photonstorm.com
|
||||
|
||||
Bugs?
|
||||
-----
|
||||
|
||||
Please add them to the [Issue Tracker][1] with as much info as possible.
|
||||
Please add them to the [Issue Tracker][issues] with as much info as possible, especially source code demonstrating the issue.
|
||||
|
||||

|
||||
|
||||
"Being negative is not how we make progress" - Larry Page, Google
|
||||
|
||||

|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright 2013 Richard Davey, Photon Storm Ltd. All rights reserved.
|
||||
Phaser is released under the [MIT License](http://opensource.org/licenses/MIT).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY RICHARD DAVEY ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICHARD DAVEY OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those of the
|
||||
authors and should not be interpreted as representing official policies, either expressed
|
||||
|
||||
[1]: https://github.com/photonstorm/phaser/issues
|
||||
[issues]: https://github.com/photonstorm/phaser/issues
|
||||
[contribute]: https://github.com/photonstorm/phaser/blob/master/CONTRIBUTING.md
|
||||
[phaser]: https://github.com/photonstorm/phaser
|
||||
[forum]: http://www.html5gamedevs.com/forum/14-phaser/
|
||||
[koding]: https://koding.com/Teamwork?import=https://github.com/photonstorm/phaser/archive/master.zip&c=git1
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
#ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
#Ignore files build by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.sln
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
*.map
|
||||
*.orig
|
||||
*.map
|
||||
*.config
|
||||
*.sublime-workspace
|
||||
.DS_Store
|
||||
launcher.html
|
||||
tests.html
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"path": "/D/wamp/www/phaser/Tests"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<ProjectGuid>{DC8A0795-0F9C-4216-A95D-6C3346EA7E26}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<OutputPath>bin</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Tests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:51901/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="cameras\camera alpha.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera bounds.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera position.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera rotation.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera scale.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera shadow.ts" />
|
||||
<TypeScriptCompile Include="cameras\camera texture.ts" />
|
||||
<TypeScriptCompile Include="cameras\fade fx.ts" />
|
||||
<TypeScriptCompile Include="cameras\flash fx.ts" />
|
||||
<TypeScriptCompile Include="cameras\focus on.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow deadzone.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow sprite.ts" />
|
||||
<TypeScriptCompile Include="cameras\follow topdown.ts" />
|
||||
<TypeScriptCompile Include="cameras\multicam1.ts" />
|
||||
<TypeScriptCompile Include="cameras\scroll factor.ts" />
|
||||
<TypeScriptCompile Include="cameras\shake fx.ts" />
|
||||
<TypeScriptCompile Include="collision\collide sprites.ts" />
|
||||
<TypeScriptCompile Include="collision\falling balls.ts" />
|
||||
<TypeScriptCompile Include="groups\basic group.ts" />
|
||||
<TypeScriptCompile Include="input\mouse scale.ts" />
|
||||
<TypeScriptCompile Include="mini games\formula 1.ts" />
|
||||
<TypeScriptCompile Include="misc\multi game.ts" />
|
||||
<TypeScriptCompile Include="particles\basic emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\graphic emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\multiple streams.ts" />
|
||||
<TypeScriptCompile Include="particles\sprite emitter.ts" />
|
||||
<TypeScriptCompile Include="particles\when particles collide.ts" />
|
||||
<TypeScriptCompile Include="sprites\animation 1.ts" />
|
||||
<TypeScriptCompile Include="sprites\mark of the bunny.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 2.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 3.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas 4.ts" />
|
||||
<TypeScriptCompile Include="sprites\texture atlas.ts" />
|
||||
<TypeScriptCompile Include="sprites\velocity.ts" />
|
||||
<TypeScriptCompile Include="tilemap\basic tilemap.ts" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="mobile\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="sprites\dynamic texture 1.ts" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="misc\screen grab.ts" />
|
||||
<Content Include="misc\screen grab.js">
|
||||
<DependentUpon>screen grab.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="sprites\align.ts" />
|
||||
<Content Include="sprites\align.js">
|
||||
<DependentUpon>align.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="sprites\flipped.ts" />
|
||||
<Content Include="sprites\flipped.js">
|
||||
<DependentUpon>flipped.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tweens\bounce.js">
|
||||
<DependentUpon>bounce.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="tweens\elastic.js">
|
||||
<DependentUpon>elastic.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="tweens\elastic.ts" />
|
||||
<TypeScriptCompile Include="tweens\bounce.ts" />
|
||||
<TypeScriptCompile Include="sprites\animate by framename.ts" />
|
||||
<TypeScriptCompile Include="geometry\rectangle.ts" />
|
||||
<TypeScriptCompile Include="geometry\rect vs rect.ts" />
|
||||
<TypeScriptCompile Include="geometry\circle.ts" />
|
||||
<Content Include="geometry\circle.js">
|
||||
<DependentUpon>circle.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geometry\point.ts" />
|
||||
<TypeScriptCompile Include="geometry\line.ts" />
|
||||
<Content Include="geometry\line.js">
|
||||
<DependentUpon>line.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\point.js">
|
||||
<DependentUpon>point.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\rect vs rect.js">
|
||||
<DependentUpon>rect vs rect.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geometry\rectangle.js">
|
||||
<DependentUpon>rectangle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\animate by framename.js">
|
||||
<DependentUpon>animate by framename.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\dynamic texture 1.js">
|
||||
<DependentUpon>dynamic texture 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\dynamic texture 2.js">
|
||||
<DependentUpon>dynamic texture 2.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="sprites\rotation.js">
|
||||
<DependentUpon>rotation.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="sprites\rotation.ts" />
|
||||
<TypeScriptCompile Include="sprites\dynamic texture 2.ts" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
</Project>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.0" orientation="orthogonal" width="100" height="100" tilewidth="16" tileheight="16">
|
||||
<tileset firstgid="1" name="platformer_tiles" tilewidth="16" tileheight="16">
|
||||
<image source="../tiles/platformer_tiles.png" width="304" height="96"/>
|
||||
</tileset>
|
||||
<layer name="Tile Layer 1" width="100" height="100">
|
||||
<data encoding="base64" compression="zlib">
|
||||
eJzt3NuNwkAMhWGaSBm0Qv/l7OOKaC6ei+Pfw3k40oqIYPtLMlkpcL1er0tB5TOQlfdH9rCrf+8+ZupR1u0ze2SocadhbZt1Ht6upf3TjqXWzCznwIxHrf8nLEoe0QYjHrN9luZ/VT7zKY/ZHiM8SsfuTo/WOtQy8vLonauRFvfZlWbWusZYjnfLfYF3r9a6Iz1a9e06P3o+T1hY1rfo9Na2VQ9KWrWR6rYcvyvXKyXGVB6cyIMVebAiD1bkwYo8WJEHL/JgJYPH+5boen7Z425xugvZ4z77d2XbSTZUj9Ksa3M/yYTucercM3nU5i4PXuTBijxYkQcr8mBFHqzIgxV5sCIPVuTBijxYkQcr8mBFHqzIgxV5sCIPVuTByekW8uBFHqzIgxV5sCKP/30TvOXx7RHt4umxuzfvORFMPDy8enpiRtHP05c8Zn0Ix5eny65Z936npOTR+02HEy1a58aOvkZ+w8T63trr1l5292zZ30hK+97lHeUxs50Uj1qt63TP46r8nX3mT/cw+hs/Vg9rP9FzXbHw2Lf1Hqm3zltMTzDxrnmXx+j+PPvz/v/c03vVg5hs51xpzrPrBzGZPUbdouuQiTyIkQcr8mBFHqzIgxV5sCIPVuTBijxYkQcr8mCF7FGavfW1rKF7lJ4xuG+XR5yJPOJT8jjRIpNH6/mt6Pp+zaPmcJpFJo+7SXQt8vg2ia5DHr8RebAiD1bkwYo8WJn1iDCsPeM9+9w3MaXvd1i+Y/B0z9nm3DpGWsdOb/Ykj+gZ76q3ty2LRyaTXR7U61XUZ67UarletTxKvd/3Ez2bkTWd5GedXTaPUbfoOuTBsNhxf5Xdg3idWjmWaus56dqcZb3Y4aHERx6sjN4/Kv75A/snIls=
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
@@ -1,80 +0,0 @@
|
||||
31,31,31,31,31,31,31,31,31,31,31,31,31,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32,31,31,31,31,31,31,31,32,32,33,32,33,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,0,0,0,32
|
||||
31,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,32,32,0,0,0,0,0,32,0,0,0,0,31
|
||||
32,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,0,0,0,0,34
|
||||
34,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,32,32,32,0,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,32,32,0,0,33
|
||||
32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,32,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
34,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,0,0,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
33,0,0,0,0,0,32,32,0,0,0,0,32,32,0,0,0,0,0,32,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,32,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,32,32,32,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,32,32,32,32,0,0,0,0,31
|
||||
34,32,0,0,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,32
|
||||
32,32,32,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,34
|
||||
33,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,0,0,32,0,0,32,32,0,0,0,0,32,0,0,0,31
|
||||
32,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,0,0,0,0,0,32,32,0,0,0,32,32,0,0,0,32,32,0,0,32
|
||||
31,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,32,32,0,0,0,32,32,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,32,32,32,32,32,32,0,0,0,32,32,32,0,0,34
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,0,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,32
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,33
|
||||
31,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32
|
||||
34,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,31
|
||||
31,0,0,0,0,0,0,32,32,32,0,0,0,0,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,32
|
||||
33,0,0,0,0,0,0,0,32,32,0,0,0,0,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,0,0,32,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,31
|
||||
34,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,0,0,0,32,32,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,32
|
||||
32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,31
|
||||
33,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,34
|
||||
32,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,31
|
||||
31,0,0,0,0,32,32,32,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,32,32,32,0,0,0,0,32
|
||||
32,0,0,0,32,32,32,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,32,0,0,32,0,0,0,0,0,0,32,32,32,32,32,0,0,31
|
||||
34,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,32,0,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,33
|
||||
34,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,32,0,0,0,31
|
||||
33,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,32,32,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,34
|
||||
34,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,0,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
33,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,32,32,0,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,0,32
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,32,0,32,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,34
|
||||
31,0,0,0,0,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,31
|
||||
33,32,32,32,32,32,32,0,0,0,32,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,33
|
||||
31,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,34
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,32,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32
|
||||
33,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,33
|
||||
32,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,32,32,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,0,0,0,0,32
|
||||
31,32,32,32,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,32,32,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,31
|
||||
32,0,32,32,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,32
|
||||
34,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,32,0,0,32,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
33,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
32,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32
|
||||
31,0,0,0,0,32,32,32,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,32,0,0,32,0,0,0,0,0,0,32,32,32,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,31
|
||||
32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,0,0,32,32,0,0,0,32,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,32,32,32
|
||||
34,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,32,32,32,0,32,0,0,32,32,32,32,32,32,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,32,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,32,0,32,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,32,32,0,0,0,0,0,0,0,0,31
|
||||
32,0,0,0,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,0,0,32,32,32,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,31
|
||||
34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,0,0,0,32,32,32,32,0,0,0,0,32,32,0,0,0,0,0,0,0,0,0,32,32,32,32,0,0,0,0,0,0,0,34
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,0,0,0,32,32,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,32,32,32,32,32,32,0,0,0,0,0,0,31
|
||||
33,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32,34,33,31,31,31,31,31,31,31,31,32,32,33,32,33,34,32,31,31,31,31,31,31,31,32,32,33,32,33,34,32
|
||||
|
@@ -1,16 +0,0 @@
|
||||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
||||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
||||
55,40,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,41,55
|
||||
55,50,38,35,1,1,1,1,1,1,29,34,29,1,1,28,1,1,47,55
|
||||
55,50,30,28,34,29,1,2,3,4,5,6,34,34,1,34,28,34,47,55
|
||||
55,50,1,30,34,29,28,7,8,9,10,11,1,33,30,1,39,29,47,55
|
||||
55,50,28,1,29,1,36,12,13,14,15,16,29,35,34,29,34,1,47,55
|
||||
55,50,30,34,29,30,32,17,18,19,20,21,30,35,31,32,1,30,47,55
|
||||
55,50,29,31,36,35,36,22,23,24,25,26,35,28,1,34,34,29,47,55
|
||||
55,42,45,45,45,45,49,35,35,35,35,34,27,34,35,34,35,1,47,55
|
||||
55,55,55,55,55,55,50,36,1,34,28,36,28,29,34,34,34,29,47,55
|
||||
55,40,53,53,53,53,54,28,32,1,1,28,34,35,29,38,34,1,47,55
|
||||
55,50,1,29,30,1,29,33,32,29,1,34,28,1,29,1,32,1,47,55
|
||||
55,42,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,43,55
|
||||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
||||
55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55
|
||||
|
@@ -1,18 +0,0 @@
|
||||
31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,34
|
||||
32,105,106,107,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
34,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,32
|
||||
31,0,0,0,0,0,0,0,0,0,0,16,104,105,107,17,0,0,31,31
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33
|
||||
34,0,0,16,104,105,106,107,17,0,0,0,0,0,0,0,0,0,31,31
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,63,65,0,0,0,0,0,31
|
||||
33,13,0,0,0,0,0,0,0,0,0,0,49,50,0,0,0,0,15,33
|
||||
31,33,13,0,0,0,0,0,0,0,0,47,51,52,46,0,0,13,34,31
|
||||
34,31,33,15,0,14,0,15,0,14,0,0,69,71,0,0,14,34,31,32
|
||||
42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
|
||||
59,59,59,59,60,59,59,59,59,59,59,59,59,59,59,59,59,60,59,59
|
||||
78,78,78,78,79,78,78,78,78,78,78,78,78,78,78,78,78,79,78,78
|
||||
|
@@ -1,90 +0,0 @@
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,6,8,8,7,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,6,21,8,8,8,7,0,0,0,0,0,6,7,0
|
||||
0,0,0,0,0,6,9,8,11,11,20,9,7,0,0,0,0,12,15,0
|
||||
0,0,0,0,0,20,8,9,11,11,9,10,8,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,13,8,21,11,11,21,20,14,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,12,13,13,14,14,15,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,0,0,0
|
||||
0,0,0,0,0,6,7,0,0,0,0,0,0,0,6,11,8,7,0,0
|
||||
0,0,0,0,0,12,15,0,0,0,0,0,0,0,8,9,10,8,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,13,14,15,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,1,1,0,0,0,0,0,0,0,0,0,6,7,0,0,0,0
|
||||
0,0,1,2,2,1,0,0,0,0,0,0,0,0,12,15,0,0,0,0
|
||||
0,0,2,8,20,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,2,12,15,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,3,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,4,5,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,6,11,8,7,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,6,7,0,0,8,9,10,8,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,12,15,0,0,12,13,14,15,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,4,5,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0
|
||||
0,6,11,8,7,0,0,0,0,0,0,0,1,1,2,1,0,0,0,0
|
||||
0,8,9,10,8,0,0,0,0,0,0,0,2,8,20,2,0,0,0,0
|
||||
0,12,13,14,15,0,0,0,0,0,0,0,2,12,15,2,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,3,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,4,5,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,1,6,11,8,7,1,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,2,8,9,10,8,2,0,0,1,0,1,0
|
||||
0,0,0,0,0,0,0,0,3,12,13,14,15,3,0,0,2,8,2,0
|
||||
0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,2,13,2,0
|
||||
0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,3,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,2,8,8,2,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,6,21,8,8,8,7,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,1,2,9,8,11,11,20,9,2,1,0,0,0,0,0,0,0
|
||||
0,0,0,2,20,8,9,11,11,9,10,20,2,0,0,0,0,0,0,0
|
||||
0,0,0,3,13,8,21,11,11,21,20,14,3,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,12,13,13,14,14,15,0,0,4,5,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,6,11,8,7,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,8,9,10,8,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,12,13,14,15,0,0,0,0
|
||||
0,0,0,0,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,12,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,8,8,7,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,21,8,8,8,7
|
||||
0,0,0,1,0,0,1,0,0,0,0,0,0,6,9,8,11,11,20,9
|
||||
0,0,0,2,9,20,2,0,0,0,0,0,0,20,8,9,11,11,9,10
|
||||
0,0,0,2,12,15,2,0,0,0,0,0,0,13,8,21,11,11,21,20
|
||||
0,0,0,3,0,0,3,0,0,0,0,0,0,0,12,13,13,14,14,15
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,0,0
|
||||
0,0,0,0,0,0,4,5,0,0,0,0,0,0,0,0,12,15,0,0
|
||||
0,0,0,0,0,6,11,8,7,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,4,8,9,10,8,5,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,12,13,13,14,14,15,0,0,0,4,5,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,1,6,11,8,7,1,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,2,8,9,10,8,2,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,3,12,13,14,15,3,0,0,0
|
||||
0,0,0,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,6,11,8,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,8,9,10,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,6,7,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,12,15,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 41 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.2 KiB |
-121
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
function dirToArray($dir) {
|
||||
|
||||
$ignore = array('.', '..', 'Tests.csproj', 'Tests.csproj.user', 'bin', 'index.php', 'phaser.css', 'obj', 'assets', 'states', 'Phaser Tests.sublime-project');
|
||||
$result = array();
|
||||
$root = scandir($dir);
|
||||
$dirs = array_diff($root, $ignore);
|
||||
|
||||
foreach ($dirs as $key => $value)
|
||||
{
|
||||
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
|
||||
{
|
||||
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (substr($value, -3) == '.js')
|
||||
{
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$state = false;
|
||||
|
||||
if (isset($_GET['f']))
|
||||
{
|
||||
$js = $_GET['d'] . '/' . $_GET['f'];
|
||||
$ts = substr($js, 0, -2) . 'ts';
|
||||
$state = substr($_GET['f'], 0, -3);
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0" />
|
||||
<title>Phaser Test Runner: <?php echo $state?></title>
|
||||
<link rel="stylesheet" href="phaser.css" type="text/css" />
|
||||
<script src="phaser.js"></script>
|
||||
<?php
|
||||
if ($state)
|
||||
{
|
||||
?>
|
||||
<script src="<?php echo $js?>"></script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
if ($state)
|
||||
{
|
||||
?>
|
||||
|
||||
<a href="index.php" class="button star">Home</a>
|
||||
<a href="<?php echo $js?>" class="button play">View JavaScript</a>
|
||||
<a href="<?php echo $ts?>" class="button play">View TypeScript</a>
|
||||
|
||||
|
||||
<div id="game"></div>
|
||||
|
||||
<p>You'll learn best from these Tests by viewing the source code.<br />
|
||||
Use the arrow keys / mouse to move around most of them.</p>
|
||||
|
||||
<p><a href="https://github.com/photonstorm/phaser">Phaser</a></p>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
function printJSLinks($dir, $files) {
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
|
||||
$value2 = substr($value, 0, -3);
|
||||
echo "<a href=\"index.php?f=$value&d=$dir\" class=\"button\">$value2</a>";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($state == false)
|
||||
{
|
||||
?>
|
||||
|
||||
<div id="header">
|
||||
<h1 id="title">Phaser Test Suite</h1>
|
||||
</div>
|
||||
|
||||
<div id="links">
|
||||
<?php
|
||||
$files = dirToArray(dirname(__FILE__));
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
|
||||
// If $key is an array, output it as an h2 or something
|
||||
if (is_array($value) && count($value) > 0)
|
||||
{
|
||||
echo "<h2>$key</h2>";
|
||||
printJSLinks($key, $value);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,36 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
// Here we create a quite tiny game (320x240 in size)
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update);
|
||||
function init() {
|
||||
// This sets a limit on the up-scale
|
||||
myGame.stage.maxScaleX = 640;
|
||||
myGame.stage.maxScaleY = 480;
|
||||
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
|
||||
myGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
function create() {
|
||||
myGame.world.setSize(2000, 2000);
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
myGame.createSprite(myGame.world.randomX, myGame.world.randomY, 'melon');
|
||||
}
|
||||
myGame.onRenderCallback = render;
|
||||
}
|
||||
function update() {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
myGame.camera.scroll.x -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
myGame.camera.scroll.y -= 4;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
myGame.input.renderDebugInfo(16, 16);
|
||||
}
|
||||
})();
|
||||
@@ -1,63 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
// Here we create a quite tiny game (320x240 in size)
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
// This sets a limit on the up-scale
|
||||
myGame.stage.maxScaleX = 640;
|
||||
myGame.stage.maxScaleY = 480;
|
||||
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
|
||||
myGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
|
||||
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.world.setSize(2000, 2000);
|
||||
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
myGame.createSprite(myGame.world.randomX, myGame.world.randomY, 'melon');
|
||||
}
|
||||
|
||||
myGame.onRenderCallback = render;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
myGame.camera.scroll.x -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
myGame.camera.scroll.x += 4;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
myGame.camera.scroll.y -= 4;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
myGame.camera.scroll.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.input.renderDebugInfo(16, 16);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,204 +0,0 @@
|
||||
body
|
||||
{
|
||||
background: url(assets/suite/background.png);
|
||||
color: white;
|
||||
font: 1em/2em Arial, Helvetica;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
* {
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgb(0, 0, 0, 0);
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
}
|
||||
|
||||
#links {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 30pt;
|
||||
margin: 0;
|
||||
padding: 16px;
|
||||
text-shadow: 0px 4px 3px rgba(0,0,0,0.4), 0px 8px 13px rgba(0,0,0,0.1), 0px 18px 23px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 20pt;
|
||||
margin: 16px 0px 16px 0px;
|
||||
text-shadow: 0px 4px 3px rgba(0,0,0,0.4), 0px 8px 13px rgba(0,0,0,0.1), 0px 18px 23px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 30px;
|
||||
margin: 16px 0px 16px 16px;
|
||||
text-shadow: 0px 4px 3px rgba(0,0,0,0.4), 0px 8px 13px rgba(0,0,0,0.1), 0px 18px 23px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
a {
|
||||
color: yellow;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:Hover {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.button
|
||||
{
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
background-color: #ccc;
|
||||
border: 1px solid #777;
|
||||
padding: 0 1.5em;
|
||||
margin: 0.5em;
|
||||
font: bold 1em/2em Arial, Helvetica;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
|
||||
-moz-border-radius: .2em;
|
||||
-webkit-border-radius: .2em;
|
||||
border-radius: .2em;
|
||||
-moz-box-shadow: 0 0 1px 1px rgba(255, 255, 255, .8) inset, 0 1px 0 rgba(0, 0, 0, .3);
|
||||
-webkit-box-shadow: 0 0 1px 1px rgba(255, 255, 255, .8) inset, 0 1px 0 rgba(0, 0, 0, .3);
|
||||
box-shadow: 0 0 1px 1px rgba(255, 255, 255, .8) inset, 0 1px 0 rgba(0, 0, 0, .3);
|
||||
background-image: linear-gradient(top, #eee, #ccc);
|
||||
}
|
||||
|
||||
.button:hover
|
||||
{
|
||||
background-color: #ddd;
|
||||
background-image: linear-gradient(top, #fafafa, #ddd);
|
||||
}
|
||||
|
||||
.button:active
|
||||
{
|
||||
-moz-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
|
||||
-webkit-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
|
||||
box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
.button:focus
|
||||
{
|
||||
outline: 0;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.button:before
|
||||
{
|
||||
background: #ccc;
|
||||
background: rgba(0,0,0,.1);
|
||||
float: left;
|
||||
width: 1em;
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
margin: 0 1em 0 -1em;
|
||||
padding: 0 .2em;
|
||||
-moz-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
|
||||
-webkit-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
|
||||
box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
|
||||
-moz-border-radius: .15em 0 0 .15em;
|
||||
-webkit-border-radius: .15em 0 0 .15em;
|
||||
border-radius: .15em 0 0 .15em;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Hexadecimal entities for the icons */
|
||||
|
||||
.add:before
|
||||
{
|
||||
content: "\271A";
|
||||
}
|
||||
|
||||
.edit:before
|
||||
{
|
||||
content: "\270E";
|
||||
}
|
||||
|
||||
.delete:before
|
||||
{
|
||||
content: "\2718";
|
||||
}
|
||||
|
||||
.save:before
|
||||
{
|
||||
content: "\2714";
|
||||
}
|
||||
|
||||
.email:before
|
||||
{
|
||||
content: "\2709";
|
||||
}
|
||||
|
||||
.like:before
|
||||
{
|
||||
content: "\2764";
|
||||
}
|
||||
|
||||
.next:before
|
||||
{
|
||||
content: "\279C";
|
||||
}
|
||||
|
||||
.star:before
|
||||
{
|
||||
content: "\2605";
|
||||
}
|
||||
|
||||
.spark:before
|
||||
{
|
||||
content: "\2737";
|
||||
}
|
||||
|
||||
.play:before
|
||||
{
|
||||
content: "\25B6";
|
||||
}
|
||||
|
||||
/* Buttons and inputs */
|
||||
button.button, input.button
|
||||
{
|
||||
cursor: pointer;
|
||||
overflow: visible; /* removes extra side spacing in IE */
|
||||
}
|
||||
|
||||
/* removes extra inner spacing in Firefox */
|
||||
button::-moz-focus-inner
|
||||
{
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* If line-height can't be modified, then fix Firefox spacing with padding */
|
||||
input::-moz-focus-inner
|
||||
{
|
||||
padding: .4em;
|
||||
}
|
||||
|
||||
/* The disabled styles */
|
||||
.button[disabled], .button[disabled]:hover, .button.disabled, .button.disabled:hover
|
||||
{
|
||||
background: #eee;
|
||||
color: #aaa;
|
||||
border-color: #aaa;
|
||||
cursor: default;
|
||||
text-shadow: none;
|
||||
position: static;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
-11622
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('teddy', 'assets/pics/profil-sad_plush.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var teddy;
|
||||
function create() {
|
||||
teddy = myGame.createSprite(0, 0, 'teddy');
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
myGame.input.onDown.add(click, this);
|
||||
teddy.renderDebug = true;
|
||||
}
|
||||
function click() {
|
||||
if(teddy.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT) {
|
||||
teddy.align = Phaser.GameObject.ALIGN_TOP_LEFT;
|
||||
} else {
|
||||
teddy.align++;
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
teddy.x = myGame.input.x;
|
||||
teddy.y = myGame.input.y;
|
||||
}
|
||||
})();
|
||||
@@ -1,50 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('teddy', 'assets/pics/profil-sad_plush.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var teddy: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
teddy = myGame.createSprite(0, 0, 'teddy');
|
||||
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
|
||||
myGame.input.onDown.add(click, this);
|
||||
|
||||
teddy.renderDebug = true;
|
||||
|
||||
}
|
||||
|
||||
function click() {
|
||||
|
||||
if (teddy.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT)
|
||||
{
|
||||
teddy.align = Phaser.GameObject.ALIGN_TOP_LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
teddy.align++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
teddy.x = myGame.input.x;
|
||||
teddy.y = myGame.input.y;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = myGame.createSprite(myGame.stage.width, 300, 'bot');
|
||||
// If you are using a Texture Atlas and want to specify the frames of an animation by their name rather than frame index
|
||||
// then you can use this format:
|
||||
bot.animations.add('run', [
|
||||
'run00',
|
||||
'run01',
|
||||
'run02',
|
||||
'run03',
|
||||
'run04',
|
||||
'run05',
|
||||
'run06',
|
||||
'run07',
|
||||
'run08',
|
||||
'run09',
|
||||
'run10'
|
||||
], 10, true, false);
|
||||
bot.animations.play('run');
|
||||
bot.velocity.x = -100;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,59 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var wobblyBall;
|
||||
function create() {
|
||||
// Create our DynamicTexture
|
||||
wobblyBall = myGame.createDynamicTexture('wobbly', 32, 64);
|
||||
// And apply it to 100 randomly positioned sprites
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var temp = myGame.createSprite(myGame.world.randomX, myGame.world.randomY);
|
||||
temp.width = 32;
|
||||
temp.height = 64;
|
||||
temp.loadDynamicTexture(wobblyBall);
|
||||
}
|
||||
// Populate the wave with some data
|
||||
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
|
||||
}
|
||||
function update() {
|
||||
wobblyBall.clear();
|
||||
updateWobblyBall();
|
||||
}
|
||||
// This creates a simple sine-wave effect running through our DynamicTexture.
|
||||
// This is then duplicated across all sprites using it, meaning we only have to calculate it once.
|
||||
var waveSize = 8;
|
||||
var wavePixelChunk = 2;
|
||||
var waveData;
|
||||
var waveDataCounter;
|
||||
function updateWobblyBall() {
|
||||
var s = 0;
|
||||
var copyRect = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: wavePixelChunk,
|
||||
h: 32
|
||||
};
|
||||
var copyPoint = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
for(var x = 0; x < 32; x += wavePixelChunk) {
|
||||
copyPoint.x = x;
|
||||
copyPoint.y = waveSize + (waveSize / 2) + waveData[s];
|
||||
wobblyBall.context.drawImage(myGame.cache.getImage('ball'), copyRect.x, copyRect.y, copyRect.w, copyRect.h, copyPoint.x, copyPoint.y, copyRect.w, copyRect.h);
|
||||
copyRect.x += wavePixelChunk;
|
||||
s++;
|
||||
}
|
||||
// Cycle through the wave data - this is what causes the image to "undulate"
|
||||
var t = waveData.shift();
|
||||
waveData.push(t);
|
||||
waveDataCounter++;
|
||||
if(waveDataCounter == waveData.length) {
|
||||
waveDataCounter = 0;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,32 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Texture Atlas Method 4
|
||||
//
|
||||
// We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file
|
||||
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var chick;
|
||||
var car;
|
||||
var mech;
|
||||
var robot;
|
||||
var cop;
|
||||
function create() {
|
||||
myGame.camera.backgroundColor = 'rgb(40, 40, 40)';
|
||||
chick = myGame.createSprite(64, 64, 'atlas');
|
||||
// You can set the frame based on the frame name (which TexturePacker usually sets to be the filename of the image itself)
|
||||
chick.frameName = 'budbrain_chick.png';
|
||||
// Or by setting the frame index
|
||||
//chick.frame = 0;
|
||||
cop = myGame.createSprite(600, 64, 'atlas');
|
||||
cop.frameName = 'ladycop.png';
|
||||
robot = myGame.createSprite(50, 300, 'atlas');
|
||||
robot.frameName = 'robot.png';
|
||||
car = myGame.createSprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
mech = myGame.createSprite(250, 100, 'atlas');
|
||||
mech.frameName = 'titan_mech.png';
|
||||
}
|
||||
})();
|
||||
@@ -1,271 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Texture Atlas Method 1
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
|
||||
// (in this case botData)
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
myGame.loader.load();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = myGame.createSprite(myGame.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bot.velocity.x = -100;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
}
|
||||
var botData = {
|
||||
"frames": [
|
||||
{
|
||||
"filename": "running bot.swf/0000",
|
||||
"frame": {
|
||||
"x": 34,
|
||||
"y": 128,
|
||||
"w": 56,
|
||||
"h": 60
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 2,
|
||||
"w": 56,
|
||||
"h": 60
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0001",
|
||||
"frame": {
|
||||
"x": 54,
|
||||
"y": 0,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0002",
|
||||
"frame": {
|
||||
"x": 54,
|
||||
"y": 58,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0003",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 192,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 11,
|
||||
"y": 0,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0004",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 64,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 1,
|
||||
"y": 0,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0005",
|
||||
"frame": {
|
||||
"x": 196,
|
||||
"y": 0,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0006",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 1,
|
||||
"y": 0,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0007",
|
||||
"frame": {
|
||||
"x": 140,
|
||||
"y": 0,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0008",
|
||||
"frame": {
|
||||
"x": 34,
|
||||
"y": 188,
|
||||
"w": 50,
|
||||
"h": 60
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 3,
|
||||
"y": 2,
|
||||
"w": 50,
|
||||
"h": 60
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0009",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 128,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 11,
|
||||
"y": 0,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0010",
|
||||
"frame": {
|
||||
"x": 84,
|
||||
"y": 188,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "http://www.texturepacker.com",
|
||||
"version": "1.0",
|
||||
"image": "running_bot.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {
|
||||
"w": 252,
|
||||
"h": 256
|
||||
},
|
||||
"scale": "0.2",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var atari;
|
||||
function create() {
|
||||
atari = myGame.createSprite(300, 0, 'atari');
|
||||
startBounceTween();
|
||||
}
|
||||
function startBounceTween() {
|
||||
atari.y = 0;
|
||||
var bounce = myGame.createTween(atari);
|
||||
bounce.to({
|
||||
y: 500
|
||||
}, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.Out);
|
||||
bounce.onComplete.add(startBounceTween, this);
|
||||
bounce.start();
|
||||
}
|
||||
})();
|
||||
@@ -1,15 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
function create() {
|
||||
var atari = myGame.createSprite(300, 0, 'atari');
|
||||
// Here is the short-hand way of creating a tween, by chaining the call to it:
|
||||
myGame.createTween(atari).to({
|
||||
y: 400
|
||||
}, 5000, Phaser.Easing.Elastic.Out, true);
|
||||
}
|
||||
})();
|
||||
@@ -1,24 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('atari', 'assets/sprites/atari130xe.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
var atari = myGame.createSprite(300, 0, 'atari');
|
||||
|
||||
// Here is the short-hand way of creating a tween, by chaining the call to it:
|
||||
myGame.createTween(atari).to({ y: 400 }, 5000, Phaser.Easing.Elastic.Out, true);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "phaser",
|
||||
"version": "1.1.4",
|
||||
"homepage": "http://phaser.io",
|
||||
"authors": [
|
||||
"photonstorm <rich@photonstorm.com>"
|
||||
],
|
||||
"description": "A fun, free and fast 2D game framework for making HTML5 games for desktop and mobile, supporting Canvas and WebGL.",
|
||||
"main": "build/phaser.min.js",
|
||||
"keywords": [
|
||||
"html5",
|
||||
"game",
|
||||
"games",
|
||||
"framework",
|
||||
"canvas",
|
||||
"WebGL",
|
||||
"tilemaps",
|
||||
"physics",
|
||||
"sprites",
|
||||
"fonts",
|
||||
"images",
|
||||
"audio",
|
||||
"Web",
|
||||
"Audio",
|
||||
"touch",
|
||||
"input",
|
||||
"mobile"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
// NOTE: This script is deprecated. The build process is managed by grunt now.
|
||||
// Keeping this file here for those that I know use it, but if you're trying to build fresh, use grunt.
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
// Get the version number
|
||||
// VERSION: '1.0.5',
|
||||
$vf = file_get_contents(dirname(__FILE__) . '/../src/Phaser.js');
|
||||
$version = substr($vf, strpos($vf, 'VERSION: ') + 10, 5);
|
||||
$buildLog = "Building version $version \n\n";
|
||||
$header = "";
|
||||
|
||||
$js = file(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.php');
|
||||
$output = "";
|
||||
|
||||
for ($i = 0; $i < count($js); $i++)
|
||||
{
|
||||
// <script src="../src/Phaser.js"></script>
|
||||
$line = trim($js[$i]);
|
||||
|
||||
if (strpos($line, '<script') !== false)
|
||||
{
|
||||
$line = str_replace('<script src="', '', $line);
|
||||
$line = dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('"></script>', '', $line);
|
||||
$filename = substr($line, strrpos($line, '/') + 1);
|
||||
|
||||
$buildLog .= $line . "\n";
|
||||
// echo $filename . "\n";
|
||||
|
||||
// Read the file in
|
||||
if (file_exists($line))
|
||||
{
|
||||
$source = file_get_contents($line);
|
||||
|
||||
if ($filename == 'Intro.js')
|
||||
{
|
||||
// Built at: {buildDate}
|
||||
$source = str_replace('{buildDate}', date('r'), $source);
|
||||
|
||||
// {version}
|
||||
$source = str_replace('{version}', $version, $source);
|
||||
|
||||
// Set the header
|
||||
$header = $source;
|
||||
}
|
||||
else
|
||||
{
|
||||
$output .= $source . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a UMD wrapper, to allow Phaser to be exposed to AMD, Node and Browsers
|
||||
$template = <<<EOT
|
||||
%s(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
} else {
|
||||
root.Phaser = factory();
|
||||
}
|
||||
}(this, function (b) {
|
||||
%s
|
||||
return Phaser;
|
||||
}));
|
||||
EOT;
|
||||
|
||||
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phaser.js', sprintf($template, $header, $output));
|
||||
|
||||
if(php_sapi_name() == 'cli' || empty($_SERVER['REMOTE_ADDR'])) {
|
||||
echo "\ndone\n\n";
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<a href="http://yui.2clics.net/">Minify it</a><br />
|
||||
|
||||
<textarea style="width: 800px; height: 800px">
|
||||
<?php echo $buildLog; ?>
|
||||
</textarea>
|
||||
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
// All JS files in build order.
|
||||
// Much easier for debugging re: line numbers
|
||||
if (!isset($path))
|
||||
{
|
||||
$path = '..';
|
||||
}
|
||||
|
||||
echo <<<EOL
|
||||
|
||||
<script src="$path/src/Intro.js"></script>
|
||||
<script src="$path/src/pixi/Pixi.js"></script>
|
||||
<script src="$path/src/Phaser.js"></script>
|
||||
<script src="$path/src/utils/Utils.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/core/Matrix.js"></script>
|
||||
<script src="$path/src/pixi/core/Point.js"></script>
|
||||
<script src="$path/src/pixi/core/Rectangle.js"></script>
|
||||
<script src="$path/src/pixi/core/Polygon.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="$path/src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="$path/src/pixi/display/Sprite.js"></script>
|
||||
<script src="$path/src/pixi/display/Stage.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/extras/CustomRenderable.js"></script>
|
||||
<script src="$path/src/pixi/extras/Strip.js"></script>
|
||||
<script src="$path/src/pixi/extras/Rope.js"></script>
|
||||
<script src="$path/src/pixi/extras/TilingSprite.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/filters/AbstractFilter.js"></script>
|
||||
<script src="$path/src/pixi/filters/FilterBlock.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/primitives/Graphics.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
<script src="$path/src/pixi/renderers/canvas/CanvasRenderer.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/renderers/webgl/PixiShader.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/PrimitiveShader.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/StripShader.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLBatch.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLFilterManager.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLGraphics.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLRenderer.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLShaders.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/text/BitmapText.js"></script>
|
||||
<script src="$path/src/pixi/text/Text.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/textures/BaseTexture.js"></script>
|
||||
<script src="$path/src/pixi/textures/Texture.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/utils/EventTarget.js"></script>
|
||||
<script src="$path/src/pixi/utils/Polyk.js"></script>
|
||||
|
||||
<script src="$path/src/core/Camera.js"></script>
|
||||
<script src="$path/src/core/State.js"></script>
|
||||
<script src="$path/src/core/StateManager.js"></script>
|
||||
<script src="$path/src/core/LinkedList.js"></script>
|
||||
<script src="$path/src/core/Signal.js"></script>
|
||||
<script src="$path/src/core/SignalBinding.js"></script>
|
||||
<script src="$path/src/core/Filter.js"></script>
|
||||
<script src="$path/src/core/Plugin.js"></script>
|
||||
<script src="$path/src/core/PluginManager.js"></script>
|
||||
<script src="$path/src/core/Stage.js"></script>
|
||||
<script src="$path/src/core/Group.js"></script>
|
||||
<script src="$path/src/core/World.js"></script>
|
||||
<script src="$path/src/core/Game.js"></script>
|
||||
|
||||
<script src="$path/src/input/Input.js"></script>
|
||||
<script src="$path/src/input/Key.js"></script>
|
||||
<script src="$path/src/input/Keyboard.js"></script>
|
||||
<script src="$path/src/input/Mouse.js"></script>
|
||||
<script src="$path/src/input/MSPointer.js"></script>
|
||||
<script src="$path/src/input/Pointer.js"></script>
|
||||
<script src="$path/src/input/Touch.js"></script>
|
||||
<script src="$path/src/input/Gamepad.js"></script>
|
||||
<script src="$path/src/input/SinglePad.js"></script>
|
||||
<script src="$path/src/input/GamepadButton.js"></script>
|
||||
<script src="$path/src/input/InputHandler.js"></script>
|
||||
|
||||
<script src="$path/src/gameobjects/Events.js"></script>
|
||||
<script src="$path/src/gameobjects/GameObjectFactory.js"></script>
|
||||
<script src="$path/src/gameobjects/BitmapData.js"></script>
|
||||
<script src="$path/src/gameobjects/Sprite.js"></script>
|
||||
<script src="$path/src/gameobjects/TileSprite.js"></script>
|
||||
<script src="$path/src/gameobjects/Text.js"></script>
|
||||
<script src="$path/src/gameobjects/BitmapText.js"></script>
|
||||
<script src="$path/src/gameobjects/Button.js"></script>
|
||||
<script src="$path/src/gameobjects/Graphics.js"></script>
|
||||
<script src="$path/src/gameobjects/RenderTexture.js"></script>
|
||||
|
||||
<script src="$path/src/system/Canvas.js"></script>
|
||||
<script src="$path/src/system/StageScaleMode.js"></script>
|
||||
<script src="$path/src/system/Device.js"></script>
|
||||
<script src="$path/src/system/RequestAnimationFrame.js"></script>
|
||||
|
||||
<script src="$path/src/math/RandomDataGenerator.js"></script>
|
||||
<script src="$path/src/math/Math.js"></script>
|
||||
<script src="$path/src/math/QuadTree.js"></script>
|
||||
|
||||
<script src="$path/src/geom/Circle.js"></script>
|
||||
<script src="$path/src/geom/Point.js"></script>
|
||||
<script src="$path/src/geom/Rectangle.js"></script>
|
||||
<script src="$path/src/geom/Line.js"></script>
|
||||
|
||||
<script src="$path/src/net/Net.js"></script>
|
||||
|
||||
<script src="$path/src/tween/TweenManager.js"></script>
|
||||
<script src="$path/src/tween/Tween.js"></script>
|
||||
<script src="$path/src/tween/Easing.js"></script>
|
||||
|
||||
<script src="$path/src/time/Time.js"></script>
|
||||
<script src="$path/src/time/Timer.js"></script>
|
||||
<script src="$path/src/time/TimerEvent.js"></script>
|
||||
|
||||
<script src="$path/src/animation/AnimationManager.js"></script>
|
||||
<script src="$path/src/animation/Animation.js"></script>
|
||||
<script src="$path/src/animation/Frame.js"></script>
|
||||
<script src="$path/src/animation/FrameData.js"></script>
|
||||
<script src="$path/src/animation/AnimationParser.js"></script>
|
||||
|
||||
<script src="$path/src/loader/Cache.js"></script>
|
||||
<script src="$path/src/loader/Loader.js"></script>
|
||||
<script src="$path/src/loader/LoaderParser.js"></script>
|
||||
|
||||
<script src="$path/src/sound/Sound.js"></script>
|
||||
<script src="$path/src/sound/SoundManager.js"></script>
|
||||
|
||||
<script src="$path/src/utils/Debug.js"></script>
|
||||
<script src="$path/src/utils/Color.js"></script>
|
||||
|
||||
<script src="$path/src/physics/arcade/SAT.js"></script>
|
||||
<script src="$path/src/physics/arcade/ArcadePhysics.js"></script>
|
||||
<script src="$path/src/physics/arcade/Body.js"></script>
|
||||
|
||||
<script src="$path/src/particles/Particles.js"></script>
|
||||
<script src="$path/src/particles/arcade/ArcadeParticles.js"></script>
|
||||
<script src="$path/src/particles/arcade/Emitter.js"></script>
|
||||
|
||||
<script src="$path/src/tilemap/Tile.js"></script>
|
||||
<script src="$path/src/tilemap/Tilemap.js"></script>
|
||||
<script src="$path/src/tilemap/TilemapLayer.js"></script>
|
||||
<script src="$path/src/tilemap/TilemapParser.js"></script>
|
||||
<script src="$path/src/tilemap/Tileset.js"></script>
|
||||
|
||||
<script src="$path/src/PixiPatch.js"></script>
|
||||
EOL;
|
||||
?>
|
||||
-8660
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
-8740
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
-8983
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
-1
File diff suppressed because one or more lines are too long
-11622
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
+2046
File diff suppressed because it is too large
Load Diff
+45730
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user