mirror of
https://github.com/wassname/phaser.git
synced 2026-08-06 13:31:05 +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 |
+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
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 130 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 531 B |
Binary file not shown.
|
Before Width: | Height: | Size: 204 KiB |
-104
@@ -1,104 +0,0 @@
|
||||
module.exports = function (grunt) {
|
||||
grunt.loadNpmTasks('grunt-typescript');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
|
||||
var wrapPhaserInUmd = function(content, isAddon) {
|
||||
var replacement = [
|
||||
'(function (root, factory) {',
|
||||
' if (typeof exports === \'object\') {',
|
||||
' module.exports = factory();',
|
||||
' } else if (typeof define === \'function\' && define.amd) {',
|
||||
' define(factory);',
|
||||
' } else {',
|
||||
' root.Phaser = factory();',
|
||||
' }',
|
||||
'}(this, function () {',
|
||||
content,
|
||||
'return Phaser;',
|
||||
'}));'
|
||||
];
|
||||
return replacement.join('\n');
|
||||
};
|
||||
|
||||
var wrapAddonInUmd = function(content) {
|
||||
var replacement = [
|
||||
'(function (root, factory) {',
|
||||
' if (typeof exports === \'object\') {',
|
||||
' module.exports = factory(require(\'phaser\'));',
|
||||
' } else if (typeof define === \'function\' && define.amd) {',
|
||||
' define([\'phaser\'], factory);',
|
||||
' } else {',
|
||||
' factory(root.Phaser);',
|
||||
' }',
|
||||
'}(this, function (Phaser) {',
|
||||
content,
|
||||
'return Phaser;',
|
||||
'}));'
|
||||
];
|
||||
return replacement.join('\n');
|
||||
};
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
typescript: {
|
||||
base: {
|
||||
src: ['Phaser/**/*.ts'],
|
||||
dest: 'build/phaser.js',
|
||||
options: {
|
||||
target: 'ES5',
|
||||
declaration: true,
|
||||
comments: true
|
||||
}
|
||||
},
|
||||
fx: {
|
||||
src: ['SpecialFX/**/*.ts'],
|
||||
dest: 'build/phaser-fx.js',
|
||||
options: {
|
||||
target: 'ES5',
|
||||
declaration: true,
|
||||
comments: true
|
||||
}
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
main: {
|
||||
files: [{
|
||||
src: 'build/phaser.js',
|
||||
dest: 'Tests/phaser.js'
|
||||
}]
|
||||
},
|
||||
fx: {
|
||||
files: [{
|
||||
src: 'build/phaser-fx.js',
|
||||
dest: 'Tests/phaser-fx.js'
|
||||
}]
|
||||
},
|
||||
mainAmd: {
|
||||
files: [{
|
||||
src: 'build/phaser.js',
|
||||
dest: 'build/phaser.amd.js'
|
||||
}],
|
||||
options: {
|
||||
processContent: wrapPhaserInUmd
|
||||
}
|
||||
},
|
||||
fxAmd: {
|
||||
files: [{
|
||||
src: 'build/phaser-fx.js',
|
||||
dest: 'build/phaser-fx.amd.js'
|
||||
}],
|
||||
options: {
|
||||
processContent: wrapAddonInUmd
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files: '**/*.ts',
|
||||
tasks: ['typescript', 'copy']
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['typescript', 'copy', '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*
|
||||
|
||||
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="gameobjects/Sprite.d.ts" />
|
||||
/// <reference path="system/animation/Animation.d.ts" />
|
||||
/// <reference path="system/animation/AnimationLoader.d.ts" />
|
||||
/// <reference path="system/animation/Frame.d.ts" />
|
||||
/// <reference path="system/animation/FrameData.d.ts" />
|
||||
module Phaser {
|
||||
class AnimationManager {
|
||||
constructor(game: Game, parent: Sprite);
|
||||
private _game;
|
||||
private _parent;
|
||||
private _anims;
|
||||
private _frameIndex;
|
||||
private _frameData;
|
||||
public currentAnim: Animation;
|
||||
public currentFrame: Frame;
|
||||
public loadFrameData(frameData: FrameData): void;
|
||||
public add(name: string, frames?: any[], frameRate?: number, loop?: bool, useNumericIndex?: bool): void;
|
||||
private validateFrames(frames, useNumericIndex);
|
||||
public play(name: string, frameRate?: number, loop?: bool): void;
|
||||
public stop(name: string): void;
|
||||
public update(): void;
|
||||
public frameData : FrameData;
|
||||
public frameTotal : number;
|
||||
public frame : number;
|
||||
public frameName : string;
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Basic {
|
||||
constructor(game: Game);
|
||||
public _game: Game;
|
||||
public name: string;
|
||||
public ID: number;
|
||||
public isGroup: bool;
|
||||
public exists: bool;
|
||||
public active: bool;
|
||||
public visible: bool;
|
||||
public alive: bool;
|
||||
public ignoreDrawDebug: bool;
|
||||
public destroy(): void;
|
||||
public preUpdate(): void;
|
||||
public update(): void;
|
||||
public postUpdate(): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
public kill(): void;
|
||||
public revive(): void;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
-150
@@ -1,150 +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.ignoreGlobalUpdate = false;
|
||||
this.ignoreGlobalRender = 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 being updated during the main game loop (you will have to call update on it yourself)
|
||||
*/
|
||||
public ignoreGlobalUpdate: bool;
|
||||
|
||||
/**
|
||||
* Setting this to true will prevent the object from being rendered during the main game loop (you will have to call render on it yourself)
|
||||
*/
|
||||
public ignoreGlobalRender: 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(forceUpdate?: bool = false) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, forceRender?: bool = false) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-26
@@ -1,26 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Cache {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _canvases;
|
||||
private _images;
|
||||
private _sounds;
|
||||
private _text;
|
||||
public addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void;
|
||||
public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number): void;
|
||||
public addTextureAtlas(key: string, url: string, data, jsonData): void;
|
||||
public addImage(key: string, url: string, data): void;
|
||||
public addSound(key: string, url: string, data): void;
|
||||
public decodedSound(key: string, data): void;
|
||||
public addText(key: string, url: string, data): void;
|
||||
public getCanvas(key: string);
|
||||
public getImage(key: string);
|
||||
public getFrameData(key: string): FrameData;
|
||||
public getSound(key: string);
|
||||
public isSoundDecoded(key: string): bool;
|
||||
public isSpriteSheet(key: string): bool;
|
||||
public getText(key: string);
|
||||
public destroy(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-17
@@ -1,17 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/Camera.d.ts" />
|
||||
module Phaser {
|
||||
class CameraManager {
|
||||
constructor(game: Game, x: number, y: number, width: number, height: number);
|
||||
private _game;
|
||||
private _cameras;
|
||||
private _cameraInstance;
|
||||
public current: Camera;
|
||||
public getAll(): Camera[];
|
||||
public update(): void;
|
||||
public render(): void;
|
||||
public addCamera(x: number, y: number, width: number, height: number): Camera;
|
||||
public removeCamera(id: number): bool;
|
||||
public destroy(): void;
|
||||
}
|
||||
}
|
||||
@@ -1,138 +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.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class CameraManager {
|
||||
|
||||
/**
|
||||
* CameraManager constructor
|
||||
* This will create a new <code>Camera</code> with position and size.
|
||||
*
|
||||
* @param x {number} X Position of the created camera.
|
||||
* @param y {number} y Position of the created camera.
|
||||
* @param width {number} Width of the created camera.
|
||||
* @param height {number} Height of the created camera.
|
||||
*/
|
||||
constructor(game: Game, x: number, y: number, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this._cameras = [];
|
||||
|
||||
this.current = this.addCamera(x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to Game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Local container for storing cameras.
|
||||
*/
|
||||
private _cameras: Camera[];
|
||||
|
||||
/**
|
||||
* Local helper stores index of next created camera.
|
||||
*/
|
||||
private _cameraInstance: number = 0;
|
||||
|
||||
/**
|
||||
* Currently used camera.
|
||||
*/
|
||||
public current: Camera;
|
||||
|
||||
/**
|
||||
* Get all the cameras.
|
||||
*
|
||||
* @returns {Camera[]} An array contains all the cameras.
|
||||
*/
|
||||
public getAll(): Camera[] {
|
||||
return this._cameras;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cameras.
|
||||
*/
|
||||
public update() {
|
||||
this._cameras.forEach((camera) => camera.update());
|
||||
}
|
||||
|
||||
/**
|
||||
* Render cameras.
|
||||
*/
|
||||
public render() {
|
||||
this._cameras.forEach((camera) => camera.render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new camera with specific position and size.
|
||||
*
|
||||
* @param x {number} X position of the new camera.
|
||||
* @param y {number} Y position of the new camera.
|
||||
* @param width {number} Width of the new camera.
|
||||
* @param height {number} Height of the new camera.
|
||||
* @returns {Camera} The newly created camera object.
|
||||
*/
|
||||
public addCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
|
||||
var newCam: Camera = new Camera(this._game, this._cameraInstance, x, y, width, height);
|
||||
|
||||
this._cameras.push(newCam);
|
||||
|
||||
this._cameraInstance++;
|
||||
|
||||
return newCam;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a new camera with its id.
|
||||
*
|
||||
* @param id {number} ID of the camera you want to remove.
|
||||
* @returns {boolean} True if successfully removed the camera, otherwise return false.
|
||||
*/
|
||||
public removeCamera(id: number): bool {
|
||||
|
||||
for (var c = 0; c < this._cameras.length; c++)
|
||||
{
|
||||
if (this._cameras[c].ID == id)
|
||||
{
|
||||
if (this.current.ID === this._cameras[c].ID)
|
||||
{
|
||||
this.current = null;
|
||||
}
|
||||
|
||||
this._cameras.splice(c, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this._cameras.length = 0;
|
||||
|
||||
this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-53
@@ -1,53 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="geom/Point.d.ts" />
|
||||
/// <reference path="geom/Rectangle.d.ts" />
|
||||
/// <reference path="geom/Quad.d.ts" />
|
||||
/// <reference path="geom/Circle.d.ts" />
|
||||
/// <reference path="geom/Line.d.ts" />
|
||||
/// <reference path="geom/IntersectResult.d.ts" />
|
||||
/// <reference path="system/QuadTree.d.ts" />
|
||||
module Phaser {
|
||||
class Collision {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
static LEFT: number;
|
||||
static RIGHT: number;
|
||||
static UP: number;
|
||||
static DOWN: number;
|
||||
static NONE: number;
|
||||
static CEILING: number;
|
||||
static FLOOR: number;
|
||||
static WALL: number;
|
||||
static ANY: number;
|
||||
static OVERLAP_BIAS: number;
|
||||
static TILE_OVERLAP: bool;
|
||||
static _tempBounds: Quad;
|
||||
static lineToLine(line1: Line, line2: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineToLineSegment(line: Line, seg: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineToRawSegment(line: Line, x1: number, y1: number, x2: number, y2: number, output?: IntersectResult): IntersectResult;
|
||||
static lineToRay(line1: Line, ray: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineToCircle(line: Line, circle: Circle, output?: IntersectResult): IntersectResult;
|
||||
static lineToRectangle(line: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToLineSegment(line1: Line, line2: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToRay(line: Line, ray: Line, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToCircle(seg: Line, circle: Circle, output?: IntersectResult): IntersectResult;
|
||||
static lineSegmentToRectangle(seg: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rayToRectangle(ray: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rayToLineSegment(rayX1, rayY1, rayX2, rayY2, lineX1, lineY1, lineX2, lineY2, output?: IntersectResult): IntersectResult;
|
||||
static pointToRectangle(point, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rectangleToRectangle(rect1: Rectangle, rect2: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static rectangleToCircle(rect: Rectangle, circle: Circle, output?: IntersectResult): IntersectResult;
|
||||
static circleToCircle(circle1: Circle, circle2: Circle, output?: IntersectResult): IntersectResult;
|
||||
static circleToRectangle(circle: Circle, rect: Rectangle, output?: IntersectResult): IntersectResult;
|
||||
static circleContainsPoint(circle: Circle, point, output?: IntersectResult): IntersectResult;
|
||||
public overlap(object1?: Basic, object2?: Basic, notifyCallback?, processCallback?): bool;
|
||||
static separate(object1, object2): bool;
|
||||
static separateTile(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideLeft: bool, collideRight: bool, collideUp: bool, collideDown: bool): bool;
|
||||
static separateTileX(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideLeft: bool, collideRight: bool): bool;
|
||||
static separateTileY(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideUp: bool, collideDown: bool): bool;
|
||||
static separateX(object1, object2): bool;
|
||||
static separateY(object1, object2): bool;
|
||||
static distance(x1: number, y1: number, x2: number, y2: number): number;
|
||||
static distanceSquared(x1: number, y1: number, x2: number, y2: number): number;
|
||||
}
|
||||
}
|
||||
-1702
File diff suppressed because it is too large
Load Diff
Vendored
-32
@@ -1,32 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class DynamicTexture {
|
||||
constructor(game: Game, width: number, height: number);
|
||||
private _game;
|
||||
private _sx;
|
||||
private _sy;
|
||||
private _sw;
|
||||
private _sh;
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public bounds: Rectangle;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
public getPixel(x: number, y: number): number;
|
||||
public getPixel32(x: number, y: number): number;
|
||||
public getPixels(rect: Rectangle): ImageData;
|
||||
public setPixel(x: number, y: number, color: number): void;
|
||||
public setPixel32(x: number, y: number, color: number): void;
|
||||
public setPixels(rect: Rectangle, input): void;
|
||||
public fillRect(rect: Rectangle, color: number): void;
|
||||
public pasteImage(key: string, frame?: number, destX?: number, destY?: number, destWidth?: number, destHeight?: number): void;
|
||||
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point): void;
|
||||
public clear(): void;
|
||||
public width : number;
|
||||
public height : number;
|
||||
private getColor32(alpha, red, green, blue);
|
||||
private getColor(red, green, blue);
|
||||
}
|
||||
}
|
||||
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class FXManager {
|
||||
constructor(game: Game);
|
||||
private _fx;
|
||||
private _length;
|
||||
private _game;
|
||||
public active: bool;
|
||||
public visible: bool;
|
||||
public add(effect): any;
|
||||
public preUpdate(): void;
|
||||
public postUpdate(): void;
|
||||
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
public render(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
public destroy(): void;
|
||||
}
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FXManager
|
||||
*
|
||||
* The FXManager controls all special effects applied to game objects such as Cameras.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class FXManager {
|
||||
|
||||
constructor(game: Game, parent) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
this._fx = [];
|
||||
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The essential reference to the main game object.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* A reference to the object that owns this FXManager instance.
|
||||
*/
|
||||
private _parent;
|
||||
|
||||
/**
|
||||
* The array in which we keep all of the registered FX
|
||||
*/
|
||||
private _fx;
|
||||
|
||||
/**
|
||||
* Holds the size of the _fx array
|
||||
*/
|
||||
private _length: number;
|
||||
|
||||
/**
|
||||
* Controls whether any of the FX have preUpdate, update or postUpdate called
|
||||
*/
|
||||
public active: bool;
|
||||
|
||||
/**
|
||||
* Controls whether any of the FX have preRender, render or postRender called
|
||||
*/
|
||||
public visible: bool;
|
||||
|
||||
/**
|
||||
* Adds a new FX to the FXManager.
|
||||
* The effect must be an object with at least one of the following methods: preUpdate, postUpdate, preRender, render or postRender.
|
||||
* A new instance of the effect will be created and a reference to Game will be passed to the object constructor.
|
||||
* @param {object} effect
|
||||
* @return {any}
|
||||
*/
|
||||
public add(effect): any {
|
||||
|
||||
var result: bool = false;
|
||||
var newEffect = { effect: {}, preUpdate: false, postUpdate: false, preRender: false, render: false, postRender: false };
|
||||
|
||||
if (typeof effect === 'function')
|
||||
{
|
||||
newEffect.effect = new effect(this._game, this._parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Error("Invalid object given to Phaser.FXManager.add");
|
||||
}
|
||||
|
||||
// Check for methods now to avoid having to do this every loop
|
||||
|
||||
if (typeof newEffect.effect['preUpdate'] === 'function')
|
||||
{
|
||||
newEffect.preUpdate = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['postUpdate'] === 'function')
|
||||
{
|
||||
newEffect.postUpdate = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['preRender'] === 'function')
|
||||
{
|
||||
newEffect.preRender = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['render'] === 'function')
|
||||
{
|
||||
newEffect.render = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (typeof newEffect.effect['postRender'] === 'function')
|
||||
{
|
||||
newEffect.postRender = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
this._length = this._fx.push(newEffect);
|
||||
|
||||
return newEffect.effect;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-update is called at the start of the objects update cycle, before any other updates have taken place.
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
if (this.active)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].preUpdate)
|
||||
{
|
||||
this._fx[i].effect.preUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
*/
|
||||
public postUpdate() {
|
||||
|
||||
if (this.active)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].postUpdate)
|
||||
{
|
||||
this._fx[i].effect.postUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-render is called at the start of the object render cycle, before any transforms have taken place.
|
||||
* It happens directly AFTER a canvas context.save has happened if added to a Camera.
|
||||
* @param {Camera} camera
|
||||
* @param {number} cameraX
|
||||
* @param {number} cameraY
|
||||
* @param {number} cameraWidth
|
||||
* @param {number} cameraHeight
|
||||
*/
|
||||
public preRender(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].preRender)
|
||||
{
|
||||
this._fx[i].effect.preRender(camera, cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
* @param {Camera} camera
|
||||
* @param {number} cameraX
|
||||
* @param {number} cameraY
|
||||
* @param {number} cameraWidth
|
||||
* @param {number} cameraHeight
|
||||
*/
|
||||
public render(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].preRender)
|
||||
{
|
||||
this._fx[i].effect.preRender(camera, cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
for (var i = 0; i < this._length; i++)
|
||||
{
|
||||
if (this._fx[i].postRender)
|
||||
{
|
||||
this._fx[i].effect.postRender(camera, cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear down this FXManager and null out references
|
||||
*/
|
||||
public destroy() {
|
||||
this._game = null;
|
||||
this._fx = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-88
@@ -1,88 +0,0 @@
|
||||
/// <reference path="AnimationManager.d.ts" />
|
||||
/// <reference path="Basic.d.ts" />
|
||||
/// <reference path="Cache.d.ts" />
|
||||
/// <reference path="CameraManager.d.ts" />
|
||||
/// <reference path="Collision.d.ts" />
|
||||
/// <reference path="DynamicTexture.d.ts" />
|
||||
/// <reference path="FXManager.d.ts" />
|
||||
/// <reference path="GameMath.d.ts" />
|
||||
/// <reference path="Group.d.ts" />
|
||||
/// <reference path="Loader.d.ts" />
|
||||
/// <reference path="Motion.d.ts" />
|
||||
/// <reference path="Signal.d.ts" />
|
||||
/// <reference path="SignalBinding.d.ts" />
|
||||
/// <reference path="SoundManager.d.ts" />
|
||||
/// <reference path="Stage.d.ts" />
|
||||
/// <reference path="Time.d.ts" />
|
||||
/// <reference path="TweenManager.d.ts" />
|
||||
/// <reference path="World.d.ts" />
|
||||
/// <reference path="system/Device.d.ts" />
|
||||
/// <reference path="system/RandomDataGenerator.d.ts" />
|
||||
/// <reference path="system/RequestAnimationFrame.d.ts" />
|
||||
/// <reference path="system/input/Input.d.ts" />
|
||||
/// <reference path="system/input/Keyboard.d.ts" />
|
||||
/// <reference path="system/input/Mouse.d.ts" />
|
||||
/// <reference path="system/input/Touch.d.ts" />
|
||||
/// <reference path="gameobjects/Emitter.d.ts" />
|
||||
/// <reference path="gameobjects/GameObject.d.ts" />
|
||||
/// <reference path="gameobjects/GeomSprite.d.ts" />
|
||||
/// <reference path="gameobjects/Particle.d.ts" />
|
||||
/// <reference path="gameobjects/Sprite.d.ts" />
|
||||
/// <reference path="gameobjects/Tilemap.d.ts" />
|
||||
/// <reference path="gameobjects/ScrollZone.d.ts" />
|
||||
module Phaser {
|
||||
class Game {
|
||||
constructor(callbackContext, parent?: string, width?: number, height?: number, initCallback?, createCallback?, updateCallback?, renderCallback?);
|
||||
private _raf;
|
||||
private _maxAccumulation;
|
||||
private _accumulator;
|
||||
private _step;
|
||||
private _loadComplete;
|
||||
private _paused;
|
||||
private _pendingState;
|
||||
public callbackContext;
|
||||
public onInitCallback;
|
||||
public onCreateCallback;
|
||||
public onUpdateCallback;
|
||||
public onRenderCallback;
|
||||
public onPausedCallback;
|
||||
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;
|
||||
public isRunning: bool;
|
||||
private boot(parent, width, height);
|
||||
private loadComplete();
|
||||
private bootLoop();
|
||||
private pausedLoop();
|
||||
private loop();
|
||||
private startState();
|
||||
public setCallbacks(initCallback?, createCallback?, updateCallback?, renderCallback?): void;
|
||||
public switchState(state, clearWorld?: bool, clearCache?: bool): void;
|
||||
public destroy(): void;
|
||||
public paused : bool;
|
||||
public framerate : number;
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera;
|
||||
public createGeomSprite(x: number, y: number): GeomSprite;
|
||||
public createSprite(x: number, y: number, key?: string): Sprite;
|
||||
public createDynamicTexture(width: number, height: number): DynamicTexture;
|
||||
public createGroup(MaxSize?: number): Group;
|
||||
public createParticle(): Particle;
|
||||
public createEmitter(x?: number, y?: number, size?: number): Emitter;
|
||||
public createScrollZone(key: string, x?: number, y?: number, width?: number, height?: number): ScrollZone;
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number): Tilemap;
|
||||
public createTween(obj): Tween;
|
||||
public collide(objectOrGroup1?: Basic, objectOrGroup2?: Basic, notifyCallback?): bool;
|
||||
public camera : Camera;
|
||||
}
|
||||
}
|
||||
Vendored
-110
@@ -1,110 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class GameMath {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
static PI: number;
|
||||
static PI_2: number;
|
||||
static PI_4: number;
|
||||
static PI_8: number;
|
||||
static PI_16: number;
|
||||
static TWO_PI: number;
|
||||
static THREE_PI_2: number;
|
||||
static E: number;
|
||||
static LN10: number;
|
||||
static LN2: number;
|
||||
static LOG10E: number;
|
||||
static LOG2E: number;
|
||||
static SQRT1_2: number;
|
||||
static SQRT2: number;
|
||||
static DEG_TO_RAD: number;
|
||||
static RAD_TO_DEG: number;
|
||||
static B_16: number;
|
||||
static B_31: number;
|
||||
static B_32: number;
|
||||
static B_48: number;
|
||||
static B_53: number;
|
||||
static B_64: number;
|
||||
static ONE_THIRD: number;
|
||||
static TWO_THIRDS: number;
|
||||
static ONE_SIXTH: number;
|
||||
static COS_PI_3: number;
|
||||
static SIN_2PI_3: number;
|
||||
static CIRCLE_ALPHA: number;
|
||||
static ON: bool;
|
||||
static OFF: bool;
|
||||
static SHORT_EPSILON: number;
|
||||
static PERC_EPSILON: number;
|
||||
static EPSILON: number;
|
||||
static LONG_EPSILON: number;
|
||||
public cosTable: any[];
|
||||
public sinTable: any[];
|
||||
public fuzzyEqual(a: number, b: number, epsilon?: number): bool;
|
||||
public fuzzyLessThan(a: number, b: number, epsilon?: number): bool;
|
||||
public fuzzyGreaterThan(a: number, b: number, epsilon?: number): bool;
|
||||
public fuzzyCeil(val: number, epsilon?: number): number;
|
||||
public fuzzyFloor(val: number, epsilon?: number): number;
|
||||
public average(...args: any[]): number;
|
||||
public slam(value: number, target: number, epsilon?: number): number;
|
||||
public percentageMinMax(val: number, max: number, min?: number): number;
|
||||
public sign(n: number): number;
|
||||
public truncate(n: number): number;
|
||||
public shear(n: number): number;
|
||||
public wrap(val: number, max: number, min?: number): number;
|
||||
public arithWrap(value: number, max: number, min?: number): number;
|
||||
public clamp(input: number, max: number, min?: number): number;
|
||||
public snapTo(input: number, gap: number, start?: number): number;
|
||||
public snapToFloor(input: number, gap: number, start?: number): number;
|
||||
public snapToCeil(input: number, gap: number, start?: number): number;
|
||||
public snapToInArray(input: number, arr: number[], sort?: bool): number;
|
||||
public roundTo(value: number, place?: number, base?: number): number;
|
||||
public floorTo(value: number, place?: number, base?: number): number;
|
||||
public ceilTo(value: number, place?: number, base?: number): number;
|
||||
public interpolateFloat(a: number, b: number, weight: number): number;
|
||||
public radiansToDegrees(angle: number): number;
|
||||
public degreesToRadians(angle: number): number;
|
||||
public angleBetween(x1: number, y1: number, x2: number, y2: number): number;
|
||||
public normalizeAngle(angle: number, radians?: bool): number;
|
||||
public nearestAngleBetween(a1: number, a2: number, radians?: bool): number;
|
||||
public normalizeAngleToAnother(dep: number, ind: number, radians?: bool): number;
|
||||
public normalizeAngleAfterAnother(dep: number, ind: number, radians?: bool): number;
|
||||
public normalizeAngleBeforeAnother(dep: number, ind: number, radians?: bool): number;
|
||||
public interpolateAngles(a1: number, a2: number, weight: number, radians?: bool, ease?): number;
|
||||
public logBaseOf(value: number, base: number): number;
|
||||
public GCD(m: number, n: number): number;
|
||||
public LCM(m: number, n: number): number;
|
||||
public factorial(value: number): number;
|
||||
public gammaFunction(value: number): number;
|
||||
public fallingFactorial(base: number, exp: number): number;
|
||||
public risingFactorial(base: number, exp: number): number;
|
||||
public binCoef(n: number, k: number): number;
|
||||
public risingBinCoef(n: number, k: number): number;
|
||||
public chanceRoll(chance?: number): bool;
|
||||
public maxAdd(value: number, amount: number, max: number): number;
|
||||
public minSub(value: number, amount: number, min: number): number;
|
||||
public wrapValue(value: number, amount: number, max: number): number;
|
||||
public randomSign(): number;
|
||||
public isOdd(n: number): bool;
|
||||
public isEven(n: number): bool;
|
||||
public wrapAngle(angle: number): number;
|
||||
public angleLimit(angle: number, min: number, max: number): number;
|
||||
public linearInterpolation(v, k);
|
||||
public bezierInterpolation(v, k): number;
|
||||
public catmullRomInterpolation(v, k);
|
||||
public linear(p0, p1, t);
|
||||
public bernstein(n, i): number;
|
||||
public catmullRom(p0, p1, p2, p3, t);
|
||||
public difference(a: number, b: number): number;
|
||||
public globalSeed: number;
|
||||
public random(): number;
|
||||
public srand(Seed: number): number;
|
||||
public getRandom(Objects, StartIndex?: number, Length?: number);
|
||||
public floor(Value: number): number;
|
||||
public ceil(Value: number): number;
|
||||
public sinCosGenerator(length: number, sinAmplitude?: number, cosAmplitude?: number, frequency?: number): any[];
|
||||
public shiftSinTable(): number;
|
||||
public shiftCosTable(): number;
|
||||
public vectorLength(dx: number, dy: number): number;
|
||||
public dotProduct(ax: number, ay: number, bx: number, by: number): number;
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - GameObjectFactory
|
||||
*
|
||||
* A quick way to create new world objects and add existing objects to the current world.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class GameObjectFactory {
|
||||
|
||||
/**
|
||||
* GameObjectFactory constructor
|
||||
* @param game {Game} A reference to the current Game.
|
||||
*/
|
||||
constructor(game: Phaser.Game) {
|
||||
|
||||
this._game = game;
|
||||
this._world = this._game.world;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to Game
|
||||
*/
|
||||
private _game: Phaser.Game;
|
||||
|
||||
/**
|
||||
* Local private reference to World
|
||||
*/
|
||||
private _world: Phaser.World;
|
||||
|
||||
/**
|
||||
* Create a new camera with specific position and size.
|
||||
*
|
||||
* @param x {number} X position of the new camera.
|
||||
* @param y {number} Y position of the new camera.
|
||||
* @param width {number} Width of the new camera.
|
||||
* @param height {number} Height of the new camera.
|
||||
* @returns {Camera} The newly created camera object.
|
||||
*/
|
||||
public camera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this._world.createCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new GeomSprite with specific position.
|
||||
*
|
||||
* @param x {number} X position of the new geom sprite.
|
||||
* @param y {number} Y position of the new geom sprite.
|
||||
* @returns {GeomSprite} The newly created geom sprite object.
|
||||
*/
|
||||
public geomSprite(x: number, y: number): GeomSprite {
|
||||
return this._world.createGeomSprite(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Sprite with specific position and sprite sheet key.
|
||||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param key {string} Optional, key for the sprite sheet you want it to use.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
public sprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return this._world.createSprite(x, y, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DynamicTexture with specific size.
|
||||
*
|
||||
* @param width {number} Width of the texture.
|
||||
* @param height {number} Height of the texture.
|
||||
* @returns {DynamicTexture} The newly created dynamic texture object.
|
||||
*/
|
||||
public dynamicTexture(width: number, height: number): DynamicTexture {
|
||||
return this._world.createDynamicTexture(width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param maxSize {number} Optional, capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public group(maxSize?: number = 0): Group {
|
||||
return this._world.createGroup(maxSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Particle.
|
||||
*
|
||||
* @return {Particle} The newly created particle object.
|
||||
*/
|
||||
public particle(): Particle {
|
||||
return this._world.createParticle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Emitter.
|
||||
*
|
||||
* @param x {number} Optional, x position of the emitter.
|
||||
* @param y {number} Optional, y position of the emitter.
|
||||
* @param size {number} Optional, size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
public emitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return this._world.createEmitter(x, y, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
*
|
||||
* @param key {string} Key to a image you wish this object to use.
|
||||
* @param x {number} X position of this object.
|
||||
* @param y {number} Y position of this object.
|
||||
* @param width number} Width of this object.
|
||||
* @param height {number} Height of this object.
|
||||
* @returns {ScrollZone} The newly created scroll zone object.
|
||||
*/
|
||||
public scrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
|
||||
return this._world.createScrollZone(key, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Tilemap.
|
||||
*
|
||||
* @param key {string} Key for tileset image.
|
||||
* @param mapData {string} Data of this tilemap.
|
||||
* @param format {number} Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
|
||||
* @param [resizeWorld] {boolean} resize the world to make same as tilemap?
|
||||
* @param [tileWidth] {number} width of each tile.
|
||||
* @param [tileHeight] {number} height of each tile.
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
return this._world.createTilemap(key, mapData, format, resizeWorld, tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a tween object for a specific object.
|
||||
*
|
||||
* @param obj Object you wish the tween will affect.
|
||||
* @return {Phaser.Tween} The newly created tween object.
|
||||
*/
|
||||
public tween(obj): Tween {
|
||||
return this._game.tweens.create(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an existing Sprite to the current world.
|
||||
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
|
||||
*
|
||||
* @param sprite The Sprite to add to the Game World
|
||||
* @return {Phaser.Sprite} The Sprite object
|
||||
*/
|
||||
public existingSprite(sprite: Sprite): Sprite {
|
||||
return this._world.group.add(sprite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an existing GeomSprite to the current world.
|
||||
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
|
||||
*
|
||||
* @param sprite The GeomSprite to add to the Game World
|
||||
* @return {Phaser.GeomSprite} The GeomSprite object
|
||||
*/
|
||||
public existingGeomSprite(sprite: GeomSprite): GeomSprite {
|
||||
return this._world.group.add(sprite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an existing Emitter to the current world.
|
||||
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
|
||||
*
|
||||
* @param emitter The Emitter to add to the Game World
|
||||
* @return {Phaser.Emitter} The Emitter object
|
||||
*/
|
||||
public existingEmitter(emitter: Emitter): Emitter {
|
||||
return this._world.group.add(emitter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an existing ScrollZone to the current world.
|
||||
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
|
||||
*
|
||||
* @param scrollZone The ScrollZone to add to the Game World
|
||||
* @return {Phaser.ScrollZone} The ScrollZone object
|
||||
*/
|
||||
public existingScrollZone(scrollZone: ScrollZone): ScrollZone {
|
||||
return this._world.group.add(scrollZone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an existing Tilemap to the current world.
|
||||
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
|
||||
*
|
||||
* @param tilemap The Tilemap to add to the Game World
|
||||
* @return {Phaser.Tilemap} The Tilemap object
|
||||
*/
|
||||
public existingTilemap(tilemap: Tilemap): Tilemap {
|
||||
return this._world.group.add(tilemap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an existing Tween to the current world.
|
||||
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
|
||||
*
|
||||
* @param tween The Tween to add to the Game World
|
||||
* @return {Phaser.Tween} The Tween object
|
||||
*/
|
||||
public existingTween(tween: Tween): Tween {
|
||||
return this._game.tweens.add(tween);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-39
@@ -1,39 +0,0 @@
|
||||
/// <reference path="Basic.d.ts" />
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Group extends Basic {
|
||||
constructor(game: Game, MaxSize?: number);
|
||||
static ASCENDING: number;
|
||||
static DESCENDING: number;
|
||||
public members: Basic[];
|
||||
public length: number;
|
||||
private _maxSize;
|
||||
private _marker;
|
||||
private _sortIndex;
|
||||
private _sortOrder;
|
||||
public destroy(): void;
|
||||
public update(): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
public maxSize : number;
|
||||
public add(Object: Basic): Basic;
|
||||
public recycle(ObjectClass?);
|
||||
public remove(Object: Basic, Splice?: bool): Basic;
|
||||
public replace(OldObject: Basic, NewObject: Basic): Basic;
|
||||
public sort(Index?: string, Order?: number): void;
|
||||
public setAll(VariableName: string, Value: Object, Recurse?: bool): void;
|
||||
public callAll(FunctionName: string, Recurse?: bool): void;
|
||||
public forEach(callback, recursive?: bool): void;
|
||||
public forEachAlive(context, callback, recursive?: bool): void;
|
||||
public getFirstAvailable(ObjectClass?);
|
||||
public getFirstNull(): number;
|
||||
public getFirstExtant(): Basic;
|
||||
public getFirstAlive(): Basic;
|
||||
public getFirstDead(): Basic;
|
||||
public countLiving(): number;
|
||||
public countDead(): number;
|
||||
public getRandom(StartIndex?: number, Length?: number): Basic;
|
||||
public clear(): void;
|
||||
public kill(): void;
|
||||
public sortHandler(Obj1: Basic, Obj2: Basic): number;
|
||||
}
|
||||
}
|
||||
-872
@@ -1,872 +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;
|
||||
this.cameraBlacklist = [];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* You can set a globalCompositeOperation that will be applied before the render method is called on this Groups children.
|
||||
* This is useful if you wish to apply an effect like 'lighten' to a whole group of children as it saves doing it one-by-one.
|
||||
* If this value is set it will call a canvas context save and restore before and after the render pass.
|
||||
* Set to null to disable.
|
||||
*/
|
||||
public globalCompositeOperation: string = null;
|
||||
|
||||
/**
|
||||
* You can set an alpha value on this Group that will be applied before the render method is called on this Groups children.
|
||||
* This is useful if you wish to alpha a whole group of children as it saves doing it one-by-one.
|
||||
* Set to 0 to disable.
|
||||
*/
|
||||
public alpha: number = 0;
|
||||
|
||||
/**
|
||||
* An Array of Cameras to which this Group, or any of its children, won't render
|
||||
* @type {Array}
|
||||
*/
|
||||
public cameraBlacklist: number[];
|
||||
|
||||
/**
|
||||
* If you do not wish this object to be visible to a specific camera, pass the camera here.
|
||||
*
|
||||
* @param camera {Camera} The specific camera.
|
||||
*/
|
||||
public hideFromCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) == -1)
|
||||
{
|
||||
this.cameraBlacklist.push(camera.ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Make this object only visible to a specific camera.
|
||||
*
|
||||
* @param camera {Camera} The camera you wish it to be visible.
|
||||
*/
|
||||
public showToCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) !== -1)
|
||||
{
|
||||
this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This clears the camera black list, making the GameObject visible to all cameras.
|
||||
*/
|
||||
public clearCameraList() {
|
||||
|
||||
this.cameraBlacklist.length = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(forceUpdate?: bool = false) {
|
||||
|
||||
if (this.ignoreGlobalUpdate && forceUpdate == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.active && basic.ignoreGlobalUpdate == false)
|
||||
{
|
||||
basic.preUpdate();
|
||||
basic.update(forceUpdate);
|
||||
basic.postUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically goes through and calls render on everything you added.
|
||||
*/
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number, forceRender?: bool = false) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) !== -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.ignoreGlobalRender && forceRender == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.globalCompositeOperation)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
this._game.stage.context.globalCompositeOperation = this.globalCompositeOperation;
|
||||
}
|
||||
|
||||
if (this.alpha > 0)
|
||||
{
|
||||
var prevAlpha: number = this._game.stage.context.globalAlpha;
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
var basic: Basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if ((basic != null) && basic.exists && basic.visible && basic.ignoreGlobalRender == false)
|
||||
{
|
||||
basic.render(camera, cameraOffsetX, cameraOffsetY, forceRender);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.alpha > 0)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = prevAlpha;
|
||||
}
|
||||
|
||||
if (this.globalCompositeOperation)
|
||||
{
|
||||
this._game.stage.context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, GameObject, Sprite, 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 {Basic} Object The object you want to add to the group.
|
||||
* @return {Basic} The same <code>Basic</code> object that was passed in.
|
||||
*/
|
||||
public add(Object: Basic): any {
|
||||
|
||||
//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 {class} ObjectClass The class type you want to recycle (e.g. Basic, EvilRobot, etc). Do NOT "new" the class in the parameter!
|
||||
*
|
||||
* @return {any} 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(this._game));
|
||||
}
|
||||
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(this._game));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an object from the group.
|
||||
*
|
||||
* @param {Basic} object The <code>Basic</code> you want to remove.
|
||||
* @param {boolean} splice Whether the object should be cut from the array entirely or not.
|
||||
*
|
||||
* @return {Basic} 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 {Basic} oldObject The object you want to replace.
|
||||
* @param {Basic} newObject The new object you want to use instead.
|
||||
*
|
||||
* @return {Basic} 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 {string} index The <code>string</code> name of the member variable you want to sort on. Default value is "y".
|
||||
* @param {number} 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 {string} VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor".
|
||||
* @param {Object} Value The value you want to assign to that variable.
|
||||
* @param {boolean} 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 {string} FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()".
|
||||
* @param {boolean} 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]();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function} callback
|
||||
* @param {boolean} recursive
|
||||
*/
|
||||
public forEach(callback, recursive: bool = false) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null)
|
||||
{
|
||||
if (recursive && (basic.isGroup == true))
|
||||
{
|
||||
basic.forEach(callback, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(this, basic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} context
|
||||
* @param {function} callback
|
||||
* @param {boolean} recursive
|
||||
*/
|
||||
public forEachAlive(context, callback, recursive: bool = false) {
|
||||
|
||||
var basic;
|
||||
var i: number = 0;
|
||||
|
||||
while (i < this.length)
|
||||
{
|
||||
basic = this.members[i++];
|
||||
|
||||
if (basic != null && basic.alive)
|
||||
{
|
||||
if (recursive && (basic.isGroup == true))
|
||||
{
|
||||
basic.forEachAlive(context, callback, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.call(context, 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 {any} [ObjectClass] An optional parameter that lets you narrow the results to instances of this particular class.
|
||||
*
|
||||
* @return {any} 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 {number} 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 {Basic} 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 {Basic} 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 {Basic} 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 {number} 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 {number} 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 {number} StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
|
||||
* @param {number} Length Optional restriction on the number of values you want to randomly select from.
|
||||
*
|
||||
* @return {Basic} 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 {Basic} Obj1 The first object being sorted.
|
||||
* @param {Basic} Obj2 The second object being sorted.
|
||||
*
|
||||
* @return {number} 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Loader {
|
||||
constructor(game: Game, callback);
|
||||
private _game;
|
||||
private _keys;
|
||||
private _fileList;
|
||||
private _gameCreateComplete;
|
||||
private _onComplete;
|
||||
private _onFileLoad;
|
||||
private _progressChunk;
|
||||
private _xhr;
|
||||
private _queueSize;
|
||||
public hasLoaded: bool;
|
||||
public progress: number;
|
||||
public reset(): void;
|
||||
public queueSize : number;
|
||||
public addImageFile(key: string, url: string): void;
|
||||
public addSpriteSheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number): void;
|
||||
public addTextureAtlas(key: string, url: string, jsonURL?: string, jsonData?): void;
|
||||
public addAudioFile(key: string, url: string): void;
|
||||
public addTextFile(key: string, url: string): void;
|
||||
public removeFile(key: string): void;
|
||||
public removeAll(): void;
|
||||
public load(onFileLoadCallback?, onCompleteCallback?): void;
|
||||
private loadFile();
|
||||
private fileError(key);
|
||||
private fileComplete(key);
|
||||
private jsonLoadComplete(key);
|
||||
private jsonLoadError(key);
|
||||
private nextFile(previousKey, success);
|
||||
private checkKeyExists(key);
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="gameobjects/GameObject.d.ts" />
|
||||
module Phaser {
|
||||
class Motion {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
public computeVelocity(Velocity: number, Acceleration?: number, Drag?: number, Max?: number): number;
|
||||
public velocityFromAngle(angle: number, speed: number): Point;
|
||||
public moveTowardsObject(source: GameObject, dest: GameObject, speed?: number, maxTime?: number): void;
|
||||
public accelerateTowardsObject(source: GameObject, dest: GameObject, speed: number, xSpeedMax: number, ySpeedMax: number): void;
|
||||
public moveTowardsMouse(source: GameObject, speed?: number, maxTime?: number): void;
|
||||
public accelerateTowardsMouse(source: GameObject, speed: number, xSpeedMax: number, ySpeedMax: number): void;
|
||||
public moveTowardsPoint(source: GameObject, target: Point, speed?: number, maxTime?: number): void;
|
||||
public accelerateTowardsPoint(source: GameObject, target: Point, speed: number, xSpeedMax: number, ySpeedMax: number): void;
|
||||
public distanceBetween(a: GameObject, b: GameObject): number;
|
||||
public distanceToPoint(a: GameObject, target: Point): number;
|
||||
public distanceToMouse(a: GameObject): number;
|
||||
public angleBetweenPoint(a: GameObject, target: Point, asDegrees?: bool): number;
|
||||
public angleBetween(a: GameObject, b: GameObject, asDegrees?: bool): number;
|
||||
public velocityFromFacing(parent: GameObject, speed: number): Point;
|
||||
public angleBetweenMouse(a: GameObject, asDegrees?: bool): number;
|
||||
}
|
||||
}
|
||||
@@ -1,409 +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 {number} Velocity Any component of velocity (e.g. 20).
|
||||
* @param {number} Acceleration Rate at which the velocity is changing.
|
||||
* @param {number} Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
|
||||
* @param {number} Max An absolute value cap for the velocity.
|
||||
*
|
||||
* @return {number} 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 {number} angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
|
||||
* @param {number} speed The speed it will move, in pixels per second sq
|
||||
*
|
||||
* @return {Point} 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 {
|
||||
|
||||
if (isNaN(speed))
|
||||
{
|
||||
speed = 0;
|
||||
}
|
||||
|
||||
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 {GameObject} source The Sprite on which the velocity will be set
|
||||
* @param {GameObject} dest The Sprite where the source object will move to
|
||||
* @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec)
|
||||
* @param {number} 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 {GameObject} source The Sprite on which the acceleration will be set
|
||||
* @param {GameObject} dest The Sprite where the source object will move towards
|
||||
* @param {number} speed The speed it will accelerate in pixels per second
|
||||
* @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
|
||||
* @param {number} 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 {GameObject} source The Sprite to move
|
||||
* @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec)
|
||||
* @param {number} 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 {GameObject} source The Sprite on which the acceleration will be set
|
||||
* @param {number} speed The speed it will accelerate in pixels per second
|
||||
* @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
|
||||
* @param {number} 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 {GameObject} source The Sprite to move
|
||||
* @param {Point} target The Point coordinates to move the source Sprite towards
|
||||
* @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec)
|
||||
* @param {number} 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 {GameObject} source The Sprite on which the acceleration will be set
|
||||
* @param {Point} target The Point coordinates to move the source Sprite towards
|
||||
* @param {number} speed The speed it will accelerate in pixels per second
|
||||
* @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
|
||||
* @param {number} 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 {GameObject} a The first Sprite
|
||||
* @param {GameObject} b The second Sprite
|
||||
* @return {number} 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 {GameObject} a The Sprite
|
||||
* @param {Point} target The Point
|
||||
* @return {number} 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 {GameObject} a Sprite to test against
|
||||
* @return {number} 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 {GameObject} a The Sprite to test from
|
||||
* @param {Point} target The Point to angle the Sprite towards
|
||||
* @param {boolean} 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 {GameObject} a The Sprite to test from
|
||||
* @param {GameObject} b The Sprite to test to
|
||||
* @param {boolean} 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 {GameObject} parent The Sprite to get the facing value from
|
||||
* @param {number} speed The speed it will move, in pixels per second sq
|
||||
*
|
||||
* @return {Point} 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 {GameObject} a The Object to test from
|
||||
* @param {boolean} 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,397 +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>
|
||||
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
|
||||
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>
|
||||
</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>
|
||||
<TypeScriptCompile Include="FXManager.ts" />
|
||||
<Content Include="FXManager.js">
|
||||
<DependentUpon>FXManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Game.js">
|
||||
<DependentUpon>Game.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="GameMath.js">
|
||||
<DependentUpon>GameMath.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="GameObjectFactory.ts" />
|
||||
<Content Include="GameObjectFactory.js">
|
||||
<DependentUpon>GameObjectFactory.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>
|
||||
<TypeScriptCompile Include="gameobjects\ScrollZone.ts" />
|
||||
<TypeScriptCompile Include="gameobjects\ScrollRegion.ts" />
|
||||
<Content Include="gameobjects\ScrollRegion.js">
|
||||
<DependentUpon>ScrollRegion.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\ScrollZone.js">
|
||||
<DependentUpon>ScrollZone.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Sprite.js">
|
||||
<DependentUpon>Sprite.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="gameobjects\Tilemap.js">
|
||||
<DependentUpon>Tilemap.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="verlet\AngleConstraint.ts" />
|
||||
<TypeScriptCompile Include="VerletManager.ts" />
|
||||
<TypeScriptCompile Include="geom\Polygon.ts" />
|
||||
<Content Include="geom\Polygon.js">
|
||||
<DependentUpon>Polygon.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Response.ts" />
|
||||
<Content Include="geom\Response.js">
|
||||
<DependentUpon>Response.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="VerletManager.js">
|
||||
<DependentUpon>VerletManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="verlet\AngleConstraint.js">
|
||||
<DependentUpon>AngleConstraint.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Circle.js">
|
||||
<DependentUpon>Circle.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="verlet\DistanceConstraint.ts" />
|
||||
<TypeScriptCompile Include="verlet\Composite.ts" />
|
||||
<Content Include="verlet\Composite.js">
|
||||
<DependentUpon>Composite.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="verlet\DistanceConstraint.js">
|
||||
<DependentUpon>DistanceConstraint.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>
|
||||
<TypeScriptCompile Include="verlet\PinConstraint.ts" />
|
||||
<TypeScriptCompile Include="verlet\Particle.ts" />
|
||||
<Content Include="verlet\Particle.js">
|
||||
<DependentUpon>Particle.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="verlet\PinConstraint.js">
|
||||
<DependentUpon>PinConstraint.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Point.js">
|
||||
<DependentUpon>Point.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Quad.ts" />
|
||||
<Content Include="geom\Quad.js">
|
||||
<DependentUpon>Quad.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="geom\Rectangle.js">
|
||||
<DependentUpon>Rectangle.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="geom\Vector2.ts" />
|
||||
<Content Include="geom\Vector2.js">
|
||||
<DependentUpon>Vector2.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="SoundManager.js">
|
||||
<DependentUpon>SoundManager.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="system\screens\PauseScreen.ts" />
|
||||
<TypeScriptCompile Include="system\screens\BootScreen.ts" />
|
||||
<TypeScriptCompile Include="system\input\MSPointer.ts" />
|
||||
<TypeScriptCompile Include="system\input\Gestures.ts" />
|
||||
<TypeScriptCompile Include="system\CollisionMask.ts" />
|
||||
<Content Include="system\CollisionMask.js">
|
||||
<DependentUpon>CollisionMask.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\input\Gestures.js">
|
||||
<DependentUpon>Gestures.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\input\MSPointer.js">
|
||||
<DependentUpon>MSPointer.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="system\input\Pointer.ts" />
|
||||
<Content Include="system\input\Pointer.js">
|
||||
<DependentUpon>Pointer.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\screens\BootScreen.js">
|
||||
<DependentUpon>BootScreen.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\screens\PauseScreen.js">
|
||||
<DependentUpon>PauseScreen.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>
|
||||
<TypeScriptCompile Include="system\TilemapLayer.ts" />
|
||||
<Content Include="system\TilemapLayer.js">
|
||||
<DependentUpon>TilemapLayer.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="system\Tween.js">
|
||||
<DependentUpon>Tween.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="system\Tween.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\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\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>
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
module Phaser {
|
||||
var VERSION: string;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Phaser
|
||||
*
|
||||
* v0.9.6 - May 21st 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 releasing Flixel on which Phaser took a lot of inspiration.
|
||||
*
|
||||
* "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.6';
|
||||
|
||||
}
|
||||
Vendored
-26
@@ -1,26 +0,0 @@
|
||||
/// <reference path="SignalBinding.d.ts" />
|
||||
module Phaser {
|
||||
class Signal {
|
||||
private _bindings;
|
||||
private _prevParams;
|
||||
static VERSION: string;
|
||||
public memorize: bool;
|
||||
private _shouldPropagate;
|
||||
public active: bool;
|
||||
public validateListener(listener, fnName): void;
|
||||
private _registerListener(listener, isOnce, listenerContext, priority);
|
||||
private _addBinding(binding);
|
||||
private _indexOfListener(listener, context);
|
||||
public has(listener, context?: any): bool;
|
||||
public add(listener, listenerContext?: any, priority?: number): SignalBinding;
|
||||
public addOnce(listener, listenerContext?: any, priority?: number): SignalBinding;
|
||||
public remove(listener, context?: any);
|
||||
public removeAll(): void;
|
||||
public getNumListeners(): number;
|
||||
public halt(): void;
|
||||
public dispatch(...paramsArr: any[]): void;
|
||||
public forget(): void;
|
||||
public dispose(): void;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
/// <reference path="Signal.d.ts" />
|
||||
module Phaser {
|
||||
class SignalBinding {
|
||||
constructor(signal: Signal, listener, isOnce: bool, listenerContext, priority?: number);
|
||||
private _listener;
|
||||
private _isOnce;
|
||||
public context;
|
||||
private _signal;
|
||||
public priority: number;
|
||||
public active: bool;
|
||||
public params;
|
||||
public execute(paramsArr?: any[]);
|
||||
public detach();
|
||||
public isBound(): bool;
|
||||
public isOnce(): bool;
|
||||
public getListener();
|
||||
public getSignal(): Signal;
|
||||
public _destroy(): void;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/Sound.d.ts" />
|
||||
module Phaser {
|
||||
class SoundManager {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _context;
|
||||
private _gainNode;
|
||||
private _volume;
|
||||
public mute(): void;
|
||||
public unmute(): void;
|
||||
public volume : number;
|
||||
public decode(key: string, callback?, sound?: Sound): void;
|
||||
public play(key: string, volume?: number, loop?: bool): Sound;
|
||||
}
|
||||
}
|
||||
@@ -1,162 +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 {
|
||||
|
||||
/**
|
||||
* SoundManager constructor
|
||||
* Create a new <code>SoundManager</code>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Reference to AudioContext instance.
|
||||
*/
|
||||
private _context = null;
|
||||
|
||||
/**
|
||||
* Gain node created from audio context.
|
||||
*/
|
||||
private _gainNode;
|
||||
|
||||
/**
|
||||
* Volume of sounds.
|
||||
* @type {number}
|
||||
*/
|
||||
private _volume: number;
|
||||
|
||||
/**
|
||||
* Mute sounds.
|
||||
*/
|
||||
public mute() {
|
||||
|
||||
this._gainNode.gain.value = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable sounds.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a sound with its assets key.
|
||||
* @param key {string} Assets key of the sound to be decoded.
|
||||
* @param callback {function} This will be invoked when finished decoding.
|
||||
* @param [sound] {Sound} its bufer will be set to decoded data.
|
||||
*/
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Play a sound with its assets key.
|
||||
* @param key {string} Assets key of the sound you want to play.
|
||||
* @param [volume] {number} volume of the sound you want to play.
|
||||
* @param [loop] {boolean} loop when it finished playing? (Default to false)
|
||||
* @return {Sound} The playing sound object.
|
||||
*/
|
||||
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, () => tempSound.play(), tempSound);
|
||||
|
||||
return tempSound;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-47
@@ -1,47 +0,0 @@
|
||||
/// <reference path="Phaser.d.ts" />
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/StageScaleMode.d.ts" />
|
||||
/// <reference path="system/screens/BootScreen.d.ts" />
|
||||
/// <reference path="system/screens/PauseScreen.d.ts" />
|
||||
module Phaser {
|
||||
class Stage {
|
||||
constructor(game: Game, parent: string, width: number, height: number);
|
||||
private _game;
|
||||
private _bgColor;
|
||||
private _bootScreen;
|
||||
private _pauseScreen;
|
||||
static ORIENTATION_LANDSCAPE: number;
|
||||
static ORIENTATION_PORTRAIT: number;
|
||||
public bounds: Rectangle;
|
||||
public aspectRatio: number;
|
||||
public clear: bool;
|
||||
public canvas: HTMLCanvasElement;
|
||||
public context: CanvasRenderingContext2D;
|
||||
public disablePauseScreen: bool;
|
||||
public disableBootScreen: bool;
|
||||
public offset: Point;
|
||||
public scale: StageScaleMode;
|
||||
public scaleMode: number;
|
||||
public minScaleX: number;
|
||||
public maxScaleX: number;
|
||||
public minScaleY: number;
|
||||
public maxScaleY: number;
|
||||
public update(): void;
|
||||
private visibilityChange(event);
|
||||
private getOffset(element);
|
||||
public strokeStyle: string;
|
||||
public lineWidth: number;
|
||||
public fillStyle: string;
|
||||
public saveCanvasValues(): void;
|
||||
public restoreCanvasValues(): void;
|
||||
public backgroundColor : string;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public centerX : number;
|
||||
public centerY : number;
|
||||
public randomX : number;
|
||||
public randomY : number;
|
||||
}
|
||||
}
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class Time {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _started;
|
||||
public timeScale: number;
|
||||
public elapsed: number;
|
||||
public time: number;
|
||||
public now: number;
|
||||
public delta: number;
|
||||
public totalElapsedSeconds : number;
|
||||
public fps: number;
|
||||
public fpsMin: number;
|
||||
public fpsMax: number;
|
||||
public msMin: number;
|
||||
public msMax: number;
|
||||
public frames: number;
|
||||
private _timeLastSecond;
|
||||
public update(): void;
|
||||
public elapsedSince(since: number): number;
|
||||
public elapsedSecondsSince(since: number): number;
|
||||
public reset(): void;
|
||||
}
|
||||
}
|
||||
-193
@@ -1,193 +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 {
|
||||
|
||||
/**
|
||||
* Time constructor
|
||||
* Create a new <code>Time</code>.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
this._started = 0;
|
||||
this._timeLastSecond = this._started;
|
||||
this.time = this._started;
|
||||
this._game = game;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Time when this object created.
|
||||
* @param {number}
|
||||
*/
|
||||
private _started: number;
|
||||
|
||||
/**
|
||||
* Time scale factor.
|
||||
* Set it to 0.5 for slow motion, to 2.0 makes game twice faster.
|
||||
* @type {number}
|
||||
*/
|
||||
public timeScale: number = 1.0;
|
||||
|
||||
/**
|
||||
* Elapsed since last frame.
|
||||
* @type {number}
|
||||
*/
|
||||
public elapsed: number = 0;
|
||||
|
||||
/**
|
||||
* Game time counter.
|
||||
* @property time
|
||||
* @type {number}
|
||||
*/
|
||||
public time: number = 0;
|
||||
|
||||
/**
|
||||
* Time of current frame.
|
||||
* @property now
|
||||
* @type {number}
|
||||
*/
|
||||
public now: number = 0;
|
||||
|
||||
/**
|
||||
* Elapsed time since last frame.
|
||||
* @property delta
|
||||
* @type {number}
|
||||
*/
|
||||
public delta: number = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method totalElapsedSeconds
|
||||
* @return {Number}
|
||||
*/
|
||||
public get totalElapsedSeconds(): number {
|
||||
|
||||
return (this.now - this._started) * 0.001;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Frames per second.
|
||||
* @type {number}
|
||||
*/
|
||||
public fps: number = 0;
|
||||
|
||||
/**
|
||||
* Minimal fps.
|
||||
* @type {number}
|
||||
*/
|
||||
public fpsMin: number = 1000;
|
||||
|
||||
/**
|
||||
* Maximal fps.
|
||||
* @type {number}
|
||||
*/
|
||||
public fpsMax: number = 0;
|
||||
|
||||
/**
|
||||
* Mininal duration between 2 frames.
|
||||
* @type {number}
|
||||
*/
|
||||
public msMin: number = 1000;
|
||||
|
||||
/**
|
||||
* Maximal duration between 2 frames.
|
||||
* @type {number}
|
||||
*/
|
||||
public msMax: number = 0;
|
||||
|
||||
/**
|
||||
* How many frames in last second.
|
||||
* @type {number}
|
||||
*/
|
||||
public frames: number = 0;
|
||||
|
||||
/**
|
||||
* Time of last second.
|
||||
* @type {number}
|
||||
*/
|
||||
private _timeLastSecond: number = 0;
|
||||
|
||||
/**
|
||||
* Update clock and calculate the fps.
|
||||
* This is called automatically by Game._raf
|
||||
* @method update
|
||||
* @param {number} raf The current timestamp, either performance.now or Date.now
|
||||
*/
|
||||
public update(raf: number) {
|
||||
|
||||
this.now = raf; // mark
|
||||
//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
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* How long has passed since given time.
|
||||
* @method elapsedSince
|
||||
* @param {number} since The time you want to measure.
|
||||
* @return {number} Duration between given time and now.
|
||||
*/
|
||||
public elapsedSince(since: number): number {
|
||||
|
||||
return this.now - since;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* How long has passed since give time (in seconds).
|
||||
* @method elapsedSecondsSince
|
||||
* @param {number} since The time you want to measure (in seconds).
|
||||
* @return {number} Duration between given time and now (in seconds).
|
||||
*/
|
||||
public elapsedSecondsSince(since: number): number {
|
||||
|
||||
return (this.now - since) * 0.001;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start time to now.
|
||||
* @method reset
|
||||
*/
|
||||
public reset() {
|
||||
|
||||
this._started = this.now;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
/// <reference path="system/Tween.d.ts" />
|
||||
module Phaser {
|
||||
class TweenManager {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _tweens;
|
||||
public getAll(): Tween[];
|
||||
public removeAll(): void;
|
||||
public create(object): Tween;
|
||||
public add(tween: Tween): Tween;
|
||||
public remove(tween: Tween): void;
|
||||
public update(): bool;
|
||||
}
|
||||
}
|
||||
Vendored
-32
@@ -1,32 +0,0 @@
|
||||
/// <reference path="Game.d.ts" />
|
||||
module Phaser {
|
||||
class World {
|
||||
constructor(game: Game, width: number, height: number);
|
||||
private _game;
|
||||
public cameras: CameraManager;
|
||||
public group: Group;
|
||||
public bounds: Rectangle;
|
||||
public worldDivisions: number;
|
||||
public update(): void;
|
||||
public render(): void;
|
||||
public destroy(): void;
|
||||
public setSize(width: number, height: number, updateCameraBounds?: bool): void;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public centerX : number;
|
||||
public centerY : number;
|
||||
public randomX : number;
|
||||
public randomY : number;
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera;
|
||||
public removeCamera(id: number): bool;
|
||||
public getAllCameras(): Camera[];
|
||||
public createSprite(x: number, y: number, key?: string): Sprite;
|
||||
public createGeomSprite(x: number, y: number): GeomSprite;
|
||||
public createDynamicTexture(width: number, height: number): DynamicTexture;
|
||||
public createGroup(MaxSize?: number): Group;
|
||||
public createScrollZone(key: string, x?: number, y?: number, width?: number, height?: number): ScrollZone;
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number): Tilemap;
|
||||
public createParticle(): Particle;
|
||||
public createEmitter(x?: number, y?: number, size?: number): Emitter;
|
||||
}
|
||||
}
|
||||
-293
@@ -1,293 +0,0 @@
|
||||
/// <reference path="Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - World
|
||||
*
|
||||
* "This world is but a canvas to our imagination." - Henry David Thoreau
|
||||
*
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* World constructor
|
||||
* Create a new <code>World</code> with specific width and height.
|
||||
*
|
||||
* @param width {number} Width of the world bound.
|
||||
* @param height {number} Height of the world bound.
|
||||
*/
|
||||
constructor(game: Game, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.cameras = new CameraManager(this._game, 0, 0, width, height);
|
||||
|
||||
this.group = new Group(this._game, 0);
|
||||
|
||||
this.bounds = new Rectangle(0, 0, width, height);
|
||||
|
||||
this.worldDivisions = 6;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Camera manager of this world.
|
||||
* @type {CameraManager}
|
||||
*/
|
||||
public cameras: CameraManager;
|
||||
|
||||
/**
|
||||
* Object container stores every object created with `create*` methods.
|
||||
* @type {Group}
|
||||
*/
|
||||
public group: Group;
|
||||
|
||||
/**
|
||||
* Bound of this world that objects can not escape from.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public bounds: Rectangle;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
public worldDivisions: number;
|
||||
|
||||
/**
|
||||
* This is called automatically every frame, and is where main logic performs.
|
||||
*/
|
||||
public update() {
|
||||
|
||||
this.group.preUpdate();
|
||||
this.group.update();
|
||||
this.group.postUpdate();
|
||||
|
||||
this.cameras.update();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render every thing to the screen, automatically called after update().
|
||||
*/
|
||||
public render() {
|
||||
|
||||
// Unlike in flixel our render process is camera driven, not group driven
|
||||
this.cameras.render();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this.group.destroy();
|
||||
|
||||
this.cameras.destroy();
|
||||
|
||||
}
|
||||
|
||||
// World methods
|
||||
|
||||
/**
|
||||
* Update size of this world with specific width and height.
|
||||
* You can choose update camera bounds and verlet manager automatically or not.
|
||||
*
|
||||
* @param width {number} New width of the world.
|
||||
* @param height {number} New height of the world.
|
||||
* @param [updateCameraBounds] {boolean} update camera bounds automatically or not. Default to true.
|
||||
* @param [updateVerletBounds] {boolean} update verlet bounds automatically or not. Default to true.
|
||||
*/
|
||||
public setSize(width: number, height: number, updateCameraBounds: bool = true, updateVerletBounds: bool = true) {
|
||||
|
||||
this.bounds.width = width;
|
||||
this.bounds.height = height;
|
||||
|
||||
if (updateCameraBounds == true)
|
||||
{
|
||||
this._game.camera.setBounds(0, 0, width, height);
|
||||
}
|
||||
|
||||
if (updateVerletBounds == true)
|
||||
{
|
||||
this._game.verlet.width = width;
|
||||
this._game.verlet.height = 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
|
||||
|
||||
/**
|
||||
* Create a new camera with specific position and size.
|
||||
*
|
||||
* @param x {number} X position of the new camera.
|
||||
* @param y {number} Y position of the new camera.
|
||||
* @param width {number} Width of the new camera.
|
||||
* @param height {number} Height of the new camera.
|
||||
* @returns {Camera} The newly created camera object.
|
||||
*/
|
||||
public createCamera(x: number, y: number, width: number, height: number): Camera {
|
||||
return this.cameras.addCamera(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a new camera with its id.
|
||||
*
|
||||
* @param id {number} ID of the camera you want to remove.
|
||||
* @returns {boolean} True if successfully removed the camera, otherwise return false.
|
||||
*/
|
||||
public removeCamera(id: number): bool {
|
||||
return this.cameras.removeCamera(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the cameras.
|
||||
*
|
||||
* @returns {array} An array contains all the cameras.
|
||||
*/
|
||||
public getAllCameras(): Camera[] {
|
||||
return this.cameras.getAll();
|
||||
}
|
||||
|
||||
// Game Objects
|
||||
|
||||
/**
|
||||
* Create a new Sprite with specific position and sprite sheet key.
|
||||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param [key] {string} key for the sprite sheet you want it to use.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
return <Sprite> this.group.add(new Sprite(this._game, x, y, key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new GeomSprite with specific position.
|
||||
*
|
||||
* @param x {number} X position of the new geom sprite.
|
||||
* @param y {number} Y position of the new geom sprite.
|
||||
* @returns {GeomSprite} The newly created geom sprite object.
|
||||
*/
|
||||
public createGeomSprite(x: number, y: number): GeomSprite {
|
||||
return <GeomSprite> this.group.add(new GeomSprite(this._game, x, y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DynamicTexture with specific size.
|
||||
*
|
||||
* @param width {number} Width of the texture.
|
||||
* @param height {number} Height of the texture.
|
||||
* @returns {DynamicTexture} The newly created dynamic texture object.
|
||||
*/
|
||||
public createDynamicTexture(width: number, height: number): DynamicTexture {
|
||||
return new DynamicTexture(this._game, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param [maxSize] {number} capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(maxSize?: number = 0): Group {
|
||||
return <Group> this.group.add(new Group(this._game, maxSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
*
|
||||
* @param key {number} Key to a image you wish this object to use.
|
||||
* @param x {number} X position of this object.
|
||||
* @param y {number} Y position of this object.
|
||||
* @param width {number} Width of this object.
|
||||
* @param height {number} Height of this object.
|
||||
* @returns {ScrollZone} The newly created scroll zone object.
|
||||
*/
|
||||
public createScrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
|
||||
return <ScrollZone> this.group.add(new ScrollZone(this._game, key, x, y, width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Tilemap.
|
||||
*
|
||||
* @param key {string} Key for tileset image.
|
||||
* @param mapData {string} Data of this tilemap.
|
||||
* @param format {number} Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
|
||||
* @param [resizeWorld] {boolean} resize the world to make same as tilemap?
|
||||
* @param [tileWidth] {number} width of each tile.
|
||||
* @param [tileHeight] {number} height of each tile.
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
return <Tilemap> this.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Particle.
|
||||
*
|
||||
* @return {Particle} The newly created particle object.
|
||||
*/
|
||||
public createParticle(): Particle {
|
||||
return new Particle(this._game);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Emitter.
|
||||
*
|
||||
* @param [x] {number} x position of the emitter.
|
||||
* @param [y] {number} y position of the emitter.
|
||||
* @param [size] {number} size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
return <Emitter> this.group.add(new Emitter(this._game, x, y, size));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-38
@@ -1,38 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../Group.d.ts" />
|
||||
module Phaser {
|
||||
class Emitter extends Group {
|
||||
constructor(game: Game, X?: number, Y?: number, Size?: number);
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public minParticleSpeed: MicroPoint;
|
||||
public maxParticleSpeed: MicroPoint;
|
||||
public particleDrag: MicroPoint;
|
||||
public minRotation: number;
|
||||
public maxRotation: number;
|
||||
public gravity: number;
|
||||
public on: bool;
|
||||
public frequency: number;
|
||||
public lifespan: number;
|
||||
public bounce: number;
|
||||
public particleClass;
|
||||
private _quantity;
|
||||
private _explode;
|
||||
private _timer;
|
||||
private _counter;
|
||||
private _point;
|
||||
public destroy(): void;
|
||||
public makeParticles(Graphics, Quantity?: number, BakedRotations?: number, Multiple?: bool, Collide?: number): Emitter;
|
||||
public update(): void;
|
||||
public kill(): void;
|
||||
public start(Explode?: bool, Lifespan?: number, Frequency?: number, Quantity?: number): void;
|
||||
public emitParticle(): void;
|
||||
public setSize(Width: number, Height: number): void;
|
||||
public setXSpeed(Min?: number, Max?: number): void;
|
||||
public setYSpeed(Min?: number, Max?: number): void;
|
||||
public setRotation(Min?: number, Max?: number): void;
|
||||
public at(Object): void;
|
||||
}
|
||||
}
|
||||
@@ -1,454 +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 {number} The X position of the emitter.
|
||||
* @param y {number} The Y position of the emitter.
|
||||
* @param [size] {number} 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 MicroPoint(-100, -100);
|
||||
this.maxParticleSpeed = new MicroPoint(100, 100);
|
||||
this.minRotation = -360;
|
||||
this.maxRotation = 360;
|
||||
this.gravity = 0;
|
||||
this.particleClass = null;
|
||||
this.particleDrag = new MicroPoint();
|
||||
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 MicroPoint();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: MicroPoint;
|
||||
|
||||
/**
|
||||
* The maximum possible velocity of a particle.
|
||||
* The default value is (100,100).
|
||||
*/
|
||||
public maxParticleSpeed: MicroPoint;
|
||||
|
||||
/**
|
||||
* The X and Y drag component of particles launched from the emitter.
|
||||
*/
|
||||
public particleDrag: MicroPoint;
|
||||
|
||||
/**
|
||||
* 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: MicroPoint;
|
||||
|
||||
/**
|
||||
* 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 {number} The number of particles to generate when using the "create from image" option.
|
||||
* @param multiple {boolean} 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 {number} 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, multiple: bool = false, collide: number = 0): 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.allowCollisions = Collision.ANY;
|
||||
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 {boolean} Whether the particles should all burst out at once.
|
||||
* @param lifespan {number} How long each particle lives once emitted. 0 = forever.
|
||||
* @param frequency {number} 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 {number} 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 && this.minRotation !== 0 && this.maxRotation !== 0)
|
||||
{
|
||||
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 {number} The desired width of the emitter (particles are spawned randomly within these dimensions).
|
||||
* @param height {number} 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 {number} The minimum value for this range.
|
||||
* @param Max {number} 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 {number} The minimum value for this range.
|
||||
* @param Max {number} 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 {number} The minimum value for this range.
|
||||
* @param Max {number} 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 {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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-84
@@ -1,84 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../Basic.d.ts" />
|
||||
/// <reference path="../Signal.d.ts" />
|
||||
module Phaser {
|
||||
class GameObject extends Basic {
|
||||
constructor(game: Game, x?: number, y?: number, width?: number, height?: number);
|
||||
private _angle;
|
||||
static ALIGN_TOP_LEFT: number;
|
||||
static ALIGN_TOP_CENTER: number;
|
||||
static ALIGN_TOP_RIGHT: number;
|
||||
static ALIGN_CENTER_LEFT: number;
|
||||
static ALIGN_CENTER: number;
|
||||
static ALIGN_CENTER_RIGHT: number;
|
||||
static ALIGN_BOTTOM_LEFT: number;
|
||||
static ALIGN_BOTTOM_CENTER: number;
|
||||
static ALIGN_BOTTOM_RIGHT: number;
|
||||
static OUT_OF_BOUNDS_STOP: number;
|
||||
static OUT_OF_BOUNDS_KILL: number;
|
||||
public _point: MicroPoint;
|
||||
public cameraBlacklist: number[];
|
||||
public bounds: Rectangle;
|
||||
public worldBounds: Quad;
|
||||
public outOfBoundsAction: number;
|
||||
public align: number;
|
||||
public facing: number;
|
||||
public alpha: number;
|
||||
public scale: MicroPoint;
|
||||
public origin: MicroPoint;
|
||||
public z: number;
|
||||
public rotationOffset: number;
|
||||
public renderRotation: bool;
|
||||
public immovable: bool;
|
||||
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;
|
||||
public touching: number;
|
||||
public wasTouching: number;
|
||||
public allowCollisions: number;
|
||||
public last: MicroPoint;
|
||||
public inputEnabled: bool;
|
||||
private _inputOver;
|
||||
public onInputOver: Signal;
|
||||
public onInputOut: Signal;
|
||||
public onInputDown: Signal;
|
||||
public onInputUp: Signal;
|
||||
public preUpdate(): void;
|
||||
public update(): void;
|
||||
public postUpdate(): void;
|
||||
private updateInput();
|
||||
private updateMotion();
|
||||
public overlaps(ObjectOrGroup, InScreenSpace?: bool, Camera?: Camera): bool;
|
||||
public overlapsAt(X: number, Y: number, ObjectOrGroup, InScreenSpace?: bool, Camera?: Camera): bool;
|
||||
public overlapsPoint(point: Point, InScreenSpace?: bool, Camera?: Camera): bool;
|
||||
public onScreen(Camera?: Camera): bool;
|
||||
public getScreenXY(point?: MicroPoint, Camera?: Camera): MicroPoint;
|
||||
public solid : bool;
|
||||
public getMidpoint(point?: MicroPoint): MicroPoint;
|
||||
public reset(X: number, Y: number): void;
|
||||
public isTouching(Direction: number): bool;
|
||||
public justTouched(Direction: number): bool;
|
||||
public hurt(Damage: number): void;
|
||||
public setBounds(x: number, y: number, width: number, height: number): void;
|
||||
public hideFromCamera(camera: Camera): void;
|
||||
public showToCamera(camera: Camera): void;
|
||||
public clearCameraList(): void;
|
||||
public destroy(): void;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public rotation : number;
|
||||
public angle : number;
|
||||
public width : number;
|
||||
public height : number;
|
||||
}
|
||||
}
|
||||
@@ -1,897 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../Basic.ts" />
|
||||
/// <reference path="../Signal.ts" />
|
||||
/// <reference path="../system/CollisionMask.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 {
|
||||
|
||||
/**
|
||||
* GameObject constructor
|
||||
*
|
||||
* Create a new <code>GameObject</code> object at specific position with specific width and height.
|
||||
*
|
||||
* @param [x] {number} The x position of the object.
|
||||
* @param [y] {number} The y position of the object.
|
||||
* @param [width] {number} The width of the object.
|
||||
* @param [height] {number} The height of the object.
|
||||
*/
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, width?: number = 16, height?: number = 16) {
|
||||
|
||||
super(game);
|
||||
|
||||
this.canvas = game.stage.canvas;
|
||||
this.context = game.stage.context;
|
||||
|
||||
this.frameBounds = 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.align = GameObject.ALIGN_TOP_LEFT;
|
||||
this.mass = 1;
|
||||
this.elasticity = 0;
|
||||
this.health = 1;
|
||||
this.immovable = false;
|
||||
this.moves = true;
|
||||
this.worldBounds = null;
|
||||
|
||||
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.cameraBlacklist = [];
|
||||
this.scrollFactor = new MicroPoint(1, 1);
|
||||
this.collisionMask = new CollisionMask(game, this, x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Angle of this object.
|
||||
* @type {number}
|
||||
*/
|
||||
private _angle: number = 0;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the top-left corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_TOP_LEFT: number = 0;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the top-center corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_TOP_CENTER: number = 1;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the top-right corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_TOP_RIGHT: number = 2;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the center-left corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_CENTER_LEFT: number = 3;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the center corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_CENTER: number = 4;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the center-right corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_CENTER_RIGHT: number = 5;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the bottom-left corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_BOTTOM_LEFT: number = 6;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the bottom-center corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_BOTTOM_CENTER: number = 7;
|
||||
|
||||
/**
|
||||
* Pivot position enum: at the bottom-right corner.
|
||||
* @type {number}
|
||||
*/
|
||||
public static ALIGN_BOTTOM_RIGHT: number = 8;
|
||||
|
||||
/**
|
||||
* Enum value for outOfBoundsAction. Stop the object when is out of world bounds.
|
||||
* @type {number}
|
||||
*/
|
||||
public static OUT_OF_BOUNDS_STOP: number = 0;
|
||||
|
||||
/**
|
||||
* Enum value for outOfBoundsAction. Kill the object when is out of world bounds.
|
||||
* @type {number}
|
||||
*/
|
||||
public static OUT_OF_BOUNDS_KILL: number = 1;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas this GameObject will render to
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
public canvas: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* A reference to the Canvas Context2D this GameObject will render to
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
public context: CanvasRenderingContext2D;
|
||||
|
||||
/**
|
||||
* Position of this object after scrolling.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public _point: MicroPoint;
|
||||
|
||||
/**
|
||||
* An Array of Cameras to which this GameObject won't render
|
||||
* @type {Array}
|
||||
*/
|
||||
public cameraBlacklist: number[];
|
||||
|
||||
/**
|
||||
* Rectangle container of this object.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public frameBounds: Rectangle;
|
||||
|
||||
/**
|
||||
* This objects CollisionMask
|
||||
* @type {CollisionMask}
|
||||
*/
|
||||
public collisionMask: CollisionMask;
|
||||
|
||||
/**
|
||||
* A rectangular area which is object is allowed to exist within. If it travels outside of this area it will perform the outOfBoundsAction.
|
||||
* @type {Quad}
|
||||
*/
|
||||
public worldBounds: Quad;
|
||||
|
||||
/**
|
||||
* What action will be performed when object is out of the worldBounds.
|
||||
* This will default to GameObject.OUT_OF_BOUNDS_STOP.
|
||||
* @type {number}
|
||||
*/
|
||||
public outOfBoundsAction: number = 0;
|
||||
|
||||
/**
|
||||
* At which point the graphic of this object will align to.
|
||||
* Align of the object will default to GameObject.ALIGN_TOP_LEFT.
|
||||
* @type {number}
|
||||
*/
|
||||
public align: number;
|
||||
|
||||
/**
|
||||
* Orientation of the object.
|
||||
* @type {number}
|
||||
*/
|
||||
public facing: number;
|
||||
|
||||
/**
|
||||
* Set alpha to a number between 0 and 1 to change the opacity.
|
||||
* @type {number}
|
||||
*/
|
||||
public alpha: number;
|
||||
|
||||
/**
|
||||
* Scale factor of the object.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scale: MicroPoint;
|
||||
|
||||
/**
|
||||
* Origin is the anchor point that the object will rotate by.
|
||||
* The origin will default to its center.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public origin: MicroPoint;
|
||||
|
||||
/**
|
||||
* Z-order value of the object.
|
||||
*/
|
||||
public z: number = 0;
|
||||
|
||||
/**
|
||||
* This value is added to the angle of the GameObject.
|
||||
* For example if you had a sprite drawn facing straight up then you could set
|
||||
* rotationOffset to 90 and it would correspond correctly with Phasers rotation system
|
||||
* @type {number}
|
||||
*/
|
||||
public rotationOffset: number = 0;
|
||||
|
||||
/**
|
||||
* Controls if the GameObject is rendered rotated or not.
|
||||
* If renderRotation is false then the object can still rotate but it will never be rendered rotated.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderRotation: bool = true;
|
||||
|
||||
// Physics properties
|
||||
|
||||
/**
|
||||
* Whether this object will be moved by impacts with other objects or not.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public immovable: bool;
|
||||
|
||||
/**
|
||||
* Basic speed of this object.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public velocity: MicroPoint;
|
||||
|
||||
/**
|
||||
* The virtual mass of the object.
|
||||
* @type {number}
|
||||
*/
|
||||
public mass: number;
|
||||
|
||||
/**
|
||||
* The bounciness of the object.
|
||||
* @type {number}
|
||||
*/
|
||||
public elasticity: number;
|
||||
|
||||
/**
|
||||
* How fast the speed of this object is changing.
|
||||
* @type {number}
|
||||
*/
|
||||
public acceleration: MicroPoint;
|
||||
|
||||
/**
|
||||
* This isn't drag exactly, more like deceleration that is only applied
|
||||
* when acceleration is not affecting the sprite.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public drag: MicroPoint;
|
||||
|
||||
/**
|
||||
* It will cap the speed automatically if you use the acceleration
|
||||
* to change its velocity.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public maxVelocity: MicroPoint;
|
||||
|
||||
/**
|
||||
* How fast this object is rotating.
|
||||
* @type {number}
|
||||
*/
|
||||
public angularVelocity: number;
|
||||
|
||||
/**
|
||||
* How fast angularVelocity of this object is changing.
|
||||
* @type {number}
|
||||
*/
|
||||
public angularAcceleration: number;
|
||||
|
||||
/**
|
||||
* Deacceleration of angularVelocity will be applied when it's rotating.
|
||||
* @type {number}
|
||||
*/
|
||||
public angularDrag: number;
|
||||
|
||||
/**
|
||||
* It will cap the rotate speed automatically if you use the angularAcceleration
|
||||
* to change its angularVelocity.
|
||||
* @type {number}
|
||||
*/
|
||||
public maxAngular: number;
|
||||
|
||||
/**
|
||||
* A point that can store numbers from 0 to 1 (for X and Y independently)
|
||||
* which governs how much this object is affected by the camera .
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scrollFactor: MicroPoint;
|
||||
|
||||
/**
|
||||
* Handy for storing health percentage or armor points or whatever.
|
||||
* @type {number}
|
||||
*/
|
||||
public health: number;
|
||||
|
||||
/**
|
||||
* Set this to false if you want to skip the automatic motion/movement stuff
|
||||
* (see updateMotion()).
|
||||
* @type {boolean}
|
||||
*/
|
||||
public moves: bool = true;
|
||||
|
||||
/**
|
||||
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts.
|
||||
* @type {number}
|
||||
*/
|
||||
public touching: number;
|
||||
|
||||
/**
|
||||
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step.
|
||||
* @type {number}
|
||||
*/
|
||||
public wasTouching: number;
|
||||
|
||||
/**
|
||||
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
|
||||
* @type {number}
|
||||
*/
|
||||
public allowCollisions: number;
|
||||
|
||||
/**
|
||||
* Important variable for collision processing.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Pre-update is called right before update() on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
this.last.x = this.frameBounds.x;
|
||||
this.last.y = this.frameBounds.y;
|
||||
|
||||
this.collisionMask.preUpdate();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this function to update your class's position and appearance.
|
||||
*/
|
||||
public update() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically called after update() by the game loop.
|
||||
*/
|
||||
public postUpdate() {
|
||||
|
||||
if (this.moves)
|
||||
{
|
||||
this.updateMotion();
|
||||
}
|
||||
|
||||
if (this.worldBounds != null)
|
||||
{
|
||||
if (this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL)
|
||||
{
|
||||
if (this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.kill();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.x < this.worldBounds.x)
|
||||
{
|
||||
this.x = this.worldBounds.x;
|
||||
}
|
||||
else if (this.x > this.worldBounds.right)
|
||||
{
|
||||
this.x = this.worldBounds.right;
|
||||
}
|
||||
|
||||
if (this.y < this.worldBounds.y)
|
||||
{
|
||||
this.y = this.worldBounds.y;
|
||||
}
|
||||
else if (this.y > this.worldBounds.bottom)
|
||||
{
|
||||
this.y = this.worldBounds.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.collisionMask.update();
|
||||
|
||||
if (this.inputEnabled)
|
||||
{
|
||||
this.updateInput();
|
||||
}
|
||||
|
||||
this.wasTouching = this.touching;
|
||||
this.touching = Collision.NONE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update input.
|
||||
*/
|
||||
private updateInput() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function for updating the position and speed of this object.
|
||||
*/
|
||||
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.frameBounds.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.frameBounds.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>Collision.overlaps()</code>.
|
||||
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
|
||||
*
|
||||
* @param objectOrGroup {object} The object or group being tested.
|
||||
* @param inScreenSpace {boolean} Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {boolean} Whether or not the objects overlap this.
|
||||
*/
|
||||
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 (!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 {number} The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param Y {number} The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
|
||||
* @param objectOrGroup {object} The object or group being tested.
|
||||
* @param inScreenSpace {boolean} Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {boolean} 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 (!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 {Point} The point in world space you want to check.
|
||||
* @param inScreenSpace {boolean} Whether to take scroll factors into account when checking for overlap.
|
||||
* @param camera {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 {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {boolean} 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 point {Point} Takes a <code>MicroPoint</code> object and assigns the post-scrolled X and Y values of this object to it.
|
||||
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
|
||||
*
|
||||
* @return {MicroPoint} 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;
|
||||
}
|
||||
|
||||
public set solid(value: bool) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
this.allowCollisions = Collision.ANY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowCollisions = Collision.NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the midpoint of this object in world coordinates.
|
||||
*
|
||||
* @param point {Point} Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
|
||||
*
|
||||
* @return {MicroPoint} 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.frameBounds.center);
|
||||
|
||||
return point;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handy for reviving game objects.
|
||||
* Resets their existence flags and position.
|
||||
*
|
||||
* @param x {number} The new X position of this object.
|
||||
* @param y {number} 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 into <code>touching</code>.
|
||||
* However, this method is good for readability and accessibility.
|
||||
*
|
||||
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @return {boolean} 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 function for checking if this object just landed on a particular surface.
|
||||
*
|
||||
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
|
||||
*
|
||||
* @returns {boolean} Whether the object just landed on any specicied surfaces.
|
||||
*/
|
||||
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 {number} 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the world bounds that this GameObject can exist within. By default a GameObject can exist anywhere
|
||||
* in the world. But by setting the bounds (which are given in world dimensions, not screen dimensions)
|
||||
* it can be stopped from leaving the world, or a section of it.
|
||||
*
|
||||
* @param x {number} x position of the bound
|
||||
* @param y {number} y position of the bound
|
||||
* @param width {number} width of its bound
|
||||
* @param height {number} height of its bound
|
||||
*/
|
||||
public setBounds(x: number, y: number, width: number, height: number) {
|
||||
|
||||
this.worldBounds = new Quad(x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the world bounds that this GameObject can exist within based on the size of the current game world.
|
||||
*
|
||||
* @param action {number} The action to take if the object hits the world bounds, either OUT_OF_BOUNDS_KILL or OUT_OF_BOUNDS_STOP
|
||||
*/
|
||||
public setBoundsFromWorld(action?: number = GameObject.OUT_OF_BOUNDS_STOP) {
|
||||
|
||||
this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height);
|
||||
this.outOfBoundsAction = action;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If you do not wish this object to be visible to a specific camera, pass the camera here.
|
||||
*
|
||||
* @param camera {Camera} The specific camera.
|
||||
*/
|
||||
public hideFromCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) == -1)
|
||||
{
|
||||
this.cameraBlacklist.push(camera.ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make this object only visible to a specific camera.
|
||||
*
|
||||
* @param camera {Camera} The camera you wish it to be visible.
|
||||
*/
|
||||
public showToCamera(camera: Camera) {
|
||||
|
||||
if (this.cameraBlacklist.indexOf(camera.ID) !== -1)
|
||||
{
|
||||
this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This clears the camera black list, making the GameObject visible to all cameras.
|
||||
*/
|
||||
public clearCameraList() {
|
||||
|
||||
this.cameraBlacklist.length = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
public destroy() {
|
||||
}
|
||||
|
||||
public setPosition(x: number, y: number) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this.frameBounds.x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this.frameBounds.x = value;
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this.frameBounds.y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this.frameBounds.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.frameBounds.width = value;
|
||||
}
|
||||
|
||||
public set height(value:number) {
|
||||
this.frameBounds.height = value;
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
return this.frameBounds.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.frameBounds.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-40
@@ -1,40 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class GeomSprite extends GameObject {
|
||||
constructor(game: Game, x?: number, y?: number);
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public type: number;
|
||||
static UNASSIGNED: number;
|
||||
static CIRCLE: number;
|
||||
static LINE: number;
|
||||
static POINT: number;
|
||||
static RECTANGLE: number;
|
||||
public circle: Circle;
|
||||
public line: Line;
|
||||
public point: Point;
|
||||
public rect: Rectangle;
|
||||
public renderOutline: bool;
|
||||
public renderFill: bool;
|
||||
public lineWidth: number;
|
||||
public lineColor: string;
|
||||
public fillColor: string;
|
||||
public loadCircle(circle: Circle): GeomSprite;
|
||||
public loadLine(line: Line): GeomSprite;
|
||||
public loadPoint(point: Point): GeomSprite;
|
||||
public loadRectangle(rect: Rectangle): GeomSprite;
|
||||
public createCircle(diameter: number): GeomSprite;
|
||||
public createLine(x: number, y: number): GeomSprite;
|
||||
public createPoint(): GeomSprite;
|
||||
public createRectangle(width: number, height: number): GeomSprite;
|
||||
public refresh(): void;
|
||||
public update(): void;
|
||||
public inCamera(camera: Rectangle): bool;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
|
||||
public renderPoint(offsetX, offsetY, point, size): void;
|
||||
public renderDebugInfo(x: number, y: number, color?: string): void;
|
||||
public collide(source: GeomSprite): bool;
|
||||
}
|
||||
}
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="Sprite.d.ts" />
|
||||
module Phaser {
|
||||
class Particle extends Sprite {
|
||||
constructor(game: Game);
|
||||
public lifespan: number;
|
||||
public friction: number;
|
||||
public update(): void;
|
||||
public onEmit(): void;
|
||||
}
|
||||
}
|
||||
@@ -1,108 +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() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../geom/Quad.d.ts" />
|
||||
module Phaser {
|
||||
class ScrollRegion {
|
||||
constructor(x: number, y: number, width: number, height: number, speedX: number, speedY: number);
|
||||
private _A;
|
||||
private _B;
|
||||
private _C;
|
||||
private _D;
|
||||
private _bounds;
|
||||
private _scroll;
|
||||
private _anchorWidth;
|
||||
private _anchorHeight;
|
||||
private _inverseWidth;
|
||||
private _inverseHeight;
|
||||
public visible: bool;
|
||||
public scrollSpeed: MicroPoint;
|
||||
public update(delta: number): void;
|
||||
public render(context: CanvasRenderingContext2D, texture, dx: number, dy: number, dw: number, dh: number): void;
|
||||
private crop(context, texture, srcX, srcY, srcW, srcH, destX, destY, destW, destH, offsetX, offsetY);
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../geom/Quad.d.ts" />
|
||||
/// <reference path="ScrollRegion.d.ts" />
|
||||
module Phaser {
|
||||
class ScrollZone extends GameObject {
|
||||
constructor(game: Game, key: string, x?: number, y?: number, width?: number, height?: number);
|
||||
private _texture;
|
||||
private _dynamicTexture;
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public currentRegion: ScrollRegion;
|
||||
public regions: ScrollRegion[];
|
||||
public flipped: bool;
|
||||
public addRegion(x: number, y: number, width: number, height: number, speedX?: number, speedY?: number): ScrollRegion;
|
||||
public setSpeed(x: number, y: number): ScrollZone;
|
||||
public update(): void;
|
||||
public inCamera(camera: Rectangle): bool;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
|
||||
private createRepeatingTexture(regionWidth, regionHeight);
|
||||
}
|
||||
}
|
||||
@@ -1,293 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../geom/Quad.ts" />
|
||||
/// <reference path="ScrollRegion.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - ScrollZone
|
||||
*
|
||||
* Creates a scrolling region of the given width and height from an image in the cache.
|
||||
* The ScrollZone can be positioned anywhere in-world like a normal game object, re-act to physics, collision, etc.
|
||||
* The image within it is scrolled via ScrollRegions and their scrollSpeed.x/y properties.
|
||||
* If you create a scroll zone larger than the given source image it will create a DynamicTexture and fill it with a pattern of the source image.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class ScrollZone extends GameObject {
|
||||
|
||||
/**
|
||||
* ScrollZone constructor
|
||||
* Create a new <code>ScrollZone</code>.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param key {string} Asset key for image texture of this object.
|
||||
* @param x {number} X position in world coordinate.
|
||||
* @param y {number} Y position in world coordinate.
|
||||
* @param [width] {number} width of this object.
|
||||
* @param [height] {number} height of this object.
|
||||
*/
|
||||
constructor(game: Game, key:string, x: number = 0, y: number = 0, width?: number = 0, height?: number = 0) {
|
||||
|
||||
super(game, x, y, width, height);
|
||||
|
||||
this.regions = [];
|
||||
|
||||
if (this._game.cache.getImage(key))
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.width = this._texture.width;
|
||||
this.height = this._texture.height;
|
||||
|
||||
if (width > this._texture.width || height > this._texture.height)
|
||||
{
|
||||
// Create our repeating texture (as the source image wasn't large enough for the requested size)
|
||||
this.createRepeatingTexture(width, height);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
// Create a default ScrollRegion at the requested size
|
||||
this.addRegion(0, 0, this.width, this.height);
|
||||
|
||||
// If the zone is smaller than the image itself then shrink the bounds
|
||||
if ((width < this._texture.width || height < this._texture.height) && width !== 0 && height !== 0)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Texture of this object.
|
||||
*/
|
||||
private _texture;
|
||||
|
||||
/**
|
||||
* If this zone is larger than texture image, this will be filled with a pattern of texture.
|
||||
* @type {DynamicTexture}
|
||||
*/
|
||||
private _dynamicTexture: DynamicTexture = null;
|
||||
|
||||
/**
|
||||
* Local rendering related temp vars to help avoid gc spikes.
|
||||
* @type {number}
|
||||
*/
|
||||
private _dx: number = 0;
|
||||
|
||||
/**
|
||||
* Local rendering related temp vars to help avoid gc spikes.
|
||||
* @type {number}
|
||||
*/
|
||||
private _dy: number = 0;
|
||||
|
||||
/**
|
||||
* Local rendering related temp vars to help avoid gc spikes.
|
||||
* @type {number}
|
||||
*/
|
||||
private _dw: number = 0;
|
||||
|
||||
/**
|
||||
* Local rendering related temp vars to help avoid gc spikes.
|
||||
* @type {number}
|
||||
*/
|
||||
private _dh: number = 0;
|
||||
|
||||
/**
|
||||
* Current region this zone is scrolling.
|
||||
* @type {ScrollRegion}
|
||||
*/
|
||||
public currentRegion: ScrollRegion;
|
||||
|
||||
/**
|
||||
* Array contains all added regions.
|
||||
* @type {ScrollRegion[]}
|
||||
*/
|
||||
public regions: ScrollRegion[];
|
||||
|
||||
/**
|
||||
* Flip this zone vertically? (default to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public flipped: bool = false;
|
||||
|
||||
/**
|
||||
* Add a new region to this zone.
|
||||
* @param x {number} X position of the new region.
|
||||
* @param y {number} Y position of the new region.
|
||||
* @param width {number} Width of the new region.
|
||||
* @param height {number} Height of the new region.
|
||||
* @param [speedX] {number} x-axis scrolling speed.
|
||||
* @param [speedY] {number} y-axis scrolling speed.
|
||||
* @return {ScrollRegion} The newly added region.
|
||||
*/
|
||||
public addRegion(x: number, y: number, width: number, height: number, speedX?:number = 0, speedY?:number = 0):ScrollRegion {
|
||||
|
||||
if (x > this.width || y > this.height || x < 0 || y < 0 || (x + width) > this.width || (y + height) > this.height)
|
||||
{
|
||||
throw Error('Invalid ScrollRegion defined. Cannot be larger than parent ScrollZone');
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentRegion = new ScrollRegion(x, y, width, height, speedX, speedY);
|
||||
|
||||
this.regions.push(this.currentRegion);
|
||||
|
||||
return this.currentRegion;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set scrolling speed of current region.
|
||||
* @param x {number} X speed of current region.
|
||||
* @param y {number} Y speed of current region.
|
||||
*/
|
||||
public setSpeed(x: number, y: number) {
|
||||
|
||||
if (this.currentRegion)
|
||||
{
|
||||
this.currentRegion.scrollSpeed.setTo(x, y);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update regions.
|
||||
*/
|
||||
public update() {
|
||||
|
||||
for (var i = 0; i < this.regions.length; i++)
|
||||
{
|
||||
this.regions[i].update(this._game.time.delta);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this zone is visible in a specific camera rectangle.
|
||||
* @param camera {Rectangle} The rectangle you want to check.
|
||||
* @return {boolean} Return true if bound of this zone intersects the given rectangle, otherwise return false.
|
||||
*/
|
||||
public inCamera(camera: Rectangle): bool {
|
||||
|
||||
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
|
||||
{
|
||||
this._dx = this.frameBounds.x - (camera.x * this.scrollFactor.x);
|
||||
this._dy = this.frameBounds.y - (camera.y * this.scrollFactor.x);
|
||||
this._dw = this.frameBounds.width * this.scale.x;
|
||||
this._dh = this.frameBounds.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.frameBounds, this.frameBounds.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this zone object to a specific camera.
|
||||
* @param camera {Camera} The camera this object will be render to.
|
||||
* @param cameraOffsetX {number} X offset of camera.
|
||||
* @param cameraOffsetY {number} Y offset of camera.
|
||||
* @return Return false if not rendered, otherwise return true.
|
||||
*/
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
|
||||
|
||||
// Render checks
|
||||
if (this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._dx = cameraOffsetX + (this.frameBounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.frameBounds.topLeft.y - camera.worldView.y);
|
||||
this._dw = this.frameBounds.width * this.scale.x;
|
||||
this._dh = this.frameBounds.height * this.scale.y;
|
||||
|
||||
// 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.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
|
||||
if (this.angle !== 0)
|
||||
{
|
||||
this.context.rotate(this.angle * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
|
||||
if (this.flipped == true)
|
||||
{
|
||||
this.context.scale(-1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this._dx = Math.round(this._dx);
|
||||
this._dy = Math.round(this._dy);
|
||||
this._dw = Math.round(this._dw);
|
||||
this._dh = Math.round(this._dh);
|
||||
|
||||
for (var i = 0; i < this.regions.length; i++)
|
||||
{
|
||||
if (this._dynamicTexture)
|
||||
{
|
||||
this.regions[i].render(this.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.regions[i].render(this.context, this._texture, this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create repeating texture with _texture, and store it into the _dynamicTexture.
|
||||
* Used to create texture when texture image is small than size of the zone.
|
||||
*/
|
||||
private createRepeatingTexture(regionWidth: number, regionHeight: number) {
|
||||
|
||||
// Work out how many we'll need of the source image to make it tile properly
|
||||
var tileWidth = Math.ceil(this._texture.width / regionWidth) * regionWidth;
|
||||
var tileHeight = Math.ceil(this._texture.height / regionHeight) * regionHeight;
|
||||
|
||||
this._dynamicTexture = new DynamicTexture(this._game, tileWidth, tileHeight);
|
||||
|
||||
this._dynamicTexture.context.rect(0, 0, tileWidth, tileHeight);
|
||||
this._dynamicTexture.context.fillStyle = this._dynamicTexture.context.createPattern(this._texture, "repeat");
|
||||
this._dynamicTexture.context.fill();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../AnimationManager.d.ts" />
|
||||
/// <reference path="GameObject.d.ts" />
|
||||
/// <reference path="../system/Camera.d.ts" />
|
||||
module Phaser {
|
||||
class Sprite extends GameObject {
|
||||
constructor(game: Game, x?: number, y?: number, key?: string);
|
||||
private _texture;
|
||||
private _dynamicTexture;
|
||||
private _sx;
|
||||
private _sy;
|
||||
private _sw;
|
||||
private _sh;
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _dw;
|
||||
private _dh;
|
||||
public animations: AnimationManager;
|
||||
public renderDebug: bool;
|
||||
public renderDebugColor: string;
|
||||
public renderDebugPointColor: string;
|
||||
public flipped: bool;
|
||||
public loadGraphic(key: string): Sprite;
|
||||
public loadDynamicTexture(texture: DynamicTexture): Sprite;
|
||||
public makeGraphic(width: number, height: number, color?: number): Sprite;
|
||||
public inCamera(camera: Rectangle): bool;
|
||||
public postUpdate(): void;
|
||||
public frame : number;
|
||||
public frameName : string;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
|
||||
private renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
public renderDebugInfo(x: number, y: number, color?: string): void;
|
||||
}
|
||||
}
|
||||
@@ -1,458 +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 {
|
||||
|
||||
/**
|
||||
* Sprite constructor
|
||||
* Create a new <code>Sprite</code>.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param [x] {number} the initial x position of the sprite.
|
||||
* @param [y] {number} the initial y position of the sprite.
|
||||
* @param [key] {string} Key of the graphic you want to load for this sprite.
|
||||
*/
|
||||
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.cacheKey = key;
|
||||
this.loadGraphic(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.frameBounds.width = 16;
|
||||
this.frameBounds.height = 16;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Texture of this sprite to be rendered.
|
||||
*/
|
||||
private _texture;
|
||||
|
||||
/**
|
||||
* Texture of this sprite is DynamicTexture? (default to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* This manages animations of the sprite. You can modify animations though it. (see AnimationManager)
|
||||
* @type AnimationManager
|
||||
*/
|
||||
public animations: AnimationManager;
|
||||
|
||||
/**
|
||||
* The cache key that was used for this texture (if any)
|
||||
*/
|
||||
public cacheKey: string;
|
||||
|
||||
/**
|
||||
* Render bound of this sprite for debugging? (default to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public renderDebug: bool = false;
|
||||
|
||||
/**
|
||||
* Color of the Sprite when no image is present. Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public fillColor: string = 'rgb(255,255,255)';
|
||||
|
||||
/**
|
||||
* Color of bound when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public renderDebugColor: string = 'rgba(0,255,0,0.5)';
|
||||
|
||||
/**
|
||||
* Color of points when render debug. (see renderDebug) Format is a css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public renderDebugPointColor: string = 'rgba(255,255,255,1)';
|
||||
|
||||
/**
|
||||
* Flip the graphic horizontally? (defaults to false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public flipped: bool = false;
|
||||
|
||||
/**
|
||||
* Load graphic for this sprite. (graphic can be SpriteSheet or Texture)
|
||||
* @param key {string} Key of the graphic you want to load for this sprite.
|
||||
* @param clearAnimations {boolean} If this Sprite has a set of animation data already loaded you can choose to keep or clear it with this boolean
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public loadGraphic(key: string, clearAnimations: bool = true): Sprite {
|
||||
|
||||
if (clearAnimations && this.animations.frameData !== null)
|
||||
{
|
||||
this.animations.destroy();
|
||||
}
|
||||
|
||||
if (this._game.cache.getImage(key) !== null)
|
||||
{
|
||||
if (this._game.cache.isSpriteSheet(key) == false)
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.frameBounds.width = this._texture.width;
|
||||
this.frameBounds.height = this._texture.height;
|
||||
this.collisionMask.width = this._texture.width;
|
||||
this.collisionMask.height = this._texture.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._texture = this._game.cache.getImage(key);
|
||||
this.animations.loadFrameData(this._game.cache.getFrameData(key));
|
||||
this.collisionMask.width = this.animations.currentFrame.width;
|
||||
this.collisionMask.height = this.animations.currentFrame.height;
|
||||
}
|
||||
|
||||
this._dynamicTexture = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a DynamicTexture as its texture.
|
||||
* @param texture {DynamicTexture} The texture object to be used by this sprite.
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public loadDynamicTexture(texture: DynamicTexture): Sprite {
|
||||
|
||||
this._texture = texture;
|
||||
|
||||
this.frameBounds.width = this._texture.width;
|
||||
this.frameBounds.height = this._texture.height;
|
||||
|
||||
this._dynamicTexture = true;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates a flat colored square image dynamically.
|
||||
* @param width {number} The width of the sprite you want to generate.
|
||||
* @param height {number} The height of the sprite you want to generate.
|
||||
* @param [color] {number} specifies the color of the generated block. (format is 0xAARRGGBB)
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public makeGraphic(width: number, height: number, color: string = 'rgb(255,255,255)'): Sprite {
|
||||
|
||||
this._texture = null;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.fillColor = color;
|
||||
this._dynamicTexture = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this object is visible in a specific camera rectangle.
|
||||
* @param camera {Rectangle} The rectangle you want to check.
|
||||
* @return {boolean} Return true if bounds of this sprite intersects the given rectangle, otherwise return false.
|
||||
*/
|
||||
public inCamera(camera: Rectangle, cameraOffsetX: number, cameraOffsetY: number): bool {
|
||||
|
||||
// Object fixed in place regardless of the camera scrolling? Then it's always visible
|
||||
if (this.scrollFactor.x == 0 && this.scrollFactor.y == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
this._dx = (this.frameBounds.x - camera.x);
|
||||
this._dy = (this.frameBounds.y - camera.y);
|
||||
this._dw = this.frameBounds.width * this.scale.x;
|
||||
this._dh = this.frameBounds.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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically called after update() by the game loop, this function just updates animations.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this sprite to specific camera. Called by game loop after update().
|
||||
* @param camera {Camera} Camera this sprite will be rendered to.
|
||||
* @cameraOffsetX {number} X offset to the camera.
|
||||
* @cameraOffsetY {number} Y offset to the camera.
|
||||
* @return {boolean} Return false if not rendered, otherwise return true.
|
||||
*/
|
||||
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.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView, cameraOffsetX, cameraOffsetY) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alpha
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
var globalAlpha = this.context.globalAlpha;
|
||||
this.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = 0;
|
||||
this._sy = 0;
|
||||
this._sw = this.frameBounds.width;
|
||||
this._sh = this.frameBounds.height;
|
||||
|
||||
this._dx = (cameraOffsetX * this.scrollFactor.x) + this.frameBounds.topLeft.x - (camera.worldView.x * this.scrollFactor.x);
|
||||
this._dy = (cameraOffsetY * this.scrollFactor.y) + this.frameBounds.topLeft.y - (camera.worldView.y * this.scrollFactor.y);
|
||||
this._dw = this.frameBounds.width * this.scale.x;
|
||||
this._dh = this.frameBounds.height * this.scale.y;
|
||||
|
||||
if (this.align == GameObject.ALIGN_TOP_CENTER)
|
||||
{
|
||||
this._dx -= this.frameBounds.halfWidth * this.scale.x;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_TOP_RIGHT)
|
||||
{
|
||||
this._dx -= this.frameBounds.width * this.scale.x;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER_LEFT)
|
||||
{
|
||||
this._dy -= this.frameBounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER)
|
||||
{
|
||||
this._dx -= this.frameBounds.halfWidth * this.scale.x;
|
||||
this._dy -= this.frameBounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_CENTER_RIGHT)
|
||||
{
|
||||
this._dx -= this.frameBounds.width * this.scale.x;
|
||||
this._dy -= this.frameBounds.halfHeight * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_LEFT)
|
||||
{
|
||||
this._dy -= this.frameBounds.height * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_CENTER)
|
||||
{
|
||||
this._dx -= this.frameBounds.halfWidth * this.scale.x;
|
||||
this._dy -= this.frameBounds.height * this.scale.y;
|
||||
}
|
||||
else if (this.align == GameObject.ALIGN_BOTTOM_RIGHT)
|
||||
{
|
||||
this._dx -= this.frameBounds.width * this.scale.x;
|
||||
this._dy -= this.frameBounds.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 || this.scrollFactor.y !== 1)
|
||||
{
|
||||
//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.rotationOffset !== 0 || this.flipped == true)
|
||||
{
|
||||
this.context.save();
|
||||
this.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
|
||||
|
||||
if (this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0))
|
||||
{
|
||||
this.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
|
||||
}
|
||||
|
||||
this._dx = -(this._dw / 2);
|
||||
this._dy = -(this._dh / 2);
|
||||
|
||||
if (this.flipped == true)
|
||||
{
|
||||
this.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.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.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.context.fillStyle = this.fillColor;
|
||||
this.context.fillRect(this._dx, this._dy, this._dw, this._dh);
|
||||
}
|
||||
|
||||
if (this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0)
|
||||
{
|
||||
//this.context.translate(0, 0);
|
||||
this.context.restore();
|
||||
}
|
||||
|
||||
if (this.renderDebug)
|
||||
{
|
||||
this.renderBounds(camera, cameraOffsetX, cameraOffsetY);
|
||||
//this.collisionMask.render(camera, cameraOffsetX, cameraOffsetY);
|
||||
}
|
||||
|
||||
if (globalAlpha > -1)
|
||||
{
|
||||
this.context.globalAlpha = globalAlpha;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the bounding box around this Sprite and the contact points. Useful for visually debugging.
|
||||
* @param camera {Camera} Camera the bound will be rendered to.
|
||||
* @param cameraOffsetX {number} X offset of bound to the camera.
|
||||
* @param cameraOffsetY {number} Y offset of bound to the camera.
|
||||
*/
|
||||
private renderBounds(camera:Camera, cameraOffsetX:number, cameraOffsetY:number) {
|
||||
|
||||
this._dx = cameraOffsetX + (this.frameBounds.topLeft.x - camera.worldView.x);
|
||||
this._dy = cameraOffsetY + (this.frameBounds.topLeft.y - camera.worldView.y);
|
||||
|
||||
this.context.fillStyle = this.renderDebugColor;
|
||||
this.context.fillRect(this._dx, this._dy, this.frameBounds.width, this.frameBounds.height);
|
||||
|
||||
//this.context.fillStyle = this.renderDebugPointColor;
|
||||
|
||||
//var hw = this.frameBounds.halfWidth * this.scale.x;
|
||||
//var hh = this.frameBounds.halfHeight * this.scale.y;
|
||||
//var sw = (this.frameBounds.width * this.scale.x) - 1;
|
||||
//var sh = (this.frameBounds.height * this.scale.y) - 1;
|
||||
|
||||
//this.context.fillRect(this._dx, this._dy, 1, 1); // top left
|
||||
//this.context.fillRect(this._dx + hw, this._dy, 1, 1); // top center
|
||||
//this.context.fillRect(this._dx + sw, this._dy, 1, 1); // top right
|
||||
//this.context.fillRect(this._dx, this._dy + hh, 1, 1); // left center
|
||||
//this.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); // center
|
||||
//this.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); // right center
|
||||
//this.context.fillRect(this._dx, this._dy + sh, 1, 1); // bottom left
|
||||
//this.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
|
||||
//this.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render debug infos. (including name, bounds info, position and some other properties)
|
||||
* @param x {number} X position of the debug info to be rendered.
|
||||
* @param y {number} Y position of the debug info to be rendered.
|
||||
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this.context.fillStyle = color;
|
||||
this.context.fillText('Sprite: ' + this.name + ' (' + this.frameBounds.width + ' x ' + this.frameBounds.height + ')', x, y);
|
||||
this.context.fillText('x: ' + this.frameBounds.x.toFixed(1) + ' y: ' + this.frameBounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
|
||||
this.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.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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="GameObject.d.ts" />
|
||||
/// <reference path="../system/TilemapLayer.d.ts" />
|
||||
/// <reference path="../system/Tile.d.ts" />
|
||||
module Phaser {
|
||||
class Tilemap extends GameObject {
|
||||
constructor(game: Game, key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number);
|
||||
static FORMAT_CSV: number;
|
||||
static FORMAT_TILED_JSON: number;
|
||||
public tiles: Tile[];
|
||||
public layers: TilemapLayer[];
|
||||
public currentLayer: TilemapLayer;
|
||||
public collisionLayer: TilemapLayer;
|
||||
public mapFormat: number;
|
||||
public update(): void;
|
||||
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
|
||||
private parseCSV(data, key, tileWidth, tileHeight);
|
||||
private parseTiledJSON(data, key);
|
||||
private generateTiles(qty);
|
||||
public widthInPixels : number;
|
||||
public heightInPixels : number;
|
||||
public setCollisionRange(start: number, end: number, collision?: number, resetCollisions?: bool): void;
|
||||
public setCollisionByIndex(values: number[], collision?: number, resetCollisions?: bool): void;
|
||||
public getTile(x: number, y: number, layer?: number): Tile;
|
||||
public getTileFromWorldXY(x: number, y: number, layer?: number): Tile;
|
||||
public getTileFromInputXY(layer?: number): Tile;
|
||||
public getTileOverlaps(object: GameObject): bool;
|
||||
public collide(objectOrGroup?, callback?): bool;
|
||||
public collideGameObject(object: GameObject): bool;
|
||||
}
|
||||
}
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Circle {
|
||||
constructor(x?: number, y?: number, diameter?: number);
|
||||
private _diameter;
|
||||
private _radius;
|
||||
public x: number;
|
||||
public y: number;
|
||||
public diameter : number;
|
||||
public radius : number;
|
||||
public circumference(): number;
|
||||
public bottom : number;
|
||||
public left : number;
|
||||
public right : number;
|
||||
public top : number;
|
||||
public area : number;
|
||||
public isEmpty : bool;
|
||||
public intersectCircleLine(line: Line): bool;
|
||||
public clone(output?: Circle): Circle;
|
||||
public contains(x: number, y: number): bool;
|
||||
public containsPoint(point: Point): bool;
|
||||
public containsCircle(circle: Circle): bool;
|
||||
public copyFrom(source: Circle): Circle;
|
||||
public copyTo(target: Circle): Circle;
|
||||
public distanceTo(target: any, round?: bool): number;
|
||||
public equals(toCompare: Circle): bool;
|
||||
public intersects(toIntersect: Circle): bool;
|
||||
public circumferencePoint(angle: number, asDegrees?: bool, output?: Point): Point;
|
||||
public offset(dx: number, dy: number): Circle;
|
||||
public offsetPoint(point: Point): Circle;
|
||||
public setTo(x: number, y: number, diameter: number): Circle;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class IntersectResult {
|
||||
public result: bool;
|
||||
public x: number;
|
||||
public y: number;
|
||||
public x1: number;
|
||||
public y1: number;
|
||||
public x2: number;
|
||||
public y2: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public setTo(x1: number, y1: number, x2?: number, y2?: number, width?: number, height?: number): void;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-27
@@ -1,27 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Line {
|
||||
constructor(x1?: number, y1?: number, x2?: number, y2?: number);
|
||||
public x1: number;
|
||||
public y1: number;
|
||||
public x2: number;
|
||||
public y2: number;
|
||||
public clone(output?: Line): Line;
|
||||
public copyFrom(source: Line): Line;
|
||||
public copyTo(target: Line): Line;
|
||||
public setTo(x1?: number, y1?: number, x2?: number, y2?: number): Line;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public length : number;
|
||||
public getY(x: number): number;
|
||||
public angle : number;
|
||||
public slope : number;
|
||||
public perpSlope : number;
|
||||
public yIntercept : number;
|
||||
public isPointOnLine(x: number, y: number): bool;
|
||||
public isPointOnLineSegment(x: number, y: number): bool;
|
||||
public intersectLineLine(line): any;
|
||||
public perp(x: number, y: number, output?: Line): Line;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class MicroPoint {
|
||||
constructor(x?: number, y?: number, parent?: any);
|
||||
private _x;
|
||||
private _y;
|
||||
public parent: any;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public copyFrom(source: any): MicroPoint;
|
||||
public copyTo(target: any): MicroPoint;
|
||||
public setTo(x: number, y: number, callParent?: bool): MicroPoint;
|
||||
public equals(toCompare): bool;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
@@ -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 + ')}]';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-28
@@ -1,28 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Point {
|
||||
constructor(x?: number, y?: number);
|
||||
public x: number;
|
||||
public y: number;
|
||||
public add(toAdd: Point, output?: Point): Point;
|
||||
public addTo(x?: number, y?: number): Point;
|
||||
public subtractFrom(x?: number, y?: number): Point;
|
||||
public invert(): Point;
|
||||
public clamp(min: number, max: number): Point;
|
||||
public clampX(min: number, max: number): Point;
|
||||
public clampY(min: number, max: number): Point;
|
||||
public clone(output?: Point): Point;
|
||||
public copyFrom(source: Point): Point;
|
||||
public copyTo(target: Point): Point;
|
||||
public distanceTo(target: Point, round?: bool): number;
|
||||
static distanceBetween(pointA: Point, pointB: Point, round?: bool): number;
|
||||
public distanceCompare(target: Point, distance: number): bool;
|
||||
public equals(toCompare: Point): bool;
|
||||
public interpolate(pointA, pointB, f): void;
|
||||
public offset(dx: number, dy: number): Point;
|
||||
public polar(length, angle): void;
|
||||
public setTo(x: number, y: number): Point;
|
||||
public subtract(point: Point, output?: Point): Point;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
@@ -1,367 +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) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the point around the x/y coordinates given to the desired angle
|
||||
* @param x {number} The x coordinate of the anchor point
|
||||
* @param y {number} The y coordinate of the anchor point
|
||||
* @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from.
|
||||
* @param {Boolean} asDegrees Is the given angle in radians (false) or degrees (true)?
|
||||
* @param {Number} distance An optional distance constraint between the point and the anchor
|
||||
* @return The modified point object
|
||||
*/
|
||||
public rotate(cx: number, cy: number, angle: number, asDegrees: bool = false, distance?:number = null) {
|
||||
|
||||
if (asDegrees)
|
||||
{
|
||||
angle = angle * GameMath.DEG_TO_RAD;
|
||||
}
|
||||
|
||||
// Get distance from origin (cx/cy) to this point
|
||||
if (distance === null)
|
||||
{
|
||||
distance = Math.sqrt(((cx - this.x) * (cx - this.x)) + ((cy - this.y) * (cy - this.y)));
|
||||
}
|
||||
|
||||
return this.setTo(cx + distance * Math.cos(angle), cy + distance * Math.sin(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,60 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Polygon
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Polygon {
|
||||
|
||||
/**
|
||||
* A *convex* clockwise polygon
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param {Vector2} pos A vector representing the origin of the polygon (all other points are relative to this one)
|
||||
* @param {Array.<Vector2>} points An Array of vectors representing the points in the polygon, in clockwise order.
|
||||
**/
|
||||
constructor(pos?: Vector2 = new Vector2, points?: Vector2[] = [], parent?:any = null) {
|
||||
|
||||
this.pos = pos;
|
||||
this.points = points;
|
||||
this.parent = parent;
|
||||
this.recalc();
|
||||
|
||||
}
|
||||
|
||||
public parent: any;
|
||||
public pos: Vector2;
|
||||
public points: Vector2[];
|
||||
public edges: Vector2[];
|
||||
public normals: Vector2[];
|
||||
|
||||
/**
|
||||
* Recalculate the edges and normals of the polygon. This
|
||||
* MUST be called if the points array is modified at all and
|
||||
* the edges or normals are to be accessed.
|
||||
*/
|
||||
public recalc() {
|
||||
|
||||
var points = this.points;
|
||||
var len = points.length;
|
||||
|
||||
this.edges = [];
|
||||
this.normals = [];
|
||||
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
var p1 = points[i];
|
||||
var p2 = i < len - 1 ? points[i + 1] : points[0];
|
||||
var e = new Vector2().copyFrom(p2).sub(p1);
|
||||
var n = new Vector2().copyFrom(e).perp().normalize();
|
||||
this.edges.push(e);
|
||||
this.normals.push(n);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Quad {
|
||||
constructor(x?: number, y?: number, width?: number, height?: number);
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public setTo(x: number, y: number, width: number, height: number): Quad;
|
||||
public left : number;
|
||||
public right : number;
|
||||
public top : number;
|
||||
public bottom : number;
|
||||
public halfWidth : number;
|
||||
public halfHeight : number;
|
||||
public intersects(q, t?: number): bool;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Polygon.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Quad
|
||||
*
|
||||
* A Quad object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
|
||||
* Very much like a Rectangle only without all of the additional methods and properties of that class.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Quad {
|
||||
|
||||
/**
|
||||
* Creates a new Quad 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 Quad
|
||||
* @constructor
|
||||
* @param {Number} x The x coordinate of the top-left corner of the quad.
|
||||
* @param {Number} y The y coordinate of the top-left corner of the quad.
|
||||
* @param {Number} width The width of the quad.
|
||||
* @param {Number} height The height of the quad.
|
||||
* @return {Quad} This object
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
|
||||
|
||||
this.setTo(x, y, width, height);
|
||||
|
||||
}
|
||||
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
|
||||
/**
|
||||
* Sets the Quad to the specified size.
|
||||
* @method setTo
|
||||
* @param {Number} x The x coordinate of the top-left corner of the quad.
|
||||
* @param {Number} y The y coordinate of the top-left corner of the quad.
|
||||
* @param {Number} width The width of the quad.
|
||||
* @param {Number} height The height of the quad.
|
||||
* @return {Quad} This object
|
||||
**/
|
||||
public setTo(x: number, y: number, width: number, height: number): Quad {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public get left(): number {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public get right(): number {
|
||||
return this.x + this.width;
|
||||
}
|
||||
|
||||
public get top(): number {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public get bottom(): number {
|
||||
return this.y + this.height;
|
||||
}
|
||||
|
||||
public get halfWidth(): number {
|
||||
return this.width / 2;
|
||||
}
|
||||
|
||||
public get halfHeight(): number {
|
||||
return this.height / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the object specified intersects (overlaps) with this Quad object.
|
||||
* This method checks the x, y, width, and height properties of the specified Quad object to see if it intersects with this Quad object.
|
||||
* @method intersects
|
||||
* @param {Object} quad The object to check for intersection with this Quad. Must have left/right/top/bottom properties (Rectangle, Quad).
|
||||
* @param {Number} tolerance 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 Quad; otherwise false.
|
||||
**/
|
||||
public intersects(quad, tolerance?: number = 0): bool {
|
||||
|
||||
return !(quad.left > this.right + tolerance || quad.right < this.left - tolerance || quad.top > this.bottom + tolerance || quad.bottom < this.top - tolerance);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the object specified intersects (overlaps) with the given values.
|
||||
* @method intersectsProps
|
||||
* @param {Number} left
|
||||
* @param {Number} right
|
||||
* @param {Number} top
|
||||
* @param {Number} bottomt
|
||||
* @param {Number} tolerance 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 Quad; otherwise false.
|
||||
**/
|
||||
public intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance?: number = 0): bool {
|
||||
|
||||
return !(left > this.right + tolerance || right < this.left - tolerance || top > this.bottom + tolerance || bottom < this.top - tolerance);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the specified coordinates are contained within the region defined by this Quad 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.x && x <= this.right && y >= this.y && y <= this.bottom)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copies the x/y/width/height values from the source object into this Quad
|
||||
* @method copyFrom
|
||||
* @param {Any} source The source object to copy from. Can be a Quad, Rectangle or any object with exposed x/y/width/height properties
|
||||
* @return {Quad} This object
|
||||
**/
|
||||
public copyFrom(source): Quad {
|
||||
|
||||
return this.setTo(source.x, source.y, source.width, source.height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the x/y/width/height values from this Quad into the given target object
|
||||
* @method copyTo
|
||||
* @param {Any} target The object to copy this quads values in to. Can be a Quad, Rectangle or any object with exposed x/y/width/height properties
|
||||
* @return {Any} The target object
|
||||
**/
|
||||
public copyTo(target): any {
|
||||
|
||||
return target.copyFrom(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a Polygon that is the same as this Quad.
|
||||
* @method toPolygon
|
||||
* @return {Polygon} A new Polygon that represents this quad.
|
||||
**/
|
||||
public toPolygon(): Polygon {
|
||||
|
||||
return new Polygon(new Vector2(this.x, this.y), [
|
||||
new Vector2(), new Vector2(this.width, 0),
|
||||
new Vector2(this.width, this.height), new Vector2(0, this.height)
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the object.
|
||||
**/
|
||||
public toString(): string {
|
||||
|
||||
return "[{Quad (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-57
@@ -1,57 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="MicroPoint.d.ts" />
|
||||
module Phaser {
|
||||
class Rectangle {
|
||||
constructor(x?: number, y?: number, width?: number, height?: number);
|
||||
private _tempX;
|
||||
private _tempY;
|
||||
private _tempWidth;
|
||||
private _tempHeight;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public topLeft: MicroPoint;
|
||||
public topCenter: MicroPoint;
|
||||
public topRight: MicroPoint;
|
||||
public leftCenter: MicroPoint;
|
||||
public center: MicroPoint;
|
||||
public rightCenter: MicroPoint;
|
||||
public bottomLeft: MicroPoint;
|
||||
public bottomCenter: MicroPoint;
|
||||
public bottomRight: MicroPoint;
|
||||
private _width;
|
||||
private _height;
|
||||
private _halfWidth;
|
||||
private _halfHeight;
|
||||
public length: number;
|
||||
public updateBounds(): void;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public halfWidth : number;
|
||||
public halfHeight : number;
|
||||
public bottom : number;
|
||||
public left : number;
|
||||
public right : number;
|
||||
public size(output?: Point): Point;
|
||||
public volume : number;
|
||||
public perimeter : number;
|
||||
public top : number;
|
||||
public clone(output?: Rectangle): Rectangle;
|
||||
public contains(x: number, y: number): bool;
|
||||
public containsPoint(point: any): bool;
|
||||
public containsRect(rect: Rectangle): bool;
|
||||
public copyFrom(source: Rectangle): Rectangle;
|
||||
public copyTo(target: Rectangle): Rectangle;
|
||||
public equals(toCompare: Rectangle): bool;
|
||||
public inflate(dx: number, dy: number): Rectangle;
|
||||
public inflatePoint(point: Point): Rectangle;
|
||||
public intersection(toIntersect: Rectangle, output?: Rectangle): Rectangle;
|
||||
public intersects(r2: Rectangle, t?: number): bool;
|
||||
public isEmpty : bool;
|
||||
public offset(dx: number, dy: number): Rectangle;
|
||||
public offsetPoint(point: Point): Rectangle;
|
||||
public setEmpty(): Rectangle;
|
||||
public setTo(x: number, y: number, width: number, height: number): Rectangle;
|
||||
public union(toUnion: Rectangle, output?: Rectangle): Rectangle;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
@@ -1,810 +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.
|
||||
* @param {Number} height The height of the rectangle.
|
||||
* @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,87 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="Polygon.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Response
|
||||
*
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Response {
|
||||
|
||||
/**
|
||||
* An object representing the result of an intersection. Contain information about:
|
||||
* - The two objects participating in the intersection
|
||||
* - The vector representing the minimum change necessary to extract the first object
|
||||
* from the second one.
|
||||
* - Whether the first object is entirely inside the second, or vice versa.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
this.a = null;
|
||||
this.b = null;
|
||||
this.overlapN = new Vector2;
|
||||
this.overlapV = new Vector2;
|
||||
|
||||
this.clear();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The first object in the collision
|
||||
*/
|
||||
public a;
|
||||
|
||||
/**
|
||||
* The second object in the collision
|
||||
*/
|
||||
public b;
|
||||
|
||||
/**
|
||||
* The shortest colliding axis (unit-vector)
|
||||
*/
|
||||
public overlapN: Vector2;
|
||||
|
||||
/**
|
||||
* The overlap vector (i.e. overlapN.scale(overlap, overlap)).
|
||||
* If this vector is subtracted from the position of `a`, `a` and `b` will no longer be colliding.
|
||||
*/
|
||||
public overlapV: Vector2;
|
||||
|
||||
/**
|
||||
* Whether the first object is completely inside the second.
|
||||
*/
|
||||
public aInB: bool;
|
||||
|
||||
/**
|
||||
* Whether the second object is completely inside the first.
|
||||
*/
|
||||
public bInA: bool;
|
||||
|
||||
/**
|
||||
* Magnitude of the overlap on the shortest colliding axis
|
||||
*/
|
||||
public overlap: number;
|
||||
|
||||
/**
|
||||
* Set some values of the response back to their defaults. Call this between tests if
|
||||
* you are going to reuse a single Response object for multiple intersection tests (recommented)
|
||||
*
|
||||
* @return {Response} This for chaining
|
||||
*/
|
||||
public clear() {
|
||||
|
||||
this.aInB = true;
|
||||
this.bInA = true;
|
||||
this.overlap = Number.MAX_VALUE;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,457 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Vector2
|
||||
*
|
||||
* A two dimensional vector.
|
||||
* Contains methods and ideas from verlet-js by Sub Protocol, SAT.js by Jim Riecken and N by Metanet Software. Brandon Jones, Colin MacKenzie IV
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class Vector2 {
|
||||
|
||||
/**
|
||||
* Creates a new Vector2 object.
|
||||
* @class Vector2
|
||||
* @constructor
|
||||
* @param {Number} x The x position of the vector
|
||||
* @param {Number} y The y position of the vector
|
||||
* @return {Vector2} This object
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0) {
|
||||
|
||||
//var GLMAT_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
}
|
||||
|
||||
public x: number;
|
||||
public y: number;
|
||||
|
||||
public setTo(x: number, y: number): Vector2 {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add this vector to the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public add(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x + v.x, this.y + v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract this vector to the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public sub(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x - v.x, this.y - v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector with the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public mul(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x * v.x, this.y * v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by the given one and return the result.
|
||||
*
|
||||
* @param {Vector2} v The other Vector.
|
||||
* @param {Vector2} The output Vector.
|
||||
* @return {Vector2} The new Vector
|
||||
*/
|
||||
public div(v: Vector2, output?:Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x / v.x, this.y / v.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale this vector by the given values and return the result.
|
||||
*
|
||||
* @param {number} x The scaling factor in the x direction.
|
||||
* @param {?number=} y The scaling factor in the y direction. If this
|
||||
* is not specified, the x scaling factor will be used.
|
||||
* @return {Vector} The new Vector
|
||||
*/
|
||||
public scale(x: number, y?:number = null, output?:Vector2 = new Vector2): Vector2 {
|
||||
|
||||
if (y === null)
|
||||
{
|
||||
y = x;
|
||||
}
|
||||
|
||||
return output.setTo(this.x * x, this.y * y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this vector by 90 degrees
|
||||
*
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public perp(output?: Vector2 = this): Vector2 {
|
||||
var x = this.x;
|
||||
return output.setTo(this.y, -x);
|
||||
}
|
||||
|
||||
// Same as copyFrom, used by VerletManager
|
||||
public mutableSet(v: Vector2): Vector2 {
|
||||
this.x = v.x;
|
||||
this.y = v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another vector to this one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableAdd(v: Vector2): Vector2 {
|
||||
this.x += v.x;
|
||||
this.y += v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract another vector from this one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableSub(v: Vector2): Vector2 {
|
||||
this.x -= v.x;
|
||||
this.y -= v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply another vector with this one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableMul(v: Vector2): Vector2 {
|
||||
this.x *= v.x;
|
||||
this.y *= v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by another one.
|
||||
*
|
||||
* @param {Vector} other The other Vector.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableDiv(v: Vector2): Vector2 {
|
||||
this.x /= v.x;
|
||||
this.y /= v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale this vector.
|
||||
*
|
||||
* @param {number} x The scaling factor in the x direction.
|
||||
* @param {?number=} y The scaling factor in the y direction. If this
|
||||
* is not specified, the x scaling factor will be used.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public mutableScale(x: number, y?:number): Vector2 {
|
||||
this.x *= x;
|
||||
this.y *= y || x;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply this vector by the given scalar.
|
||||
*
|
||||
* @param {number} scalar
|
||||
* @return {Vector2} This for chaining.
|
||||
*/
|
||||
public mutableMultiplyByScalar(scalar: number): Vector2 {
|
||||
this.x *= scalar;
|
||||
this.y *= scalar;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this vector by the given scalar.
|
||||
*
|
||||
* @param {number} scalar
|
||||
* @return {Vector2} This for chaining.
|
||||
*/
|
||||
public mutableDivideByScalar(scalar: number): Vector2 {
|
||||
this.x /= scalar;
|
||||
this.y /= scalar;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse this vector.
|
||||
*
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public reverse(): Vector2 {
|
||||
this.x = -this.x;
|
||||
this.y = -this.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public edge(v: Vector2, output?: Vector2 = new Vector2): Vector2 {
|
||||
return this.sub(v, output);
|
||||
}
|
||||
|
||||
public equals(v: Vector2): bool {
|
||||
return this.x == v.x && this.y == v.y;
|
||||
}
|
||||
|
||||
public epsilonEquals(v: Vector2, epsilon:number): bool {
|
||||
return Math.abs(this.x - v.x) <= epsilon && Math.abs(this.y - v.y) <= epsilon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of this vector.
|
||||
*
|
||||
* @return {number} The length of this vector.
|
||||
*/
|
||||
public length(): number {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length^2 of this vector.
|
||||
*
|
||||
* @return {number} The length^2 of this vector.
|
||||
*/
|
||||
public length2(): number {
|
||||
return (this.x * this.x) + (this.y * this.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance between this vector and the given vector.
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public distance(v: Vector2): number {
|
||||
return Math.sqrt(this.distance2(v));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance^2 between this vector and the given vector.
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public distance2(v: Vector2): number {
|
||||
return ((v.x - this.x) * (v.x - this.x)) + ((v.y - this.y) * (v.y - this.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Project this vector on to another vector.
|
||||
*
|
||||
* @param {Vector} other The vector to project onto.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public project(other: Vector2): Vector2 {
|
||||
|
||||
var amt = this.dot(other) / other.length2();
|
||||
|
||||
if (amt != 0)
|
||||
{
|
||||
this.x = amt * other.x;
|
||||
this.y = amt * other.y;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Project this vector onto a vector of unit length.
|
||||
*
|
||||
* @param {Vector} other The unit vector to project onto.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public projectN(other: Vector2): Vector2 {
|
||||
|
||||
var amt = this.dot(other);
|
||||
|
||||
if (amt != 0)
|
||||
{
|
||||
this.x = amt * other.x;
|
||||
this.y = amt * other.y;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reflect this vector on an arbitrary axis.
|
||||
*
|
||||
* @param {Vector} axis The vector representing the axis.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public reflect(axis): Vector2 {
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
this.project(axis).scale(2);
|
||||
this.x -= x;
|
||||
this.y -= y;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reflect this vector on an arbitrary axis (represented by a unit vector)
|
||||
*
|
||||
* @param {Vector} axis The unit vector representing the axis.
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public reflectN(axis): Vector2 {
|
||||
|
||||
var x = this.x;
|
||||
var y = this.y;
|
||||
this.projectN(axis).scale(2);
|
||||
this.x -= x;
|
||||
this.y -= y;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public getProjectionMagnitude(v: Vector2): number {
|
||||
|
||||
var den = v.dot(v);
|
||||
|
||||
if (den == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.abs(this.dot(v) / den);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public direction(output?: Vector2 = new Vector2): Vector2 {
|
||||
|
||||
output.copyFrom(this);
|
||||
return this.normalize(output);
|
||||
|
||||
}
|
||||
|
||||
public normalRightHand(output?: Vector2 = this): Vector2 {
|
||||
return output.setTo(this.y * -1, this.x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize (make unit length) this vector.
|
||||
*
|
||||
* @return {Vector} This for chaining.
|
||||
*/
|
||||
public normalize(output?: Vector2 = this): Vector2 {
|
||||
|
||||
var m = this.length();
|
||||
|
||||
if (m != 0)
|
||||
{
|
||||
output.setTo(this.x / m, this.y / m);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public getMagnitude(): number {
|
||||
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dot product of this vector against another.
|
||||
*
|
||||
* @param {Vector} other The vector to dot this one against.
|
||||
* @return {number} The dot product.
|
||||
*/
|
||||
public dot(v: Vector2): number {
|
||||
return ((this.x * v.x) + (this.y * v.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cross product of this vector against another.
|
||||
*
|
||||
* @param {Vector} other The vector to cross this one against.
|
||||
* @return {number} The cross product.
|
||||
*/
|
||||
public cross(v: Vector2): number {
|
||||
return ((this.x * v.y) - (this.y * v.x));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the angle between this vector and the given vector.
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public angle(v: Vector2): number {
|
||||
return Math.atan2(this.x * v.y - this.y * v.x, this.x * v.x + this.y * v.y);
|
||||
}
|
||||
|
||||
public angle2(vLeft: Vector2, vRight: Vector2): number {
|
||||
return vLeft.sub(this).angle(vRight.sub(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this vector around the origin to the given angle (theta) and return the result in a new Vector
|
||||
*
|
||||
* @return {Vector2} v The vector to check
|
||||
*/
|
||||
public rotate(origin, theta, output?: Vector2 = new Vector2): Vector2 {
|
||||
var x = this.x - origin.x;
|
||||
var y = this.y - origin.y;
|
||||
return output.setTo(x * Math.cos(theta) - y * Math.sin(theta) + origin.x, x * Math.sin(theta) + y * Math.cos(theta) + origin.y);
|
||||
}
|
||||
|
||||
public clone(output?: Vector2 = new Vector2): Vector2 {
|
||||
return output.setTo(this.x, this.y);
|
||||
}
|
||||
|
||||
public copyFrom(v: Vector2): Vector2 {
|
||||
this.x = v.x;
|
||||
this.y = v.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public copyTo(v: Vector2): Vector2 {
|
||||
return v.setTo(this.x, this.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method toString
|
||||
* @return {string} a string representation of the object.
|
||||
**/
|
||||
public toString(): string {
|
||||
return "[{Vector2 (x=" + this.x + " y=" + this.y + ")}]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Phaser
|
||||
*
|
||||
* v0.9.6 - May 21st 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 releasing Flixel on which Phaser took a lot of inspiration.
|
||||
*
|
||||
* "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.6';
|
||||
})(Phaser || (Phaser = {}));
|
||||
Vendored
-80
@@ -1,80 +0,0 @@
|
||||
/// <reference path="../gameobjects/Sprite.d.ts" />
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Camera {
|
||||
constructor(game: Game, id: number, x: number, y: number, width: number, height: number);
|
||||
private _game;
|
||||
private _clip;
|
||||
private _stageX;
|
||||
private _stageY;
|
||||
private _rotation;
|
||||
private _target;
|
||||
private _sx;
|
||||
private _sy;
|
||||
private _fxFlashColor;
|
||||
private _fxFlashComplete;
|
||||
private _fxFlashDuration;
|
||||
private _fxFlashAlpha;
|
||||
private _fxFadeColor;
|
||||
private _fxFadeComplete;
|
||||
private _fxFadeDuration;
|
||||
private _fxFadeAlpha;
|
||||
private _fxShakeIntensity;
|
||||
private _fxShakeDuration;
|
||||
private _fxShakeComplete;
|
||||
private _fxShakeOffset;
|
||||
private _fxShakeDirection;
|
||||
private _fxShakePrevX;
|
||||
private _fxShakePrevY;
|
||||
static STYLE_LOCKON: number;
|
||||
static STYLE_PLATFORMER: number;
|
||||
static STYLE_TOPDOWN: number;
|
||||
static STYLE_TOPDOWN_TIGHT: number;
|
||||
static SHAKE_BOTH_AXES: number;
|
||||
static SHAKE_HORIZONTAL_ONLY: number;
|
||||
static SHAKE_VERTICAL_ONLY: number;
|
||||
public ID: number;
|
||||
public worldView: Rectangle;
|
||||
public totalSpritesRendered: number;
|
||||
public scale: MicroPoint;
|
||||
public scroll: MicroPoint;
|
||||
public bounds: Rectangle;
|
||||
public deadzone: Rectangle;
|
||||
public showBorder: bool;
|
||||
public borderColor: string;
|
||||
public opaque: bool;
|
||||
private _bgColor;
|
||||
private _bgTexture;
|
||||
private _bgTextureRepeat;
|
||||
public showShadow: bool;
|
||||
public shadowColor: string;
|
||||
public shadowBlur: number;
|
||||
public shadowOffset: MicroPoint;
|
||||
public visible: bool;
|
||||
public alpha: number;
|
||||
public inputX: number;
|
||||
public inputY: number;
|
||||
public fx: FXManager;
|
||||
public flash(color?: number, duration?: number, onComplete?, force?: bool): void;
|
||||
public fade(color?: number, duration?: number, onComplete?, force?: bool): void;
|
||||
public shake(intensity?: number, duration?: number, onComplete?, force?: bool, direction?: number): void;
|
||||
public stopFX(): void;
|
||||
public follow(target: Sprite, style?: number): void;
|
||||
public focusOnXY(x: number, y: number): void;
|
||||
public focusOn(point): void;
|
||||
public setBounds(x?: number, y?: number, width?: number, height?: number): void;
|
||||
public update(): void;
|
||||
public render(): void;
|
||||
public backgroundColor : string;
|
||||
public setTexture(key: string, repeat?: string): void;
|
||||
public setPosition(x: number, y: number): void;
|
||||
public setSize(width: number, height: number): void;
|
||||
public renderDebugInfo(x: number, y: number, color?: string): void;
|
||||
public x : number;
|
||||
public y : number;
|
||||
public width : number;
|
||||
public height : number;
|
||||
public rotation : number;
|
||||
private checkClip();
|
||||
}
|
||||
}
|
||||
@@ -1,664 +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 {
|
||||
|
||||
/**
|
||||
*Sprite constructor
|
||||
* Instantiates a new camera at the specified location, with the specified size and zoom level.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param id {number} Unique identity.
|
||||
* @param x {number} X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
|
||||
* @param y {number} Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
|
||||
* @param width {number} The width of the camera display in pixels.
|
||||
* @param height {number} The height of the camera display in pixels.
|
||||
*/
|
||||
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;
|
||||
this.fx = new FXManager(this._game, this);
|
||||
|
||||
// The view into the world canvas we wish to render
|
||||
this.worldView = new Rectangle(0, 0, width, height);
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to Game.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Camera "follow" style preset: camera has no deadzone, just tracks the focus object directly.
|
||||
* @type {number}
|
||||
*/
|
||||
public static STYLE_LOCKON: number = 0;
|
||||
|
||||
/**
|
||||
* Camera "follow" style preset: camera deadzone is narrow but tall.
|
||||
* @type {number}
|
||||
*/
|
||||
public static STYLE_PLATFORMER: number = 1;
|
||||
|
||||
/**
|
||||
* Camera "follow" style preset: camera deadzone is a medium-size square around the focus object.
|
||||
* @type {number}
|
||||
*/
|
||||
public static STYLE_TOPDOWN: number = 2;
|
||||
|
||||
/**
|
||||
* Camera "follow" style preset: camera deadzone is a small square around the focus object.
|
||||
* @type {number}
|
||||
*/
|
||||
public static STYLE_TOPDOWN_TIGHT: number = 3;
|
||||
|
||||
/**
|
||||
* Identity of this camera.
|
||||
*/
|
||||
public ID: number;
|
||||
|
||||
/**
|
||||
* Camera view rectangle in world coordinate.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public worldView: Rectangle;
|
||||
|
||||
/**
|
||||
* How many sprites will be rendered by this camera.
|
||||
* @type {number}
|
||||
*/
|
||||
public totalSpritesRendered: number;
|
||||
|
||||
/**
|
||||
* Scale factor of the camera.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scale: MicroPoint = new MicroPoint(1, 1);
|
||||
|
||||
/**
|
||||
* Scrolling factor.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public scroll: MicroPoint = new MicroPoint(0, 0);
|
||||
|
||||
/**
|
||||
* Camera bounds.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public bounds: Rectangle = null;
|
||||
|
||||
/**
|
||||
* Sprite moving inside this rectangle will not cause camera moving.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public deadzone: Rectangle = null;
|
||||
|
||||
// Camera Border
|
||||
public disableClipping: bool = false;
|
||||
|
||||
/**
|
||||
* Whether render border of this camera or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showBorder: bool = false;
|
||||
|
||||
/**
|
||||
* Color of border of this camera. (in css color string)
|
||||
* @type {string}
|
||||
*/
|
||||
public borderColor: string = 'rgb(255,255,255)';
|
||||
|
||||
/**
|
||||
* Whether the camera background is opaque or not. If set to true the Camera is filled with
|
||||
* the value of Camera.backgroundColor every frame.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public opaque: bool = false;
|
||||
|
||||
/**
|
||||
* Clears the camera every frame using a canvas clearRect call (default to true).
|
||||
* Note that this erases anything below the camera as well, so do not use it in conjuction with a camera
|
||||
* that uses alpha or that needs to be able to manage opacity. Equally if Camera.opaque is set to true
|
||||
* then set Camera.clear to false to save rendering time.
|
||||
* By default the Stage will clear itself every frame, so be sure not to double-up clear calls.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public clear: bool = false;
|
||||
|
||||
/**
|
||||
* Background color in css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
private _bgColor: string = 'rgb(0,0,0)';
|
||||
|
||||
/**
|
||||
* Background texture to be rendered if background is visible.
|
||||
*/
|
||||
private _bgTexture;
|
||||
|
||||
/**
|
||||
* Background texture repeat style. (default is 'repeat')
|
||||
* @type {string}
|
||||
*/
|
||||
private _bgTextureRepeat: string = 'repeat';
|
||||
|
||||
// Camera Shadow
|
||||
/**
|
||||
* Render camera shadow or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showShadow: bool = false;
|
||||
|
||||
/**
|
||||
* Color of shadow, in css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public shadowColor: string = 'rgb(0,0,0)';
|
||||
|
||||
/**
|
||||
* Blur factor of shadow.
|
||||
* @type {number}
|
||||
*/
|
||||
public shadowBlur: number = 10;
|
||||
|
||||
/**
|
||||
* Offset of the shadow from camera's position.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public shadowOffset: MicroPoint = new MicroPoint(4, 4);
|
||||
|
||||
/**
|
||||
* Whether this camera visible or not. (default is true)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public visible: bool = true;
|
||||
|
||||
/**
|
||||
* Alpha of the camera. (everything rendered to this camera will be affected)
|
||||
* @type {number}
|
||||
*/
|
||||
public alpha: number = 1;
|
||||
|
||||
/**
|
||||
* The x position of the current input event in world coordinates.
|
||||
* @type {number}
|
||||
*/
|
||||
public inputX: number = 0;
|
||||
|
||||
/**
|
||||
* The y position of the current input event in world coordinates.
|
||||
* @type {number}
|
||||
*/
|
||||
public inputY: number = 0;
|
||||
|
||||
/**
|
||||
* Effects manager.
|
||||
* @type {FXManager}
|
||||
*/
|
||||
public fx: FXManager;
|
||||
|
||||
/**
|
||||
* Tells this camera object what sprite to track.
|
||||
* @param target {Sprite} The object you want the camera to track. Set to null to not follow anything.
|
||||
* @param [style] {number} Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the camera focus to this location instantly.
|
||||
* @param x {number} X position.
|
||||
* @param y {number} Y position.
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the camera focus to this location instantly.
|
||||
* @param point {any} Point you want to focus.
|
||||
*/
|
||||
public focusOn(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 {number} The smallest X value of your world (usually 0).
|
||||
* @param y {number} The smallest Y value of your world (usually 0).
|
||||
* @param width {number} The largest X value of your world (usually the world width).
|
||||
* @param height {number} The largest Y value of your world (usually the world height).
|
||||
*/
|
||||
public setBounds(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
|
||||
|
||||
if (this.bounds == null)
|
||||
{
|
||||
this.bounds = new Rectangle();
|
||||
}
|
||||
|
||||
this.bounds.setTo(x, y, width, height);
|
||||
|
||||
this.scroll.setTo(0, 0);
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update focusing and scrolling.
|
||||
*/
|
||||
public update() {
|
||||
|
||||
this.fx.preUpdate();
|
||||
|
||||
if (this._target !== null)
|
||||
{
|
||||
if (this.deadzone == null)
|
||||
{
|
||||
this.focusOnXY(this._target.x, this._target.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 cameras 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) + 1;
|
||||
}
|
||||
|
||||
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) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
this.fx.postUpdate();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw background, shadow, effects, and objects if this is visible.
|
||||
*/
|
||||
public render() {
|
||||
|
||||
if (this.visible === false || this.alpha < 0.1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._rotation !== 0 || this._clip || this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
}
|
||||
|
||||
// It may be safer/quicker to just save the context every frame regardless (needs testing on mobile - sucked on Android 2.x)
|
||||
//this._game.stage.context.save();
|
||||
|
||||
this.fx.preRender(this, this._stageX, this._stageY, this.worldView.width, this.worldView.height);
|
||||
|
||||
if (this.alpha !== 1)
|
||||
{
|
||||
this._game.stage.context.globalAlpha = this.alpha;
|
||||
}
|
||||
|
||||
this._sx = this._stageX;
|
||||
this._sy = this._stageY;
|
||||
|
||||
// Shadow
|
||||
if (this.showShadow == true)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
if (this.clear == true)
|
||||
{
|
||||
this._game.stage.context.clearRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
}
|
||||
|
||||
// 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 == true)
|
||||
{
|
||||
this._game.stage.context.shadowBlur = 0;
|
||||
this._game.stage.context.shadowOffsetX = 0;
|
||||
this._game.stage.context.shadowOffsetY = 0;
|
||||
}
|
||||
|
||||
this.fx.render(this, this._stageX, this._stageY, this.worldView.width, this.worldView.height);
|
||||
|
||||
// Clip the camera so we don't get sprites appearing outside the edges
|
||||
if (this._clip == true && this.disableClipping == false)
|
||||
{
|
||||
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 == true)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
// Scale off
|
||||
if (this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
this._game.stage.context.scale(1, 1);
|
||||
}
|
||||
|
||||
this.fx.postRender(this, this._sx, this._sy, this.worldView.width, this.worldView.height);
|
||||
|
||||
if (this._rotation !== 0 || (this._clip && this.disableClipping == false))
|
||||
{
|
||||
this._game.stage.context.translate(0, 0);
|
||||
}
|
||||
|
||||
if (this._rotation !== 0 || this._clip || this.scale.x !== 1 || this.scale.y !== 1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set camera background texture.
|
||||
* @param key {string} Asset key of the texture.
|
||||
* @param [repeat] {string} what kind of repeat will this texture used for background.
|
||||
*/
|
||||
public setTexture(key: string, repeat?: string = 'repeat') {
|
||||
|
||||
this._bgTexture = this._game.stage.context.createPattern(this._game.cache.getImage(key), repeat);
|
||||
this._bgTextureRepeat = repeat;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set position of this camera.
|
||||
* @param x {number} X position.
|
||||
* @param y {number} Y position.
|
||||
*/
|
||||
public setPosition(x: number, y: number) {
|
||||
|
||||
this._stageX = x;
|
||||
this._stageY = y;
|
||||
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Give this camera a new size.
|
||||
* @param width {number} Width of new size.
|
||||
* @param height {number} Height of new size.
|
||||
*/
|
||||
public setSize(width: number, height: number) {
|
||||
|
||||
this.worldView.width = width;
|
||||
this.worldView.height = height;
|
||||
this.checkClip();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render debug infos. (including id, position, rotation, scrolling factor, bounds and some other properties)
|
||||
* @param x {number} X position of the debug info to be rendered.
|
||||
* @param y {number} Y position of the debug info to be rendered.
|
||||
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
|
||||
*/
|
||||
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) {
|
||||
|
||||
if (value > this._game.stage.width)
|
||||
{
|
||||
value = this._game.stage.width;
|
||||
}
|
||||
|
||||
this.worldView.width = value;
|
||||
this.checkClip();
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this.worldView.height;
|
||||
}
|
||||
|
||||
public set height(value: number) {
|
||||
|
||||
if (value > this._game.stage.height)
|
||||
{
|
||||
value = this._game.stage.height;
|
||||
}
|
||||
|
||||
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,501 +0,0 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - CollisionMask
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class CollisionMask {
|
||||
|
||||
/**
|
||||
* CollisionMask constructor. Creates a new <code>CollisionMask</code> for the given GameObject.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param parent {Phaser.GameObject} The GameObject this CollisionMask belongs to.
|
||||
* @param x {number} The initial x position of the CollisionMask.
|
||||
* @param y {number} The initial y position of the CollisionMask.
|
||||
* @param width {number} The width of the CollisionMask.
|
||||
* @param height {number} The height of the CollisionMask.
|
||||
*/
|
||||
constructor(game: Game, parent: GameObject, x: number, y: number, width: number, height: number) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
|
||||
// By default the CollisionMask is a quad
|
||||
this.type = CollisionMask.QUAD;
|
||||
|
||||
this.quad = new Phaser.Quad(this._parent.x, this._parent.y, this._parent.width, this._parent.height);
|
||||
this.offset = new MicroPoint(0, 0);
|
||||
this.last = new MicroPoint(0, 0);
|
||||
|
||||
this._ref = this.quad;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
private _game;
|
||||
private _parent;
|
||||
|
||||
// An internal reference to the active collision shape
|
||||
private _ref;
|
||||
|
||||
/**
|
||||
* Geom type of this sprite. (available: QUAD, POINT, CIRCLE, LINE, RECTANGLE, POLYGON)
|
||||
* @type {number}
|
||||
*/
|
||||
public type: number = 0;
|
||||
|
||||
/**
|
||||
* Quad (a smaller version of Rectangle).
|
||||
* @type {number}
|
||||
*/
|
||||
public static QUAD: number = 0;
|
||||
|
||||
/**
|
||||
* Point.
|
||||
* @type {number}
|
||||
*/
|
||||
public static POINT: number = 1;
|
||||
|
||||
/**
|
||||
* Circle.
|
||||
* @type {number}
|
||||
*/
|
||||
public static CIRCLE: number = 2;
|
||||
|
||||
/**
|
||||
* Line.
|
||||
* @type {number}
|
||||
*/
|
||||
public static LINE: number = 3;
|
||||
|
||||
/**
|
||||
* Rectangle.
|
||||
* @type {number}
|
||||
*/
|
||||
public static RECTANGLE: number = 4;
|
||||
|
||||
/**
|
||||
* Polygon.
|
||||
* @type {number}
|
||||
*/
|
||||
public static POLYGON: number = 5;
|
||||
|
||||
/**
|
||||
* Rectangle shape container. A Rectangle instance.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public quad: Quad;
|
||||
|
||||
/**
|
||||
* Point shape container. A Point instance.
|
||||
* @type {Point}
|
||||
*/
|
||||
public point: Point;
|
||||
|
||||
/**
|
||||
* Circle shape container. A Circle instance.
|
||||
* @type {Circle}
|
||||
*/
|
||||
public circle: Circle;
|
||||
|
||||
/**
|
||||
* Line shape container. A Line instance.
|
||||
* @type {Line}
|
||||
*/
|
||||
public line: Line;
|
||||
|
||||
/**
|
||||
* Rectangle shape container. A Rectangle instance.
|
||||
* @type {Rectangle}
|
||||
*/
|
||||
public rect: Rectangle;
|
||||
|
||||
/**
|
||||
* A value from the top-left of the GameObject frame that this collisionMask is offset to.
|
||||
* If the CollisionMask is a Quad/Rectangle the offset relates to the top-left of that Quad.
|
||||
* If the CollisionMask is a Circle the offset relates to the center of the circle.
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public offset: MicroPoint;
|
||||
|
||||
/**
|
||||
* The previous x/y coordinates of the CollisionMask, used for hull calculations
|
||||
* @type {MicroPoint}
|
||||
*/
|
||||
public last: MicroPoint;
|
||||
|
||||
/**
|
||||
* Create a circle shape with specific diameter.
|
||||
* @param diameter {number} Diameter of the circle.
|
||||
* @return {CollisionMask} This
|
||||
*/
|
||||
createCircle(diameter: number): CollisionMask {
|
||||
|
||||
this.type = CollisionMask.CIRCLE;
|
||||
this.circle = new Circle(this.last.x, this.last.y, diameter);
|
||||
this._ref = this.circle;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-update is called right before update() on each object in the game loop.
|
||||
*/
|
||||
public preUpdate() {
|
||||
|
||||
this.last.x = this.x;
|
||||
this.last.y = this.y;
|
||||
|
||||
}
|
||||
|
||||
public update() {
|
||||
|
||||
this._ref.x = this._parent.x + this.offset.x;
|
||||
this._ref.y = this._parent.y + this.offset.y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the bounding box around this Sprite and the contact points. Useful for visually debugging.
|
||||
* @param camera {Camera} Camera the bound will be rendered to.
|
||||
* @param cameraOffsetX {number} X offset of bound to the camera.
|
||||
* @param cameraOffsetY {number} Y offset of bound to the camera.
|
||||
*/
|
||||
public render(camera:Camera, cameraOffsetX:number, cameraOffsetY:number) {
|
||||
|
||||
var _dx = cameraOffsetX + (this.x - camera.worldView.x);
|
||||
var _dy = cameraOffsetY + (this.y - camera.worldView.y);
|
||||
|
||||
this._parent.context.fillStyle = this._parent.renderDebugColor;
|
||||
|
||||
if (this.type == CollisionMask.QUAD)
|
||||
{
|
||||
this._parent.context.fillRect(_dx, _dy, this.width, this.height);
|
||||
}
|
||||
else if (this.type == CollisionMask.CIRCLE)
|
||||
{
|
||||
this._parent.context.beginPath();
|
||||
this._parent.context.arc(_dx, _dy, this.circle.radius, 0, Math.PI * 2);
|
||||
this._parent.context.fill();
|
||||
this._parent.context.closePath();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy all objects and references belonging to this CollisionMask
|
||||
*/
|
||||
public destroy() {
|
||||
|
||||
this._game = null;
|
||||
this._parent = null;
|
||||
this._ref = null;
|
||||
this.quad = null;
|
||||
this.point = null;
|
||||
this.circle = null;
|
||||
this.rect = null;
|
||||
this.line = null;
|
||||
this.offset = null;
|
||||
|
||||
}
|
||||
|
||||
public intersectsRaw(left: number, right: number, top: number, bottom: number): bool {
|
||||
|
||||
//if ((objBounds.x + objBounds.width > x) && (objBounds.x < x + width) && (objBounds.y + objBounds.height > y) && (objBounds.y < y + height))
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public intersectsVector(vector: Phaser.Vector2): bool {
|
||||
|
||||
if (this.type == CollisionMask.QUAD)
|
||||
{
|
||||
return this.quad.contains(vector.x, vector.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param source {GeomSprite} Sprite you want to check.
|
||||
* @return {boolean} Whether they overlaps or not.
|
||||
*/
|
||||
public intersects(source: CollisionMask): bool {
|
||||
|
||||
// Quad vs. Quad
|
||||
if (this.type == CollisionMask.QUAD && source.type == CollisionMask.QUAD)
|
||||
{
|
||||
return this.quad.intersects(source.quad);
|
||||
}
|
||||
|
||||
// Circle vs. Circle
|
||||
if (this.type == CollisionMask.CIRCLE && source.type == CollisionMask.CIRCLE)
|
||||
{
|
||||
return Collision.circleToCircle(this.circle, source.circle).result;
|
||||
}
|
||||
|
||||
// Circle vs. Rect
|
||||
if (this.type == CollisionMask.CIRCLE && source.type == CollisionMask.RECTANGLE)
|
||||
{
|
||||
return Collision.circleToRectangle(this.circle, source.rect).result;
|
||||
}
|
||||
|
||||
// Circle vs. Point
|
||||
if (this.type == CollisionMask.CIRCLE && source.type == CollisionMask.POINT)
|
||||
{
|
||||
return Collision.circleContainsPoint(this.circle, source.point).result;
|
||||
}
|
||||
|
||||
// Circle vs. Line
|
||||
if (this.type == CollisionMask.CIRCLE && source.type == CollisionMask.LINE)
|
||||
{
|
||||
return Collision.lineToCircle(source.line, this.circle).result;
|
||||
}
|
||||
|
||||
// Rect vs. Rect
|
||||
if (this.type == CollisionMask.RECTANGLE && source.type == CollisionMask.RECTANGLE)
|
||||
{
|
||||
return Collision.rectangleToRectangle(this.rect, source.rect).result;
|
||||
}
|
||||
|
||||
// Rect vs. Circle
|
||||
if (this.type == CollisionMask.RECTANGLE && source.type == CollisionMask.CIRCLE)
|
||||
{
|
||||
return Collision.circleToRectangle(source.circle, this.rect).result;
|
||||
}
|
||||
|
||||
// Rect vs. Point
|
||||
if (this.type == CollisionMask.RECTANGLE && source.type == CollisionMask.POINT)
|
||||
{
|
||||
return Collision.pointToRectangle(source.point, this.rect).result;
|
||||
}
|
||||
|
||||
// Rect vs. Line
|
||||
if (this.type == CollisionMask.RECTANGLE && source.type == CollisionMask.LINE)
|
||||
{
|
||||
return Collision.lineToRectangle(source.line, this.rect).result;
|
||||
}
|
||||
|
||||
// Point vs. Point
|
||||
if (this.type == CollisionMask.POINT && source.type == CollisionMask.POINT)
|
||||
{
|
||||
return this.point.equals(source.point);
|
||||
}
|
||||
|
||||
// Point vs. Circle
|
||||
if (this.type == CollisionMask.POINT && source.type == CollisionMask.CIRCLE)
|
||||
{
|
||||
return Collision.circleContainsPoint(source.circle, this.point).result;
|
||||
}
|
||||
|
||||
// Point vs. Rect
|
||||
if (this.type == CollisionMask.POINT && source.type == CollisionMask.RECTANGLE)
|
||||
{
|
||||
return Collision.pointToRectangle(this.point, source.rect).result;
|
||||
}
|
||||
|
||||
// Point vs. Line
|
||||
if (this.type == CollisionMask.POINT && source.type == CollisionMask.LINE)
|
||||
{
|
||||
return source.line.isPointOnLine(this.point.x, this.point.y);
|
||||
}
|
||||
|
||||
// Line vs. Line
|
||||
if (this.type == CollisionMask.LINE && source.type == CollisionMask.LINE)
|
||||
{
|
||||
return Collision.lineSegmentToLineSegment(this.line, source.line).result;
|
||||
}
|
||||
|
||||
// Line vs. Circle
|
||||
if (this.type == CollisionMask.LINE && source.type == CollisionMask.CIRCLE)
|
||||
{
|
||||
return Collision.lineToCircle(this.line, source.circle).result;
|
||||
}
|
||||
|
||||
// Line vs. Rect
|
||||
if (this.type == CollisionMask.LINE && source.type == CollisionMask.RECTANGLE)
|
||||
{
|
||||
return Collision.lineSegmentToRectangle(this.line, source.rect).result;
|
||||
}
|
||||
|
||||
// Line vs. Point
|
||||
if (this.type == CollisionMask.LINE && source.type == CollisionMask.POINT)
|
||||
{
|
||||
return this.line.isPointOnLine(source.point.x, source.point.y);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public checkHullIntersection(mask: CollisionMask): bool {
|
||||
|
||||
if ((this.hullX + this.hullWidth > mask.hullX) && (this.hullX < mask.hullX + mask.width) && (this.hullY + this.hullHeight > mask.hullY) && (this.hullY < mask.hullY + mask.hullHeight))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get hullWidth(): number {
|
||||
|
||||
if (this.deltaX > 0)
|
||||
{
|
||||
return this.width + this.deltaX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.width - this.deltaX;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get hullHeight(): number {
|
||||
|
||||
if (this.deltaY > 0)
|
||||
{
|
||||
return this.height + this.deltaY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.height - this.deltaY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get hullX(): number {
|
||||
|
||||
if (this.x < this.last.x)
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.last.x;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get hullY(): number {
|
||||
|
||||
if (this.y < this.last.y)
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.last.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get deltaXAbs(): number {
|
||||
return (this.deltaX > 0 ? this.deltaX : -this.deltaX);
|
||||
}
|
||||
|
||||
public get deltaYAbs(): number {
|
||||
return (this.deltaY > 0 ? this.deltaY : -this.deltaY);
|
||||
}
|
||||
|
||||
public get deltaX(): number {
|
||||
return this.x - this.last.x;
|
||||
}
|
||||
|
||||
public get deltaY(): number {
|
||||
return this.y - this.last.y;
|
||||
}
|
||||
|
||||
public get x(): number {
|
||||
return this._ref.x;
|
||||
//return this.quad.x;
|
||||
}
|
||||
|
||||
public set x(value: number) {
|
||||
this._ref.x = value;
|
||||
//this.quad.x = value;
|
||||
}
|
||||
|
||||
public get y(): number {
|
||||
return this._ref.y;
|
||||
//return this.quad.y;
|
||||
}
|
||||
|
||||
public set y(value: number) {
|
||||
this._ref.y = value;
|
||||
//this.quad.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.quad.width = value;
|
||||
this._ref.width = value;
|
||||
}
|
||||
|
||||
public set height(value:number) {
|
||||
//this.quad.height = value;
|
||||
this._ref.height = value;
|
||||
}
|
||||
|
||||
public get width(): number {
|
||||
//return this.quad.width;
|
||||
return this._ref.width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
//return this.quad.height;
|
||||
return this._ref.height;
|
||||
}
|
||||
|
||||
public get left(): number {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public get right(): number {
|
||||
return this.x + this.width;
|
||||
}
|
||||
|
||||
public get top(): number {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public get bottom(): number {
|
||||
return this.y + this.height;
|
||||
}
|
||||
|
||||
public get halfWidth(): number {
|
||||
return this.width / 2;
|
||||
}
|
||||
|
||||
public get halfHeight(): number {
|
||||
return this.height / 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-49
@@ -1,49 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Device {
|
||||
constructor();
|
||||
public desktop: bool;
|
||||
public iOS: bool;
|
||||
public android: bool;
|
||||
public chromeOS: bool;
|
||||
public linux: bool;
|
||||
public macOS: bool;
|
||||
public windows: bool;
|
||||
public canvas: bool;
|
||||
public file: bool;
|
||||
public fileSystem: bool;
|
||||
public localStorage: bool;
|
||||
public webGL: bool;
|
||||
public worker: bool;
|
||||
public touch: bool;
|
||||
public css3D: bool;
|
||||
public arora: bool;
|
||||
public chrome: bool;
|
||||
public epiphany: bool;
|
||||
public firefox: bool;
|
||||
public ie: bool;
|
||||
public ieVersion: number;
|
||||
public mobileSafari: bool;
|
||||
public midori: bool;
|
||||
public opera: bool;
|
||||
public safari: bool;
|
||||
public webApp: bool;
|
||||
public audioData: bool;
|
||||
public webaudio: bool;
|
||||
public ogg: bool;
|
||||
public mp3: bool;
|
||||
public wav: bool;
|
||||
public m4a: bool;
|
||||
public iPhone: bool;
|
||||
public iPhone4: bool;
|
||||
public iPad: bool;
|
||||
public pixelRatio: number;
|
||||
private _checkOS();
|
||||
private _checkFeatures();
|
||||
private _checkBrowser();
|
||||
private _checkAudio();
|
||||
private _checkDevice();
|
||||
private _checkCSS3D();
|
||||
public getAll(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class LinkedList {
|
||||
constructor();
|
||||
public object: Basic;
|
||||
public next: LinkedList;
|
||||
public destroy(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-53
@@ -1,53 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="LinkedList.d.ts" />
|
||||
module Phaser {
|
||||
class QuadTree extends Rectangle {
|
||||
constructor(X: number, Y: number, Width: number, Height: number, Parent?: QuadTree);
|
||||
static A_LIST: number;
|
||||
static B_LIST: number;
|
||||
static divisions: number;
|
||||
private _canSubdivide;
|
||||
private _headA;
|
||||
private _tailA;
|
||||
private _headB;
|
||||
private _tailB;
|
||||
private static _min;
|
||||
private _northWestTree;
|
||||
private _northEastTree;
|
||||
private _southEastTree;
|
||||
private _southWestTree;
|
||||
private _leftEdge;
|
||||
private _rightEdge;
|
||||
private _topEdge;
|
||||
private _bottomEdge;
|
||||
private _halfWidth;
|
||||
private _halfHeight;
|
||||
private _midpointX;
|
||||
private _midpointY;
|
||||
private static _object;
|
||||
private static _objectLeftEdge;
|
||||
private static _objectTopEdge;
|
||||
private static _objectRightEdge;
|
||||
private static _objectBottomEdge;
|
||||
private static _list;
|
||||
private static _useBothLists;
|
||||
private static _processingCallback;
|
||||
private static _notifyCallback;
|
||||
private static _iterator;
|
||||
private static _objectHullX;
|
||||
private static _objectHullY;
|
||||
private static _objectHullWidth;
|
||||
private static _objectHullHeight;
|
||||
private static _checkObjectHullX;
|
||||
private static _checkObjectHullY;
|
||||
private static _checkObjectHullWidth;
|
||||
private static _checkObjectHullHeight;
|
||||
public destroy(): void;
|
||||
public load(ObjectOrGroup1: Basic, ObjectOrGroup2?: Basic, NotifyCallback?, ProcessCallback?): void;
|
||||
public add(ObjectOrGroup: Basic, List: number): void;
|
||||
private addObject();
|
||||
private addToList();
|
||||
public execute(): bool;
|
||||
private overlapNode();
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class RandomDataGenerator {
|
||||
constructor(seeds?: string[]);
|
||||
private s0;
|
||||
private s1;
|
||||
private s2;
|
||||
private c;
|
||||
private uint32();
|
||||
private fract32();
|
||||
private rnd();
|
||||
private hash(data);
|
||||
public sow(seeds?: string[]): void;
|
||||
public integer : number;
|
||||
public frac : number;
|
||||
public real : number;
|
||||
public integerInRange(min: number, max: number): number;
|
||||
public realInRange(min: number, max: number): number;
|
||||
public normal : number;
|
||||
public uuid : string;
|
||||
public pick(array);
|
||||
public weightedPick(array);
|
||||
public timestamp(min?: number, max?: number): number;
|
||||
public angle : number;
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class RequestAnimationFrame {
|
||||
constructor(callback, callbackContext);
|
||||
private _callback;
|
||||
private _callbackContext;
|
||||
public setCallback(callback): void;
|
||||
private _timeOutID;
|
||||
private _isSetTimeOut;
|
||||
public isUsingSetTimeOut(): bool;
|
||||
public isUsingRAF(): bool;
|
||||
public lastTime: number;
|
||||
public currentTime: number;
|
||||
public isRunning: bool;
|
||||
public start(callback?): void;
|
||||
public stop(): void;
|
||||
public RAFUpdate(): void;
|
||||
public SetTimeoutUpdate(): void;
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="../SoundManager.d.ts" />
|
||||
module Phaser {
|
||||
class Sound {
|
||||
constructor(context, gainNode, data, volume?: number, loop?: bool);
|
||||
private _context;
|
||||
private _gainNode;
|
||||
private _localGainNode;
|
||||
private _buffer;
|
||||
private _volume;
|
||||
private _sound;
|
||||
public loop: bool;
|
||||
public duration: number;
|
||||
public isPlaying: bool;
|
||||
public isDecoding: bool;
|
||||
public setDecodedBuffer(data): void;
|
||||
public play(): void;
|
||||
public stop(): void;
|
||||
public mute(): void;
|
||||
public unmute(): void;
|
||||
public volume : number;
|
||||
}
|
||||
}
|
||||
@@ -1,158 +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 {
|
||||
|
||||
/**
|
||||
* Sound constructor
|
||||
* @param context {object} The AudioContext instance.
|
||||
* @param gainNode {object} Gain node instance.
|
||||
* @param data {object} Sound data.
|
||||
* @param [volume] {number} volume of this sound when playing.
|
||||
* @param [loop] {boolean} loop this sound when playing? (Default to false)
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to AudioContext.
|
||||
*/
|
||||
private _context;
|
||||
/**
|
||||
* Reference to gain node of SoundManager.
|
||||
*/
|
||||
private _gainNode;
|
||||
/**
|
||||
* GainNode of this sound.
|
||||
*/
|
||||
private _localGainNode;
|
||||
/**
|
||||
* Decoded data buffer.
|
||||
*/
|
||||
private _buffer;
|
||||
/**
|
||||
* Volume of this sound.
|
||||
*/
|
||||
private _volume: number;
|
||||
/**
|
||||
* The real sound object (buffer source).
|
||||
*/
|
||||
private _sound;
|
||||
|
||||
loop: bool = false;
|
||||
duration: number;
|
||||
isPlaying: bool = false;
|
||||
isDecoding: bool = false;
|
||||
|
||||
public setDecodedBuffer(data) {
|
||||
|
||||
this._buffer = data;
|
||||
this.isDecoding = false;
|
||||
//this.play();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Play this sound.
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop playing this sound.
|
||||
*/
|
||||
public stop() {
|
||||
|
||||
if (this.isPlaying === true)
|
||||
{
|
||||
this.isPlaying = false;
|
||||
|
||||
this._sound.noteOff(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mute the sound.
|
||||
*/
|
||||
public mute() {
|
||||
|
||||
this._localGainNode.gain.value = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the sound.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class StageScaleMode {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _startHeight;
|
||||
private _iterations;
|
||||
private _check;
|
||||
static EXACT_FIT: number;
|
||||
static NO_SCALE: number;
|
||||
static SHOW_ALL: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public orientation;
|
||||
public update(): void;
|
||||
public isLandscape : bool;
|
||||
private checkOrientation(event);
|
||||
private refresh();
|
||||
private setScreenSize();
|
||||
}
|
||||
}
|
||||
@@ -1,366 +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.
|
||||
* The resizing method is based on a technique taken from Viewporter v2.0 by Zynga Inc. http://github.com/zynga/viewporter
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class StageScaleMode {
|
||||
|
||||
/**
|
||||
* StageScaleMode constructor
|
||||
*/
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
|
||||
this.enterLandscape = new Phaser.Signal();
|
||||
this.enterPortrait = new Phaser.Signal();
|
||||
|
||||
if (window['orientation'])
|
||||
{
|
||||
this.orientation = window['orientation'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (window.outerWidth > window.outerHeight)
|
||||
{
|
||||
this.orientation = 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.orientation = 0;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('orientationchange', (event) => this.checkOrientation(event), false);
|
||||
window.addEventListener('resize', (event) => this.checkResize(event), false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Game;
|
||||
|
||||
/**
|
||||
* Stage height when start the game.
|
||||
* @type {number}
|
||||
*/
|
||||
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.
|
||||
* @type {number}
|
||||
*/
|
||||
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.
|
||||
* @type {number}
|
||||
*/
|
||||
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.
|
||||
* @type {number}
|
||||
*/
|
||||
public static SHOW_ALL: number = 2;
|
||||
|
||||
/**
|
||||
* Minimum width the canvas should be scaled to (in pixels)
|
||||
* @type {number}
|
||||
*/
|
||||
public minWidth: number = null;
|
||||
|
||||
/**
|
||||
* Maximum width the canvas should be scaled to (in pixels).
|
||||
* If null it will scale to whatever width the browser can handle.
|
||||
* @type {number}
|
||||
*/
|
||||
public maxWidth: number = null;
|
||||
|
||||
/**
|
||||
* Minimum height the canvas should be scaled to (in pixels)
|
||||
* @type {number}
|
||||
*/
|
||||
public minHeight: number = null;
|
||||
|
||||
/**
|
||||
* Maximum height the canvas should be scaled to (in pixels).
|
||||
* If null it will scale to whatever height the browser can handle.
|
||||
* @type {number}
|
||||
*/
|
||||
public maxHeight: number = null;
|
||||
|
||||
/**
|
||||
* Width of the stage after calculation.
|
||||
* @type {number}
|
||||
*/
|
||||
public width: number = 0;
|
||||
|
||||
/**
|
||||
* Height of the stage after calculation.
|
||||
* @type {number}
|
||||
*/
|
||||
public height: number = 0;
|
||||
|
||||
/**
|
||||
* Window orientation angle (90 and -90 are landscape, 0 is portrait)
|
||||
* @type {number}
|
||||
*/
|
||||
public orientation: number;
|
||||
|
||||
/**
|
||||
* A Signal that is dispatched when the device enters landscape mode from portrait
|
||||
* @type {Signal}
|
||||
*/
|
||||
public enterLandscape: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* A Signal that is dispatched when the device enters portrait mode from landscape
|
||||
* @type {Signal}
|
||||
*/
|
||||
public enterPortrait: Phaser.Signal;
|
||||
|
||||
public get isFullScreen(): bool {
|
||||
|
||||
if (document['fullscreenElement'] === null|| document['mozFullScreenElement'] === null|| document['webkitFullscreenElement'] === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public startFullScreen() {
|
||||
|
||||
if (this.isFullScreen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var element = this._game.stage.canvas;
|
||||
|
||||
if (element['requestFullScreen'])
|
||||
{
|
||||
element['requestFullScreen']();
|
||||
}
|
||||
else if(element['mozRequestFullScreen'])
|
||||
{
|
||||
element['mozRequestFullScreen']();
|
||||
}
|
||||
else if (element['webkitRequestFullScreen'])
|
||||
{
|
||||
element['webkitRequestFullScreen']();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public stopFullScreen() {
|
||||
|
||||
if (document['cancelFullScreen'])
|
||||
{
|
||||
document['cancelFullScreen']();
|
||||
}
|
||||
else if (document['mozCancelFullScreen'])
|
||||
{
|
||||
document['mozCancelFullScreen']();
|
||||
}
|
||||
else if (document['webkitCancelFullScreen'])
|
||||
{
|
||||
document['webkitCancelFullScreen']();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The core update loop, called by Phaser.Stage
|
||||
*/
|
||||
public update() {
|
||||
|
||||
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
|
||||
{
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get isPortrait(): bool {
|
||||
return this.orientation == 0;
|
||||
}
|
||||
|
||||
public get isLandscape(): bool {
|
||||
return this.orientation === 90 || this.orientation === -90;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle window.orientationchange events
|
||||
*/
|
||||
private checkOrientation(event) {
|
||||
|
||||
this.orientation = window['orientation'];
|
||||
|
||||
if (this.isLandscape)
|
||||
{
|
||||
this.enterLandscape.dispatch(this.orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enterPortrait.dispatch(this.orientation);
|
||||
}
|
||||
|
||||
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE)
|
||||
{
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle window.resize events
|
||||
*/
|
||||
private checkResize(event) {
|
||||
|
||||
if (window.outerWidth > window.outerHeight)
|
||||
{
|
||||
this.orientation = 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.orientation = 0;
|
||||
}
|
||||
|
||||
if (this.isLandscape)
|
||||
{
|
||||
this.enterLandscape.dispatch(this.orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enterPortrait.dispatch(this.orientation);
|
||||
}
|
||||
|
||||
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE)
|
||||
{
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-calculate scale mode and update screen size.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set screen size automatically based on the scaleMode.
|
||||
*/
|
||||
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.maxWidth && window.innerWidth > this.maxWidth)
|
||||
{
|
||||
this.width = this.maxWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.width = window.innerWidth;
|
||||
}
|
||||
|
||||
if (this.maxHeight && window.innerHeight > this.maxHeight)
|
||||
{
|
||||
this.height = this.maxHeight;
|
||||
}
|
||||
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.maxWidth && this.width > this.maxWidth)
|
||||
{
|
||||
this.width = this.maxWidth;
|
||||
}
|
||||
|
||||
if (this.maxHeight && this.height > this.maxHeight)
|
||||
{
|
||||
this.height = this.maxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Tile {
|
||||
constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number);
|
||||
private _game;
|
||||
public name: string;
|
||||
public mass: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public allowCollisions: number;
|
||||
public collideLeft: bool;
|
||||
public collideRight: bool;
|
||||
public collideUp: bool;
|
||||
public collideDown: bool;
|
||||
public tilemap: Tilemap;
|
||||
public index: number;
|
||||
public destroy(): void;
|
||||
public setCollision(collision: number, resetCollisions: bool): void;
|
||||
public resetCollision(): void;
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
Vendored
-51
@@ -1,51 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
module Phaser {
|
||||
class TilemapLayer {
|
||||
constructor(game: Game, parent: Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number);
|
||||
private _game;
|
||||
private _parent;
|
||||
private _texture;
|
||||
private _tileOffsets;
|
||||
private _startX;
|
||||
private _startY;
|
||||
private _maxX;
|
||||
private _maxY;
|
||||
private _tx;
|
||||
private _ty;
|
||||
private _dx;
|
||||
private _dy;
|
||||
private _oldCameraX;
|
||||
private _oldCameraY;
|
||||
private _columnData;
|
||||
private _tempTileX;
|
||||
private _tempTileY;
|
||||
private _tempTileW;
|
||||
private _tempTileH;
|
||||
public name: string;
|
||||
public alpha: number;
|
||||
public exists: bool;
|
||||
public visible: bool;
|
||||
public orientation: string;
|
||||
public properties: {};
|
||||
public mapData;
|
||||
public mapFormat: number;
|
||||
public boundsInTiles: Rectangle;
|
||||
public tileWidth: number;
|
||||
public tileHeight: number;
|
||||
public widthInTiles: number;
|
||||
public heightInTiles: number;
|
||||
public widthInPixels: number;
|
||||
public heightInPixels: number;
|
||||
public tileMargin: number;
|
||||
public tileSpacing: number;
|
||||
public getTileFromWorldXY(x: number, y: number): number;
|
||||
public getTileOverlaps(object: GameObject): bool;
|
||||
public getTileBlock(x: number, y: number, width: number, height: number): any[];
|
||||
public getTileIndex(x: number, y: number): number;
|
||||
public addColumn(column): void;
|
||||
public updateBounds(): void;
|
||||
public parseTileOffsets(): number;
|
||||
public renderDebugInfo(x: number, y: number, color?: string): void;
|
||||
public render(camera: Camera, dx, dy): bool;
|
||||
}
|
||||
}
|
||||
Vendored
-42
@@ -1,42 +0,0 @@
|
||||
/// <reference path="../Game.d.ts" />
|
||||
/// <reference path="easing/Back.d.ts" />
|
||||
/// <reference path="easing/Bounce.d.ts" />
|
||||
/// <reference path="easing/Circular.d.ts" />
|
||||
/// <reference path="easing/Cubic.d.ts" />
|
||||
/// <reference path="easing/Elastic.d.ts" />
|
||||
/// <reference path="easing/Exponential.d.ts" />
|
||||
/// <reference path="easing/Linear.d.ts" />
|
||||
/// <reference path="easing/Quadratic.d.ts" />
|
||||
/// <reference path="easing/Quartic.d.ts" />
|
||||
/// <reference path="easing/Quintic.d.ts" />
|
||||
/// <reference path="easing/Sinusoidal.d.ts" />
|
||||
module Phaser {
|
||||
class Tween {
|
||||
constructor(object, game: Game);
|
||||
private _game;
|
||||
private _manager;
|
||||
private _object;
|
||||
private _pausedTime;
|
||||
private _valuesStart;
|
||||
private _valuesEnd;
|
||||
private _duration;
|
||||
private _delayTime;
|
||||
private _startTime;
|
||||
private _easingFunction;
|
||||
private _interpolationFunction;
|
||||
private _chainedTweens;
|
||||
public onStart: Signal;
|
||||
public onUpdate: Signal;
|
||||
public onComplete: Signal;
|
||||
public to(properties, duration?: number, ease?: any, autoStart?: bool): Tween;
|
||||
public start(): Tween;
|
||||
public stop(): Tween;
|
||||
public parent : Game;
|
||||
public delay : number;
|
||||
public easing : any;
|
||||
public interpolation : any;
|
||||
public chain(tween: Tween): Tween;
|
||||
public debugValue;
|
||||
public update(time): bool;
|
||||
}
|
||||
}
|
||||
@@ -1,330 +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 {
|
||||
|
||||
/**
|
||||
* Tween constructor
|
||||
* Create a new <code>Tween</code>.
|
||||
*
|
||||
* @param object {object} Target object will be affected by this tween.
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
*/
|
||||
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._chainedTweens = [];
|
||||
this.onStart = new Phaser.Signal();
|
||||
this.onUpdate = new Phaser.Signal();
|
||||
this.onComplete = new Phaser.Signal();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Local private reference to game.
|
||||
*/
|
||||
private _game: Phaser.Game;
|
||||
|
||||
/**
|
||||
* Manager of this tween.
|
||||
* @type {Phaser.TweenManager}
|
||||
*/
|
||||
private _manager: Phaser.TweenManager;
|
||||
|
||||
/**
|
||||
* Reference to the target object.
|
||||
* @type {object}
|
||||
*/
|
||||
private _object = null;
|
||||
private _pausedTime: number = 0;
|
||||
|
||||
/**
|
||||
* Start values container.
|
||||
* @type {object}
|
||||
*/
|
||||
private _valuesStart = {};
|
||||
|
||||
/**
|
||||
* End values container.
|
||||
* @type {object}
|
||||
*/
|
||||
private _valuesEnd = {};
|
||||
|
||||
/**
|
||||
* How long this tween will perform.
|
||||
* @type {number}
|
||||
*/
|
||||
private _duration = 1000;
|
||||
private _delayTime = 0;
|
||||
private _startTime = null;
|
||||
|
||||
/**
|
||||
* Easing function which actually updating this tween.
|
||||
* @type {function}
|
||||
*/
|
||||
private _easingFunction;
|
||||
private _interpolationFunction;
|
||||
|
||||
/**
|
||||
* Contains chained tweens.
|
||||
* @type {Tweens[]}
|
||||
*/
|
||||
private _chainedTweens = [];
|
||||
|
||||
/**
|
||||
* Signal to be dispatched when this tween start.
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onStart: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* Signal to be dispatched when this tween updating.
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onUpdate: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* Signal to be dispatched when this tween completed.
|
||||
* @type {Phaser.Signal}
|
||||
*/
|
||||
public onComplete: Phaser.Signal;
|
||||
|
||||
/**
|
||||
* Configure the Tween
|
||||
* @param properties {object} Propertis you want to tween.
|
||||
* @param [duration] {number} duration of this tween.
|
||||
* @param [ease] {any} Easing function.
|
||||
* @param [autoStart] {boolean} Whether this tween will start automatically or not.
|
||||
* @param [delay] {number} delay before this tween will start, defaults to 0 (no delay)
|
||||
* @return {Tween} Itself.
|
||||
*/
|
||||
public to(properties, duration?: number = 1000, ease?: any = null, autoStart?: bool = false, delay?:number = 0) {
|
||||
|
||||
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 (delay > 0)
|
||||
{
|
||||
this._delayTime = delay;
|
||||
}
|
||||
|
||||
if (autoStart === true)
|
||||
{
|
||||
return this.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Start to tween.
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop tweening.
|
||||
*/
|
||||
public stop() {
|
||||
|
||||
if (this._manager !== null)
|
||||
{
|
||||
this._manager.remove(this);
|
||||
}
|
||||
|
||||
this.onComplete.dispose();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another chained tween, which will start automatically when the one before it completes.
|
||||
* @param tween {Phaser.Tween} Tween object you want to chain with this.
|
||||
* @return {Phaser.Tween} Itselfe.
|
||||
*/
|
||||
public chain(tween:Phaser.Tween) {
|
||||
|
||||
this._chainedTweens.push(tween);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug value?
|
||||
*/
|
||||
public debugValue;
|
||||
|
||||
/**
|
||||
* Update tweening.
|
||||
* @param time {number} Current time from game clock.
|
||||
* @return {boolean} Return false if this completed and no need to update, otherwise return true.
|
||||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Animation {
|
||||
constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool);
|
||||
private _game;
|
||||
private _parent;
|
||||
private _frames;
|
||||
private _frameData;
|
||||
private _frameIndex;
|
||||
private _timeLastFrame;
|
||||
private _timeNextFrame;
|
||||
public name: string;
|
||||
public currentFrame: Frame;
|
||||
public isFinished: bool;
|
||||
public isPlaying: bool;
|
||||
public looped: bool;
|
||||
public delay: number;
|
||||
public frameTotal : number;
|
||||
public frame : number;
|
||||
public play(frameRate?: number, loop?: bool): void;
|
||||
public restart(): void;
|
||||
public stop(): void;
|
||||
public update(): bool;
|
||||
public destroy(): void;
|
||||
private onComplete();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser {
|
||||
class AnimationLoader {
|
||||
static parseSpriteSheet(game: Game, key: string, frameWidth: number, frameHeight: number, frameMax: number): FrameData;
|
||||
static parseJSONData(game: Game, json): FrameData;
|
||||
}
|
||||
}
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser {
|
||||
class Frame {
|
||||
constructor(x: number, y: number, width: number, height: number, name: string);
|
||||
public x: number;
|
||||
public y: number;
|
||||
public width: number;
|
||||
public height: number;
|
||||
public index: number;
|
||||
public name: string;
|
||||
public rotated: bool;
|
||||
public rotationDirection: string;
|
||||
public trimmed: bool;
|
||||
public sourceSizeW: number;
|
||||
public sourceSizeH: number;
|
||||
public spriteSourceSizeX: number;
|
||||
public spriteSourceSizeY: number;
|
||||
public spriteSourceSizeW: number;
|
||||
public spriteSourceSizeH: number;
|
||||
public setRotation(rotated: bool, rotationDirection: string): void;
|
||||
public setTrim(trimmed: bool, actualWidth, actualHeight, destX, destY, destWidth, destHeight): void;
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser {
|
||||
class FrameData {
|
||||
constructor();
|
||||
private _frames;
|
||||
private _frameNames;
|
||||
public total : number;
|
||||
public addFrame(frame: Frame): Frame;
|
||||
public getFrame(index: number): Frame;
|
||||
public getFrameByName(name: string): Frame;
|
||||
public checkFrameName(name: string): bool;
|
||||
public getFrameRange(start: number, end: number, output?: Frame[]): Frame[];
|
||||
public getFrameIndexes(output?: number[]): number[];
|
||||
public getFrameIndexesByName(input: string[]): number[];
|
||||
public getAllFrames(): Frame[];
|
||||
public getFrames(range: number[]): Frame[];
|
||||
}
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser.Easing {
|
||||
class Back {
|
||||
static In(k): number;
|
||||
static Out(k): number;
|
||||
static InOut(k): number;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser.Easing {
|
||||
class Bounce {
|
||||
static In(k): number;
|
||||
static Out(k): number;
|
||||
static InOut(k): number;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser.Easing {
|
||||
class Circular {
|
||||
static In(k): number;
|
||||
static Out(k): number;
|
||||
static InOut(k): number;
|
||||
}
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser.Easing {
|
||||
class Cubic {
|
||||
static In(k): number;
|
||||
static Out(k): number;
|
||||
static InOut(k): number;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser.Easing {
|
||||
class Elastic {
|
||||
static In(k): number;
|
||||
static Out(k): number;
|
||||
static InOut(k): number;
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/// <reference path="../../Game.d.ts" />
|
||||
module Phaser.Easing {
|
||||
class Exponential {
|
||||
static In(k): number;
|
||||
static Out(k): number;
|
||||
static InOut(k): number;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user