Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f0c764b63 | ||
|
|
375da5db14 | ||
|
|
159426c6fa | ||
|
|
a25f6dbc3b | ||
|
|
0ed1aedba7 | ||
|
|
bf8ee44d13 | ||
|
|
de3583db80 | ||
|
|
88f901249a | ||
|
|
f4ff4d88fe | ||
|
|
37323562cd | ||
|
|
f6cc40f025 | ||
|
|
529d210006 | ||
|
|
7b572b9b81 | ||
|
|
43bc0e72f1 | ||
|
|
ad0e53abb9 | ||
|
|
6dca66c501 | ||
|
|
0fbbb887fc | ||
|
|
f9a63a9d2e | ||
|
|
92edaf76ef | ||
|
|
4c48e88fc1 | ||
|
|
59a4e80dc1 | ||
|
|
310eb0a69e | ||
|
|
d5e45c22e9 | ||
|
|
b9deb43c88 | ||
|
|
e95ec9fdbc | ||
|
|
936092cba1 | ||
|
|
0727541e05 | ||
|
|
3c6bee8dda | ||
|
|
6d418ba9c7 | ||
|
|
4b3d282f67 | ||
|
|
232d022aaa | ||
|
|
26415094b6 | ||
|
|
e396b56686 | ||
|
|
47f98ac2bc | ||
|
|
d964ef7d0a | ||
|
|
7db37bf5d5 | ||
|
|
a97357b34e | ||
|
|
e8559fb735 | ||
|
|
58d203619a | ||
|
|
16dc2c1597 | ||
|
|
c57071bd98 | ||
|
|
1f93b62055 | ||
|
|
947985c5b1 | ||
|
|
690bd3e9e2 | ||
|
|
3df4746e8a | ||
|
|
34e5ee3eb8 | ||
|
|
819380d001 | ||
|
|
26459602aa | ||
|
|
79007bc142 | ||
|
|
0641170aab | ||
|
|
d9323de752 | ||
|
|
1d633a55f0 | ||
|
|
3c631768f2 | ||
|
|
59ea6746db | ||
|
|
2a65488eec | ||
|
|
cf3b9ae187 | ||
|
|
10252543f2 | ||
|
|
62da24a7fc | ||
|
|
b0f4ac3bcc | ||
|
|
e9ab2d30b6 | ||
|
|
27bca6a8c2 | ||
|
|
8628c5b2f3 | ||
|
|
e11cae5373 | ||
|
|
c0032e7a58 | ||
|
|
9e5e30bb12 | ||
|
|
03cde81b48 | ||
|
|
b7bb52696f | ||
|
|
df2a048594 | ||
|
|
68d5c73fea | ||
|
|
eddce653e9 | ||
|
|
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 | ||
|
|
3236ea6b24 | ||
|
|
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 |
@@ -1,6 +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
|
||||
Phaser.sublime-workspace
|
||||
*.suo
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
# Vendors
|
||||
node_modules/
|
||||
|
||||
# Build
|
||||
dist/
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"globals" : { "Phaser": false, "PIXI": false },
|
||||
// Ignore Environment Globals
|
||||
"browser" : true, // Standard browser globals e.g. `window`, `document`.
|
||||
"couch" : false,
|
||||
"dojo" : false,
|
||||
"jquery" : true,
|
||||
"mootools" : false,
|
||||
"node" : false,
|
||||
"nonstandard" : false,
|
||||
"phantom" : false,
|
||||
"prototypejs" : false,
|
||||
"rhino" : false,
|
||||
"worker" : false,
|
||||
"wsh" : true, // Windows Scripting Host.
|
||||
"yui" : false,
|
||||
|
||||
// Development
|
||||
"debug" : true, // Allow debugger statements e.g. browser breakpoints.
|
||||
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
||||
|
||||
// ECMAScript Support
|
||||
"es3" : true, // Support legacy browser and javascript environments.
|
||||
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
|
||||
"strict" : false, // Require `use strict` pragma in every file.
|
||||
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
|
||||
|
||||
// Functionality
|
||||
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
|
||||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
||||
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
|
||||
"curly" : true, // Require {} for every new block or scope.
|
||||
"eqeqeq" : false, // Require triple equals i.e. `===`.
|
||||
"eqnull" : true, // Tolerate use of `== null`.
|
||||
"evil" : false, // Tolerate use of `eval`.
|
||||
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
||||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
|
||||
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
|
||||
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
|
||||
"immed" : false, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||
"iterator" : true, // This option suppresses warnings about the __iterator__ property.
|
||||
"lastsemic" : true, // This option suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block.
|
||||
"latedef" : false, // Prohipit variable use before definition.
|
||||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
||||
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
|
||||
"loopfunc" : true, // Allow functions to be defined within loops.
|
||||
// "maxcomplexity" : 10, // This option lets you control cyclomatic complexity throughout your code.
|
||||
// "maxdepth" : 2, // This option lets you control how nested do you want your blocks to be.
|
||||
// "maxlen" : 80, // This option lets you set the maximum length of a line.
|
||||
// "maxparams" : 5, // This option lets you set the max number of formal parameters allowed per function.
|
||||
// "maxstatements" : 25, // This option lets you set the max number of statements allowed per function.This option lets you set the max number of formal parameters allowed per function.
|
||||
"moz" : false, // This options tells JSHint that your code uses Mozilla JavaScript extensions.
|
||||
"multistr" : true, // This option suppresses warnings about multi-line strings.
|
||||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
|
||||
"proto" : true, // This option suppresses warnings about the __proto__ property.
|
||||
"scripturl" : true, // Tolerate script-targeted URLs.
|
||||
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
||||
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
|
||||
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
||||
"undef" : true, // Require all non-global variables be declared before they are used.
|
||||
"unused" : true, // This option warns when you define and never use your variables.
|
||||
"validthis" : true, // This option suppresses warnings about possible strict violations when the code is running in strict mode and you use this in a non-constructor function.
|
||||
|
||||
// Styling
|
||||
"indent" : 4, // Specify indentation spacing
|
||||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||
"noempty" : true, // Prohibit use of empty blocks.
|
||||
"nonew" : true, // Prohibit use of constructors for side-effects.
|
||||
"plusplus" : false, // Prohibit use of `++` & `--`.
|
||||
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
|
||||
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
||||
"trailing" : true // Prohibit trailing whitespaces.
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#How to contribute
|
||||
|
||||
It's important to us that you feel you can contribute towards the evolution of Phaser. This can take many forms: from helping to fix bugs or improve the docs, to adding in new features to the source. This guide should help you in making that process as smooth as possible.
|
||||
|
||||
|
||||
##Reporting issues
|
||||
|
||||
[GitHub Issues][0] is the place to report bugs you may have found in either the core library or any of the examples that are part of the repository. When submitting a bug please do the following:
|
||||
|
||||
1. **Search for existing issues.** Your bug may have already been fixed or addressed in a development branch version of Phaser, so be sure to search the issues first before putting in a duplicate issue.
|
||||
|
||||
2. **Create an isolated and reproducible test case.** If you are reporting a bug, make sure you also have a minimal, runnable, code example that reproduces the problem you have.
|
||||
|
||||
3. **Include a live example.** After narrowing your code down to only the problem areas, make use of[jsFiddle][1], [jsBin][2], or a link to your live site so that we can view a live example of the problem.
|
||||
|
||||
4. **Share as much information as possible.** Include browser version affected, your OS, version of the library, steps to reproduce, etc. "X isn't working!!!1!" will probably just be closed.
|
||||
|
||||
|
||||
##Pixi and Phaser
|
||||
|
||||
It's important to understand that internally Phaser uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) for all rendering. It's possible you may find a bug that is generated on the Pixi level rather than Phaser. You're welcome to still report the issue of course, but if you get a reply saying we think it might be a Pixi issue this is what we're talking about :)
|
||||
|
||||
|
||||
##Support Forum
|
||||
|
||||
We have a very active [Phaser Support Forum](http://www.html5gamedevs.com/forum/14-phaser/). If you need general support, or are struggling to understand how to do something or need your code checked over, then we would urge you to post it to our forum. There are a lot of friendly devs in there who can help, as well as the core Phaser and Pixi teams, so it's a great place to get support from. You're welcome to report bugs directly on GitHub, but for general support we'd always recommend using the forum first.
|
||||
|
||||
|
||||
##Dev vs. Master
|
||||
|
||||
The dev branch of Phaser is our 'current working' version. It is always ahead of the master branch in terms of features and fixes. However it's also bleeding-edge and experimental and we cannot and do not guarantee it will compile or work for you. Very often we have to break things for a few days while we rebuild and patch. So by all means please export the dev branch and contribute towards it, indeed that is where all Pull Requests should be sent, but do so understanding the API may change beneath you.
|
||||
|
||||
|
||||
##Making Changes
|
||||
|
||||
To take advantage of our grunt build script and jshint config it will be easiest for you if you have node.js and grunt installed locally.
|
||||
|
||||
You can download node.js from[nodejs.org][3]. After it has been installed open a console and run `npm i - g grunt - cli` to install the global `grunt` executable.
|
||||
|
||||
After that you can clone the repository and run `npm i` inside the cloned folder. This will install dependencies necessary for building the project. Once that is ready,
|
||||
make your changes and submit a Pull Request:
|
||||
|
||||
- **Send Pull Requests to the `dev` branch.** All Pull Requests must be sent to the `dev` branch, `master` is the latest release and PRs to that branch will be closed.
|
||||
|
||||
- **Ensure changes are jshint validated.** Our JSHint configuration file is provided in the repository and you should check against it before submitting.
|
||||
|
||||
- **Never commit new builds.** When making a code change you should always run `grunt` which will rebuild the project so you can test, *however* please do not commit these new builds or your PR will be closed. Builds by default are placed in the `dist` folder, to keep them separate from the `build` folder releases.
|
||||
|
||||
- **Only commit relevant changes.** Don't include changes that are not directly relevant to the fix you are making. The more focused a PR is, the faster it will get attention and be merged. Extra files changing only whitespace or trash files will likely get your PR closed.
|
||||
|
||||
|
||||
##I don't really like git / node.js, but I can fix this bug
|
||||
|
||||
That is fine too. While Pull Requests are the best thing in the world for us, they are not the only way to help. You're welcome to post fixes to our forum or even just email them to us. All we ask is that you still adhere to the guidelines presented here re: JSHint, etc.
|
||||
|
||||
|
||||
##Code Style Guide
|
||||
|
||||
- Use 4 spaces for tabs, never tab characters.
|
||||
|
||||
- No trailing whitespace, blank lines should have no whitespace.
|
||||
|
||||
- Always favor strict equals` === `unless you * need * to use type coercion.
|
||||
|
||||
- Follow conventions already in the code, and listen to jshint. Our config is set-up for a reason.
|
||||
|
||||
Thanks to Chad for creating the original Pixi.js Contributing file which we adapted for Phaser.
|
||||
|
||||
[0]: https://github.com/photonstorm/phaser/issues
|
||||
[1]: http://jsfiddle.net
|
||||
[2]: http://jsbin.com/
|
||||
[3]: http://nodejs.org
|
||||
@@ -1,16 +0,0 @@
|
||||
YUI.add("yuidoc-meta", function(Y) {
|
||||
Y.YUIDoc = { meta: {
|
||||
"classes": [
|
||||
"TimeManager"
|
||||
],
|
||||
"modules": [
|
||||
"Phaser"
|
||||
],
|
||||
"allModules": [
|
||||
{
|
||||
"displayName": "Phaser",
|
||||
"name": "Phaser"
|
||||
}
|
||||
]
|
||||
} };
|
||||
});
|
||||
|
Before Width: | Height: | Size: 491 B |
|
Before Width: | Height: | Size: 6.2 KiB |
@@ -1,783 +0,0 @@
|
||||
/*
|
||||
Font sizes for all selectors other than the body are given in percentages,
|
||||
with 100% equal to 13px. To calculate a font size percentage, multiply the
|
||||
desired size in pixels by 7.6923076923.
|
||||
|
||||
Here's a quick lookup table:
|
||||
|
||||
10px - 76.923%
|
||||
11px - 84.615%
|
||||
12px - 92.308%
|
||||
13px - 100%
|
||||
14px - 107.692%
|
||||
15px - 115.385%
|
||||
16px - 123.077%
|
||||
17px - 130.769%
|
||||
18px - 138.462%
|
||||
19px - 146.154%
|
||||
20px - 153.846%
|
||||
*/
|
||||
|
||||
html {
|
||||
background: #fff;
|
||||
color: #333;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
body {
|
||||
/*font: 13px/1.4 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', 'Bitstream Vera Sans', 'Helvetica', 'Arial', sans-serif;*/
|
||||
font: 13px/1.4 'Helvetica', 'Arial', sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* -- Links ----------------------------------------------------------------- */
|
||||
a {
|
||||
color: #356de4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
a:hover { text-decoration: underline; }
|
||||
|
||||
/* "Jump to Table of Contents" link is shown to assistive tools, but hidden from
|
||||
sight until it's focused. */
|
||||
.jump {
|
||||
position: absolute;
|
||||
padding: 3px 6px;
|
||||
left: -99999px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.jump:focus { left: 40%; }
|
||||
|
||||
/* -- Paragraphs ------------------------------------------------------------ */
|
||||
p { margin: 1.3em 0; }
|
||||
dd p, td p { margin-bottom: 0; }
|
||||
dd p:first-child, td p:first-child { margin-top: 0; }
|
||||
|
||||
/* -- Headings -------------------------------------------------------------- */
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #D98527;/*was #f80*/
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
font-weight: bold;
|
||||
line-height: 1.1;
|
||||
margin: 1.1em 0 0.5em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 184.6%;
|
||||
color: #30418C;
|
||||
margin: 0.75em 0 0.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 153.846%;
|
||||
color: #E48A2B;
|
||||
}
|
||||
|
||||
h3 { font-size: 138.462%; }
|
||||
|
||||
h4 {
|
||||
border-bottom: 1px solid #DBDFEA;
|
||||
color: #E48A2B;
|
||||
font-size: 115.385%;
|
||||
font-weight: normal;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
h5, h6 { font-size: 107.692%; }
|
||||
|
||||
/* -- Code and examples ----------------------------------------------------- */
|
||||
code, kbd, pre, samp {
|
||||
font-family: Menlo, Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace;
|
||||
font-size: 92.308%;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
p code, p kbd, p samp {
|
||||
background: #FCFBFA;
|
||||
border: 1px solid #EFEEED;
|
||||
padding: 0 3px;
|
||||
}
|
||||
|
||||
a code, a kbd, a samp,
|
||||
pre code, pre kbd, pre samp,
|
||||
table code, table kbd, table samp,
|
||||
.intro code, .intro kbd, .intro samp,
|
||||
.toc code, .toc kbd, .toc samp {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
pre.code, pre.terminal, pre.cmd {
|
||||
overflow-x: auto;
|
||||
*overflow-x: scroll;
|
||||
padding: 0.3em 0.6em;
|
||||
}
|
||||
|
||||
pre.code {
|
||||
background: #FCFBFA;
|
||||
border: 1px solid #EFEEED;
|
||||
border-left-width: 5px;
|
||||
}
|
||||
|
||||
pre.terminal, pre.cmd {
|
||||
background: #F0EFFC;
|
||||
border: 1px solid #D0CBFB;
|
||||
border-left: 5px solid #D0CBFB;
|
||||
}
|
||||
|
||||
/* Don't reduce the font size of <code>/<kbd>/<samp> elements inside <pre>
|
||||
blocks. */
|
||||
pre code, pre kbd, pre samp { font-size: 100%; }
|
||||
|
||||
/* Used to denote text that shouldn't be selectable, such as line numbers or
|
||||
shell prompts. Guess which browser this doesn't work in. */
|
||||
.noselect {
|
||||
-moz-user-select: -moz-none;
|
||||
-khtml-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* -- Lists ----------------------------------------------------------------- */
|
||||
dd { margin: 0.2em 0 0.7em 1em; }
|
||||
dl { margin: 1em 0; }
|
||||
dt { font-weight: bold; }
|
||||
|
||||
/* -- Tables ---------------------------------------------------------------- */
|
||||
caption, th { text-align: left; }
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td, th {
|
||||
border: 1px solid #fff;
|
||||
padding: 5px 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
td { background: #E6E9F5; }
|
||||
td dl { margin: 0; }
|
||||
td dl dl { margin: 1em 0; }
|
||||
td pre:first-child { margin-top: 0; }
|
||||
|
||||
th {
|
||||
background: #D2D7E6;/*#97A0BF*/
|
||||
border-bottom: none;
|
||||
border-top: none;
|
||||
color: #000;/*#FFF1D5*/
|
||||
font-family: 'Trebuchet MS', sans-serif;
|
||||
font-weight: bold;
|
||||
line-height: 1.3;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
/* -- Layout and Content ---------------------------------------------------- */
|
||||
#doc {
|
||||
margin: auto;
|
||||
min-width: 1024px;
|
||||
}
|
||||
|
||||
.content { padding: 0 20px 0 25px; }
|
||||
|
||||
.sidebar {
|
||||
padding: 0 15px 0 10px;
|
||||
}
|
||||
#bd {
|
||||
padding: 7px 0 130px;
|
||||
position: relative;
|
||||
width: 99%;
|
||||
}
|
||||
|
||||
/* -- Table of Contents ----------------------------------------------------- */
|
||||
|
||||
/* The #toc id refers to the single global table of contents, while the .toc
|
||||
class refers to generic TOC lists that could be used throughout the page. */
|
||||
|
||||
.toc code, .toc kbd, .toc samp { font-size: 100%; }
|
||||
.toc li { font-weight: bold; }
|
||||
.toc li li { font-weight: normal; }
|
||||
|
||||
/* -- Intro and Example Boxes ----------------------------------------------- */
|
||||
/*
|
||||
.intro, .example { margin-bottom: 2em; }
|
||||
.example {
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
-moz-box-shadow: 0 0 5px #bfbfbf;
|
||||
-webkit-box-shadow: 0 0 5px #bfbfbf;
|
||||
box-shadow: 0 0 5px #bfbfbf;
|
||||
padding: 1em;
|
||||
}
|
||||
.intro {
|
||||
background: none repeat scroll 0 0 #F0F1F8; border: 1px solid #D4D8EB; padding: 0 1em;
|
||||
}
|
||||
*/
|
||||
|
||||
/* -- Other Styles ---------------------------------------------------------- */
|
||||
|
||||
/* These are probably YUI-specific, and should be moved out of Selleck's default
|
||||
theme. */
|
||||
|
||||
.button {
|
||||
border: 1px solid #dadada;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
color: #444;
|
||||
display: inline-block;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size: 92.308%;
|
||||
font-weight: bold;
|
||||
padding: 4px 13px 3px;
|
||||
-moz-text-shadow: 1px 1px 0 #fff;
|
||||
-webkit-text-shadow: 1px 1px 0 #fff;
|
||||
text-shadow: 1px 1px 0 #fff;
|
||||
white-space: nowrap;
|
||||
|
||||
background: #EFEFEF; /* old browsers */
|
||||
background: -moz-linear-gradient(top, #f5f5f5 0%, #efefef 50%, #e5e5e5 51%, #dfdfdf 100%); /* firefox */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(50%,#efefef), color-stop(51%,#e5e5e5), color-stop(100%,#dfdfdf)); /* webkit */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#dfdfdf',GradientType=0 ); /* ie */
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
border-color: #466899;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
-moz-text-shadow: 1px 1px 0 #222;
|
||||
-webkit-text-shadow: 1px 1px 0 #222;
|
||||
text-shadow: 1px 1px 0 #222;
|
||||
|
||||
background: #6396D8; /* old browsers */
|
||||
background: -moz-linear-gradient(top, #6396D8 0%, #5A83BC 50%, #547AB7 51%, #466899 100%); /* firefox */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6396D8), color-stop(50%,#5A83BC), color-stop(51%,#547AB7), color-stop(100%,#466899)); /* webkit */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6396D8', endColorstr='#466899',GradientType=0 ); /* ie */
|
||||
}
|
||||
|
||||
.newwindow { text-align: center; }
|
||||
|
||||
.header .version em {
|
||||
display: block;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
#classdocs .item {
|
||||
border-bottom: 1px solid #466899;
|
||||
margin: 1em 0;
|
||||
padding: 1.5em;
|
||||
}
|
||||
|
||||
#classdocs .item .params p,
|
||||
#classdocs .item .returns p,{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#classdocs .item em code, #classdocs .item em.comment {
|
||||
color: green;
|
||||
}
|
||||
|
||||
#classdocs .item em.comment a {
|
||||
color: green;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#classdocs .foundat {
|
||||
font-size: 11px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.attrs .emits {
|
||||
margin-left: 2em;
|
||||
padding: .5em;
|
||||
border-left: 1px dashed #ccc;
|
||||
}
|
||||
|
||||
abbr {
|
||||
border-bottom: 1px dashed #ccc;
|
||||
font-size: 80%;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L8 {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
ul li p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.method .name {
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
.apidocs .methods .extends .method,
|
||||
.apidocs .properties .extends .property,
|
||||
.apidocs .attrs .extends .attr,
|
||||
.apidocs .events .extends .event {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.apidocs .methods .extends .inherited,
|
||||
.apidocs .properties .extends .inherited,
|
||||
.apidocs .attrs .extends .inherited,
|
||||
.apidocs .events .extends .inherited {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#hd {
|
||||
background: whiteSmoke;
|
||||
background: -moz-linear-gradient(top,#DCDBD9 0,#F6F5F3 100%);
|
||||
background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#DCDBD9),color-stop(100%,#F6F5F3));
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dcdbd9',endColorstr='#F6F5F3',GradientType=0);
|
||||
border-bottom: 1px solid #DFDFDF;
|
||||
padding: 0 15px 1px 20px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
#hd img {
|
||||
margin-right: 10px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
/* -- API Docs CSS ---------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
This file is organized so that more generic styles are nearer the top, and more
|
||||
specific styles are nearer the bottom of the file. This allows us to take full
|
||||
advantage of the cascade to avoid redundant style rules. Please respect this
|
||||
convention when making changes.
|
||||
*/
|
||||
|
||||
/* -- Generic TabView styles ------------------------------------------------ */
|
||||
|
||||
/*
|
||||
These styles apply to all API doc tabviews. To change styles only for a
|
||||
specific tabview, see the other sections below.
|
||||
*/
|
||||
|
||||
.yui3-js-enabled .apidocs .tabview {
|
||||
visibility: hidden; /* Hide until the TabView finishes rendering. */
|
||||
_visibility: visible;
|
||||
}
|
||||
|
||||
.apidocs .tabview.yui3-tabview-content { visibility: visible; }
|
||||
.apidocs .tabview .yui3-tabview-panel { background: #fff; }
|
||||
|
||||
/* -- Generic Content Styles ------------------------------------------------ */
|
||||
|
||||
/* Headings */
|
||||
h2, h3, h4, h5, h6 {
|
||||
border: none;
|
||||
color: #30418C;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.link-docs {
|
||||
float: right;
|
||||
font-size: 15px;
|
||||
margin: 4px 4px 6px;
|
||||
padding: 6px 30px 5px;
|
||||
}
|
||||
|
||||
.apidocs { zoom: 1; }
|
||||
|
||||
/* Generic box styles. */
|
||||
.apidocs .box {
|
||||
border: 1px solid;
|
||||
border-radius: 3px;
|
||||
margin: 1em 0;
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
/* A flag is a compact, capsule-like indicator of some kind. It's used to
|
||||
indicate private and protected items, item return types, etc. in an
|
||||
attractive and unobtrusive way. */
|
||||
.apidocs .flag {
|
||||
background: #bababa;
|
||||
border-radius: 3px;
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
margin: 0 0.5em;
|
||||
padding: 2px 4px 1px;
|
||||
}
|
||||
|
||||
/* Class/module metadata such as "Uses", "Extends", "Defined in", etc. */
|
||||
.apidocs .meta {
|
||||
background: #f9f9f9;
|
||||
border-color: #efefef;
|
||||
color: #555;
|
||||
font-size: 11px;
|
||||
padding: 3px 6px;
|
||||
}
|
||||
|
||||
.apidocs .meta p { margin: 0; }
|
||||
|
||||
/* Deprecation warning. */
|
||||
.apidocs .box.deprecated,
|
||||
.apidocs .flag.deprecated {
|
||||
background: #fdac9f;
|
||||
border: 1px solid #fd7775;
|
||||
}
|
||||
|
||||
.apidocs .box.deprecated p { margin: 0.5em 0; }
|
||||
.apidocs .flag.deprecated { color: #333; }
|
||||
|
||||
/* Module/Class intro description. */
|
||||
.apidocs .intro {
|
||||
background: #f0f1f8;
|
||||
border-color: #d4d8eb;
|
||||
}
|
||||
|
||||
/* Loading spinners. */
|
||||
#bd.loading .apidocs,
|
||||
#api-list.loading .yui3-tabview-panel {
|
||||
background: #fff url(../img/spinner.gif) no-repeat center 70px;
|
||||
min-height: 150px;
|
||||
}
|
||||
|
||||
#bd.loading .apidocs .content,
|
||||
#api-list.loading .yui3-tabview-panel .apis {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.apidocs .no-visible-items { color: #666; }
|
||||
|
||||
/* Generic inline list. */
|
||||
.apidocs ul.inline {
|
||||
display: inline;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs ul.inline li { display: inline; }
|
||||
|
||||
/* Comma-separated list. */
|
||||
.apidocs ul.commas li:after { content: ','; }
|
||||
.apidocs ul.commas li:last-child:after { content: ''; }
|
||||
|
||||
/* Keyboard shortcuts. */
|
||||
kbd .cmd { font-family: Monaco, Helvetica; }
|
||||
|
||||
/* -- Generic Access Level styles ------------------------------------------- */
|
||||
.apidocs .item.protected,
|
||||
.apidocs .item.private,
|
||||
.apidocs .index-item.protected,
|
||||
.apidocs .index-item.deprecated,
|
||||
.apidocs .index-item.private {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.show-deprecated .item.deprecated,
|
||||
.show-deprecated .index-item.deprecated,
|
||||
.show-protected .item.protected,
|
||||
.show-protected .index-item.protected,
|
||||
.show-private .item.private,
|
||||
.show-private .index-item.private {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.hide-inherited .item.inherited,
|
||||
.hide-inherited .index-item.inherited {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* -- Generic Item Index styles --------------------------------------------- */
|
||||
.apidocs .index { margin: 1.5em 0 3em; }
|
||||
|
||||
.apidocs .index h3 {
|
||||
border-bottom: 1px solid #efefef;
|
||||
color: #333;
|
||||
font-size: 13px;
|
||||
margin: 2em 0 0.6em;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.apidocs .index .no-visible-items { margin-top: 2em; }
|
||||
|
||||
.apidocs .index-list {
|
||||
border-color: #efefef;
|
||||
font-size: 12px;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-moz-column-count: 4;
|
||||
-moz-column-gap: 10px;
|
||||
-moz-column-width: 170px;
|
||||
-ms-column-count: 4;
|
||||
-ms-column-gap: 10px;
|
||||
-ms-column-width: 170px;
|
||||
-o-column-count: 4;
|
||||
-o-column-gap: 10px;
|
||||
-o-column-width: 170px;
|
||||
-webkit-column-count: 4;
|
||||
-webkit-column-gap: 10px;
|
||||
-webkit-column-width: 170px;
|
||||
column-count: 4;
|
||||
column-gap: 10px;
|
||||
column-width: 170px;
|
||||
}
|
||||
|
||||
.apidocs .no-columns .index-list {
|
||||
-moz-column-count: 1;
|
||||
-ms-column-count: 1;
|
||||
-o-column-count: 1;
|
||||
-webkit-column-count: 1;
|
||||
column-count: 1;
|
||||
}
|
||||
|
||||
.apidocs .index-item { white-space: nowrap; }
|
||||
|
||||
.apidocs .index-item .flag {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #afafaf;
|
||||
display: inline;
|
||||
margin: 0 0 0 0.2em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* -- Generic API item styles ----------------------------------------------- */
|
||||
.apidocs .args {
|
||||
display: inline;
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
|
||||
.apidocs .flag.chainable { background: #46ca3b; }
|
||||
.apidocs .flag.protected { background: #9b86fc; }
|
||||
.apidocs .flag.private { background: #fd6b1b; }
|
||||
.apidocs .flag.async { background: #356de4; }
|
||||
.apidocs .flag.required { background: #e60923; }
|
||||
|
||||
.apidocs .item {
|
||||
border-bottom: 1px solid #efefef;
|
||||
margin: 1.5em 0 2em;
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
.apidocs .item h4,
|
||||
.apidocs .item h5,
|
||||
.apidocs .item h6 {
|
||||
color: #333;
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.apidocs .item .description p,
|
||||
.apidocs .item pre.code {
|
||||
margin: 1em 0 0;
|
||||
}
|
||||
|
||||
.apidocs .item .meta {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs .item .name {
|
||||
display: inline;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.apidocs .item .type,
|
||||
.apidocs .item .type a,
|
||||
.apidocs .returns-inline {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.apidocs .item .type,
|
||||
.apidocs .returns-inline {
|
||||
font-size: 11px;
|
||||
margin: 0 0 0 0;
|
||||
}
|
||||
|
||||
.apidocs .item .type a { border-bottom: 1px dotted #afafaf; }
|
||||
.apidocs .item .type a:hover { border: none; }
|
||||
|
||||
/* -- Item Parameter List --------------------------------------------------- */
|
||||
.apidocs .params-list {
|
||||
list-style: square;
|
||||
margin: 1em 0 0 2em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs .param { margin-bottom: 1em; }
|
||||
|
||||
.apidocs .param .type,
|
||||
.apidocs .param .type a {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.apidocs .param .type {
|
||||
margin: 0 0 0 0.5em;
|
||||
*margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.apidocs .param-name { font-weight: bold; }
|
||||
|
||||
/* -- Item "Emits" block ---------------------------------------------------- */
|
||||
.apidocs .item .emits {
|
||||
background: #f9f9f9;
|
||||
border-color: #eaeaea;
|
||||
}
|
||||
|
||||
/* -- Item "Returns" block -------------------------------------------------- */
|
||||
.apidocs .item .returns .type,
|
||||
.apidocs .item .returns .type a {
|
||||
font-size: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* -- Class Constructor block ----------------------------------------------- */
|
||||
.apidocs .constructor .item {
|
||||
border: none;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
/* -- File Source View ------------------------------------------------------ */
|
||||
.apidocs .file pre.code,
|
||||
#doc .apidocs .file pre.prettyprint {
|
||||
background: inherit;
|
||||
border: none;
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.apidocs .L0,
|
||||
.apidocs .L1,
|
||||
.apidocs .L2,
|
||||
.apidocs .L3,
|
||||
.apidocs .L4,
|
||||
.apidocs .L5,
|
||||
.apidocs .L6,
|
||||
.apidocs .L7,
|
||||
.apidocs .L8,
|
||||
.apidocs .L9 {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
/* -- Submodule List -------------------------------------------------------- */
|
||||
.apidocs .module-submodule-description {
|
||||
font-size: 12px;
|
||||
margin: 0.3em 0 1em;
|
||||
}
|
||||
|
||||
.apidocs .module-submodule-description p:first-child { margin-top: 0; }
|
||||
|
||||
/* -- Sidebar TabView ------------------------------------------------------- */
|
||||
#api-tabview { margin-top: 0.6em; }
|
||||
|
||||
#api-tabview-filter,
|
||||
#api-tabview-panel {
|
||||
border: 1px solid #dfdfdf;
|
||||
}
|
||||
|
||||
#api-tabview-filter {
|
||||
border-bottom: none;
|
||||
border-top: none;
|
||||
padding: 0.6em 10px 0 10px;
|
||||
}
|
||||
|
||||
#api-tabview-panel { border-top: none; }
|
||||
#api-filter { width: 97%; }
|
||||
|
||||
/* -- Content TabView ------------------------------------------------------- */
|
||||
#classdocs .yui3-tabview-panel { border: none; }
|
||||
|
||||
/* -- Source File Contents -------------------------------------------------- */
|
||||
.prettyprint li.L0,
|
||||
.prettyprint li.L1,
|
||||
.prettyprint li.L2,
|
||||
.prettyprint li.L3,
|
||||
.prettyprint li.L5,
|
||||
.prettyprint li.L6,
|
||||
.prettyprint li.L7,
|
||||
.prettyprint li.L8 {
|
||||
list-style: decimal;
|
||||
}
|
||||
|
||||
/* -- API options ----------------------------------------------------------- */
|
||||
#api-options {
|
||||
font-size: 11px;
|
||||
margin-top: 2.2em;
|
||||
position: absolute;
|
||||
right: 1.5em;
|
||||
}
|
||||
|
||||
/*#api-options label { margin-right: 0.6em; }*/
|
||||
|
||||
/* -- API list -------------------------------------------------------------- */
|
||||
#api-list {
|
||||
margin-top: 1.5em;
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.apis {
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0.5em 0 0.5em 0.4em;
|
||||
}
|
||||
|
||||
.apis a {
|
||||
border: 1px solid transparent;
|
||||
display: block;
|
||||
margin: 0 0 0 -4px;
|
||||
padding: 1px 4px 0;
|
||||
text-decoration: none;
|
||||
_border: none;
|
||||
_display: inline;
|
||||
}
|
||||
|
||||
.apis a:hover,
|
||||
.apis a:focus {
|
||||
background: #E8EDFC;
|
||||
background: -moz-linear-gradient(top, #e8edfc 0%, #becef7 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#E8EDFC), color-stop(100%,#BECEF7));
|
||||
border-color: #AAC0FA;
|
||||
border-radius: 3px;
|
||||
color: #333;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.api-list-item a:hover,
|
||||
.api-list-item a:focus {
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px #fff;
|
||||
}
|
||||
|
||||
.apis .message { color: #888; }
|
||||
.apis .result a { padding: 3px 5px 2px; }
|
||||
|
||||
.apis .result .type {
|
||||
right: 4px;
|
||||
top: 7px;
|
||||
}
|
||||
|
||||
.api-list-item .yui3-highlight {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 740 B |
|
Before Width: | Height: | Size: 2.6 KiB |
@@ -1,10 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirector</title>
|
||||
<meta http-equiv="refresh" content="0;url=../">
|
||||
</head>
|
||||
<body>
|
||||
<a href="../">Click here to redirect</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,52 +0,0 @@
|
||||
YUI.add('api-filter', function (Y) {
|
||||
|
||||
Y.APIFilter = Y.Base.create('apiFilter', Y.Base, [Y.AutoCompleteBase], {
|
||||
// -- Initializer ----------------------------------------------------------
|
||||
initializer: function () {
|
||||
this._bindUIACBase();
|
||||
this._syncUIACBase();
|
||||
},
|
||||
getDisplayName: function(name) {
|
||||
|
||||
Y.each(Y.YUIDoc.meta.allModules, function(i) {
|
||||
if (i.name === name && i.displayName) {
|
||||
name = i.displayName;
|
||||
}
|
||||
});
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}, {
|
||||
// -- Attributes -----------------------------------------------------------
|
||||
ATTRS: {
|
||||
resultHighlighter: {
|
||||
value: 'phraseMatch'
|
||||
},
|
||||
|
||||
// May be set to "classes" or "modules".
|
||||
queryType: {
|
||||
value: 'classes'
|
||||
},
|
||||
|
||||
source: {
|
||||
valueFn: function() {
|
||||
var self = this;
|
||||
return function(q) {
|
||||
var data = Y.YUIDoc.meta[self.get('queryType')],
|
||||
out = [];
|
||||
Y.each(data, function(v) {
|
||||
if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
|
||||
out.push(v);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}, '3.4.0', {requires: [
|
||||
'autocomplete-base', 'autocomplete-highlighters', 'autocomplete-sources'
|
||||
]});
|
||||
@@ -1,251 +0,0 @@
|
||||
YUI.add('api-list', function (Y) {
|
||||
|
||||
var Lang = Y.Lang,
|
||||
YArray = Y.Array,
|
||||
|
||||
APIList = Y.namespace('APIList'),
|
||||
|
||||
classesNode = Y.one('#api-classes'),
|
||||
inputNode = Y.one('#api-filter'),
|
||||
modulesNode = Y.one('#api-modules'),
|
||||
tabviewNode = Y.one('#api-tabview'),
|
||||
|
||||
tabs = APIList.tabs = {},
|
||||
|
||||
filter = APIList.filter = new Y.APIFilter({
|
||||
inputNode : inputNode,
|
||||
maxResults: 1000,
|
||||
|
||||
on: {
|
||||
results: onFilterResults
|
||||
}
|
||||
}),
|
||||
|
||||
search = APIList.search = new Y.APISearch({
|
||||
inputNode : inputNode,
|
||||
maxResults: 100,
|
||||
|
||||
on: {
|
||||
clear : onSearchClear,
|
||||
results: onSearchResults
|
||||
}
|
||||
}),
|
||||
|
||||
tabview = APIList.tabview = new Y.TabView({
|
||||
srcNode : tabviewNode,
|
||||
panelNode: '#api-tabview-panel',
|
||||
render : true,
|
||||
|
||||
on: {
|
||||
selectionChange: onTabSelectionChange
|
||||
}
|
||||
}),
|
||||
|
||||
focusManager = APIList.focusManager = tabviewNode.plug(Y.Plugin.NodeFocusManager, {
|
||||
circular : true,
|
||||
descendants: '#api-filter, .yui3-tab-panel-selected .api-list-item a, .yui3-tab-panel-selected .result a',
|
||||
keys : {next: 'down:40', previous: 'down:38'}
|
||||
}).focusManager,
|
||||
|
||||
LIST_ITEM_TEMPLATE =
|
||||
'<li class="api-list-item {typeSingular}">' +
|
||||
'<a href="{rootPath}{typePlural}/{name}.html">{displayName}</a>' +
|
||||
'</li>';
|
||||
|
||||
// -- Init ---------------------------------------------------------------------
|
||||
|
||||
// Duckpunch FocusManager's key event handling to prevent it from handling key
|
||||
// events when a modifier is pressed.
|
||||
Y.before(function (e, activeDescendant) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
||||
return new Y.Do.Prevent();
|
||||
}
|
||||
}, focusManager, '_focusPrevious', focusManager);
|
||||
|
||||
Y.before(function (e, activeDescendant) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
||||
return new Y.Do.Prevent();
|
||||
}
|
||||
}, focusManager, '_focusNext', focusManager);
|
||||
|
||||
// Create a mapping of tabs in the tabview so we can refer to them easily later.
|
||||
tabview.each(function (tab, index) {
|
||||
var name = tab.get('label').toLowerCase();
|
||||
|
||||
tabs[name] = {
|
||||
index: index,
|
||||
name : name,
|
||||
tab : tab
|
||||
};
|
||||
});
|
||||
|
||||
// Switch tabs on Ctrl/Cmd-Left/Right arrows.
|
||||
tabviewNode.on('key', onTabSwitchKey, 'down:37,39');
|
||||
|
||||
// Focus the filter input when the `/` key is pressed.
|
||||
Y.one(Y.config.doc).on('key', onSearchKey, 'down:83');
|
||||
|
||||
// Keep the Focus Manager up to date.
|
||||
inputNode.on('focus', function () {
|
||||
focusManager.set('activeDescendant', inputNode);
|
||||
});
|
||||
|
||||
// Update all tabview links to resolved URLs.
|
||||
tabview.get('panelNode').all('a').each(function (link) {
|
||||
link.setAttribute('href', link.get('href'));
|
||||
});
|
||||
|
||||
// -- Private Functions --------------------------------------------------------
|
||||
function getFilterResultNode() {
|
||||
return filter.get('queryType') === 'classes' ? classesNode : modulesNode;
|
||||
}
|
||||
|
||||
// -- Event Handlers -----------------------------------------------------------
|
||||
function onFilterResults(e) {
|
||||
var frag = Y.one(Y.config.doc.createDocumentFragment()),
|
||||
resultNode = getFilterResultNode(),
|
||||
typePlural = filter.get('queryType'),
|
||||
typeSingular = typePlural === 'classes' ? 'class' : 'module';
|
||||
|
||||
if (e.results.length) {
|
||||
YArray.each(e.results, function (result) {
|
||||
frag.append(Lang.sub(LIST_ITEM_TEMPLATE, {
|
||||
rootPath : APIList.rootPath,
|
||||
displayName : filter.getDisplayName(result.highlighted),
|
||||
name : result.text,
|
||||
typePlural : typePlural,
|
||||
typeSingular: typeSingular
|
||||
}));
|
||||
});
|
||||
} else {
|
||||
frag.append(
|
||||
'<li class="message">' +
|
||||
'No ' + typePlural + ' found.' +
|
||||
'</li>'
|
||||
);
|
||||
}
|
||||
|
||||
resultNode.empty(true);
|
||||
resultNode.append(frag);
|
||||
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onSearchClear(e) {
|
||||
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onSearchKey(e) {
|
||||
var target = e.target;
|
||||
|
||||
if (target.test('input,select,textarea')
|
||||
|| target.get('isContentEditable')) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
inputNode.focus();
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onSearchResults(e) {
|
||||
var frag = Y.one(Y.config.doc.createDocumentFragment());
|
||||
|
||||
if (e.results.length) {
|
||||
YArray.each(e.results, function (result) {
|
||||
frag.append(result.display);
|
||||
});
|
||||
} else {
|
||||
frag.append(
|
||||
'<li class="message">' +
|
||||
'No results found. Maybe you\'ll have better luck with a ' +
|
||||
'different query?' +
|
||||
'</li>'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
focusManager.refresh();
|
||||
}
|
||||
|
||||
function onTabSelectionChange(e) {
|
||||
var tab = e.newVal,
|
||||
name = tab.get('label').toLowerCase();
|
||||
|
||||
tabs.selected = {
|
||||
index: tab.get('index'),
|
||||
name : name,
|
||||
tab : tab
|
||||
};
|
||||
|
||||
switch (name) {
|
||||
case 'classes': // fallthru
|
||||
case 'modules':
|
||||
filter.setAttrs({
|
||||
minQueryLength: 0,
|
||||
queryType : name
|
||||
});
|
||||
|
||||
search.set('minQueryLength', -1);
|
||||
|
||||
// Only send a request if this isn't the initially-selected tab.
|
||||
if (e.prevVal) {
|
||||
filter.sendRequest(filter.get('value'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'everything':
|
||||
filter.set('minQueryLength', -1);
|
||||
search.set('minQueryLength', 1);
|
||||
|
||||
if (search.get('value')) {
|
||||
search.sendRequest(search.get('value'));
|
||||
} else {
|
||||
inputNode.focus();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// WTF? We shouldn't be here!
|
||||
filter.set('minQueryLength', -1);
|
||||
search.set('minQueryLength', -1);
|
||||
}
|
||||
|
||||
if (focusManager) {
|
||||
setTimeout(function () {
|
||||
focusManager.refresh();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
function onTabSwitchKey(e) {
|
||||
var currentTabIndex = tabs.selected.index;
|
||||
|
||||
if (!(e.ctrlKey || e.metaKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
switch (e.keyCode) {
|
||||
case 37: // left arrow
|
||||
if (currentTabIndex > 0) {
|
||||
tabview.selectChild(currentTabIndex - 1);
|
||||
inputNode.focus();
|
||||
}
|
||||
break;
|
||||
|
||||
case 39: // right arrow
|
||||
if (currentTabIndex < (Y.Object.size(tabs) - 2)) {
|
||||
tabview.selectChild(currentTabIndex + 1);
|
||||
inputNode.focus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}, '3.4.0', {requires: [
|
||||
'api-filter', 'api-search', 'event-key', 'node-focusmanager', 'tabview'
|
||||
]});
|
||||
@@ -1,98 +0,0 @@
|
||||
YUI.add('api-search', function (Y) {
|
||||
|
||||
var Lang = Y.Lang,
|
||||
Node = Y.Node,
|
||||
YArray = Y.Array;
|
||||
|
||||
Y.APISearch = Y.Base.create('apiSearch', Y.Base, [Y.AutoCompleteBase], {
|
||||
// -- Public Properties ----------------------------------------------------
|
||||
RESULT_TEMPLATE:
|
||||
'<li class="result {resultType}">' +
|
||||
'<a href="{url}">' +
|
||||
'<h3 class="title">{name}</h3>' +
|
||||
'<span class="type">{resultType}</span>' +
|
||||
'<div class="description">{description}</div>' +
|
||||
'<span class="className">{class}</span>' +
|
||||
'</a>' +
|
||||
'</li>',
|
||||
|
||||
// -- Initializer ----------------------------------------------------------
|
||||
initializer: function () {
|
||||
this._bindUIACBase();
|
||||
this._syncUIACBase();
|
||||
},
|
||||
|
||||
// -- Protected Methods ----------------------------------------------------
|
||||
_apiResultFilter: function (query, results) {
|
||||
// Filter components out of the results.
|
||||
return YArray.filter(results, function (result) {
|
||||
return result.raw.resultType === 'component' ? false : result;
|
||||
});
|
||||
},
|
||||
|
||||
_apiResultFormatter: function (query, results) {
|
||||
return YArray.map(results, function (result) {
|
||||
var raw = Y.merge(result.raw), // create a copy
|
||||
desc = raw.description || '';
|
||||
|
||||
// Convert description to text and truncate it if necessary.
|
||||
desc = Node.create('<div>' + desc + '</div>').get('text');
|
||||
|
||||
if (desc.length > 65) {
|
||||
desc = Y.Escape.html(desc.substr(0, 65)) + ' …';
|
||||
} else {
|
||||
desc = Y.Escape.html(desc);
|
||||
}
|
||||
|
||||
raw['class'] || (raw['class'] = '');
|
||||
raw.description = desc;
|
||||
|
||||
// Use the highlighted result name.
|
||||
raw.name = result.highlighted;
|
||||
|
||||
return Lang.sub(this.RESULT_TEMPLATE, raw);
|
||||
}, this);
|
||||
},
|
||||
|
||||
_apiTextLocator: function (result) {
|
||||
return result.displayName || result.name;
|
||||
}
|
||||
}, {
|
||||
// -- Attributes -----------------------------------------------------------
|
||||
ATTRS: {
|
||||
resultFormatter: {
|
||||
valueFn: function () {
|
||||
return this._apiResultFormatter;
|
||||
}
|
||||
},
|
||||
|
||||
resultFilters: {
|
||||
valueFn: function () {
|
||||
return this._apiResultFilter;
|
||||
}
|
||||
},
|
||||
|
||||
resultHighlighter: {
|
||||
value: 'phraseMatch'
|
||||
},
|
||||
|
||||
resultListLocator: {
|
||||
value: 'data.results'
|
||||
},
|
||||
|
||||
resultTextLocator: {
|
||||
valueFn: function () {
|
||||
return this._apiTextLocator;
|
||||
}
|
||||
},
|
||||
|
||||
source: {
|
||||
value: '/api/v1/search?q={query}&count={maxResults}'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}, '3.4.0', {requires: [
|
||||
'autocomplete-base', 'autocomplete-highlighters', 'autocomplete-sources',
|
||||
'escape'
|
||||
]});
|
||||
@@ -1,370 +0,0 @@
|
||||
YUI().use(
|
||||
'yuidoc-meta',
|
||||
'api-list', 'history-hash', 'node-screen', 'node-style', 'pjax',
|
||||
function (Y) {
|
||||
|
||||
var win = Y.config.win,
|
||||
localStorage = win.localStorage,
|
||||
|
||||
bdNode = Y.one('#bd'),
|
||||
|
||||
pjax,
|
||||
defaultRoute,
|
||||
|
||||
classTabView,
|
||||
selectedTab;
|
||||
|
||||
// Kill pjax functionality unless serving over HTTP.
|
||||
if (!Y.getLocation().protocol.match(/^https?\:/)) {
|
||||
Y.Router.html5 = false;
|
||||
}
|
||||
|
||||
// Create the default route with middleware which enables syntax highlighting
|
||||
// on the loaded content.
|
||||
defaultRoute = Y.Pjax.defaultRoute.concat(function (req, res, next) {
|
||||
prettyPrint();
|
||||
bdNode.removeClass('loading');
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
pjax = new Y.Pjax({
|
||||
container : '#docs-main',
|
||||
contentSelector: '#docs-main > .content',
|
||||
linkSelector : '#bd a',
|
||||
titleSelector : '#xhr-title',
|
||||
|
||||
navigateOnHash: true,
|
||||
root : '/',
|
||||
routes : [
|
||||
// -- / ----------------------------------------------------------------
|
||||
{
|
||||
path : '/(index.html)?',
|
||||
callbacks: defaultRoute
|
||||
},
|
||||
|
||||
// -- /classes/* -------------------------------------------------------
|
||||
{
|
||||
path : '/classes/:class.html*',
|
||||
callbacks: [defaultRoute, 'handleClasses']
|
||||
},
|
||||
|
||||
// -- /files/* ---------------------------------------------------------
|
||||
{
|
||||
path : '/files/*file',
|
||||
callbacks: [defaultRoute, 'handleFiles']
|
||||
},
|
||||
|
||||
// -- /modules/* -------------------------------------------------------
|
||||
{
|
||||
path : '/modules/:module.html*',
|
||||
callbacks: defaultRoute
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// -- Utility Functions --------------------------------------------------------
|
||||
|
||||
pjax.checkVisibility = function (tab) {
|
||||
tab || (tab = selectedTab);
|
||||
|
||||
if (!tab) { return; }
|
||||
|
||||
var panelNode = tab.get('panelNode'),
|
||||
visibleItems;
|
||||
|
||||
// If no items are visible in the tab panel due to the current visibility
|
||||
// settings, display a message to that effect.
|
||||
visibleItems = panelNode.all('.item,.index-item').some(function (itemNode) {
|
||||
if (itemNode.getComputedStyle('display') !== 'none') {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
panelNode.all('.no-visible-items').remove();
|
||||
|
||||
if (!visibleItems) {
|
||||
if (Y.one('#index .index-item')) {
|
||||
panelNode.append(
|
||||
'<div class="no-visible-items">' +
|
||||
'<p>' +
|
||||
'Some items are not shown due to the current visibility ' +
|
||||
'settings. Use the checkboxes at the upper right of this ' +
|
||||
'page to change the visibility settings.' +
|
||||
'</p>' +
|
||||
'</div>'
|
||||
);
|
||||
} else {
|
||||
panelNode.append(
|
||||
'<div class="no-visible-items">' +
|
||||
'<p>' +
|
||||
'This class doesn\'t provide any methods, properties, ' +
|
||||
'attributes, or events.' +
|
||||
'</p>' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Hide index sections without any visible items.
|
||||
Y.all('.index-section').each(function (section) {
|
||||
var items = 0,
|
||||
visibleItems = 0;
|
||||
|
||||
section.all('.index-item').each(function (itemNode) {
|
||||
items += 1;
|
||||
|
||||
if (itemNode.getComputedStyle('display') !== 'none') {
|
||||
visibleItems += 1;
|
||||
}
|
||||
});
|
||||
|
||||
section.toggleClass('hidden', !visibleItems);
|
||||
section.toggleClass('no-columns', visibleItems < 4);
|
||||
});
|
||||
};
|
||||
|
||||
pjax.initClassTabView = function () {
|
||||
if (!Y.all('#classdocs .api-class-tab').size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (classTabView) {
|
||||
classTabView.destroy();
|
||||
selectedTab = null;
|
||||
}
|
||||
|
||||
classTabView = new Y.TabView({
|
||||
srcNode: '#classdocs',
|
||||
|
||||
on: {
|
||||
selectionChange: pjax.onTabSelectionChange
|
||||
}
|
||||
});
|
||||
|
||||
pjax.updateTabState();
|
||||
classTabView.render();
|
||||
};
|
||||
|
||||
pjax.initLineNumbers = function () {
|
||||
var hash = win.location.hash.substring(1),
|
||||
container = pjax.get('container'),
|
||||
hasLines, node;
|
||||
|
||||
// Add ids for each line number in the file source view.
|
||||
container.all('.linenums>li').each(function (lineNode, index) {
|
||||
lineNode.set('id', 'l' + (index + 1));
|
||||
lineNode.addClass('file-line');
|
||||
hasLines = true;
|
||||
});
|
||||
|
||||
// Scroll to the desired line.
|
||||
if (hasLines && /^l\d+$/.test(hash)) {
|
||||
if ((node = container.getById(hash))) {
|
||||
win.scroll(0, node.getY());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pjax.initRoot = function () {
|
||||
var terminators = /^(?:classes|files|modules)$/,
|
||||
parts = pjax._getPathRoot().split('/'),
|
||||
root = [],
|
||||
i, len, part;
|
||||
|
||||
for (i = 0, len = parts.length; i < len; i += 1) {
|
||||
part = parts[i];
|
||||
|
||||
if (part.match(terminators)) {
|
||||
// Makes sure the path will end with a "/".
|
||||
root.push('');
|
||||
break;
|
||||
}
|
||||
|
||||
root.push(part);
|
||||
}
|
||||
|
||||
pjax.set('root', root.join('/'));
|
||||
};
|
||||
|
||||
pjax.updateTabState = function (src) {
|
||||
var hash = win.location.hash.substring(1),
|
||||
defaultTab, node, tab, tabPanel;
|
||||
|
||||
function scrollToNode() {
|
||||
if (node.hasClass('protected')) {
|
||||
Y.one('#api-show-protected').set('checked', true);
|
||||
pjax.updateVisibility();
|
||||
}
|
||||
|
||||
if (node.hasClass('private')) {
|
||||
Y.one('#api-show-private').set('checked', true);
|
||||
pjax.updateVisibility();
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
// For some reason, unless we re-get the node instance here,
|
||||
// getY() always returns 0.
|
||||
var node = Y.one('#classdocs').getById(hash);
|
||||
win.scrollTo(0, node.getY() - 70);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
if (!classTabView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (src === 'hashchange' && !hash) {
|
||||
defaultTab = 'index';
|
||||
} else {
|
||||
if (localStorage) {
|
||||
defaultTab = localStorage.getItem('tab_' + pjax.getPath()) ||
|
||||
'index';
|
||||
} else {
|
||||
defaultTab = 'index';
|
||||
}
|
||||
}
|
||||
|
||||
if (hash && (node = Y.one('#classdocs').getById(hash))) {
|
||||
if ((tabPanel = node.ancestor('.api-class-tabpanel', true))) {
|
||||
if ((tab = Y.one('#classdocs .api-class-tab.' + tabPanel.get('id')))) {
|
||||
if (classTabView.get('rendered')) {
|
||||
Y.Widget.getByNode(tab).set('selected', 1);
|
||||
} else {
|
||||
tab.addClass('yui3-tab-selected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll to the desired element if this is a hash URL.
|
||||
if (node) {
|
||||
if (classTabView.get('rendered')) {
|
||||
scrollToNode();
|
||||
} else {
|
||||
classTabView.once('renderedChange', scrollToNode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tab = Y.one('#classdocs .api-class-tab.' + defaultTab);
|
||||
|
||||
// When the `defaultTab` node isn't found, `localStorage` is stale.
|
||||
if (!tab && defaultTab !== 'index') {
|
||||
tab = Y.one('#classdocs .api-class-tab.index');
|
||||
}
|
||||
|
||||
if (classTabView.get('rendered')) {
|
||||
Y.Widget.getByNode(tab).set('selected', 1);
|
||||
} else {
|
||||
tab.addClass('yui3-tab-selected');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pjax.updateVisibility = function () {
|
||||
var container = pjax.get('container');
|
||||
|
||||
container.toggleClass('hide-inherited',
|
||||
!Y.one('#api-show-inherited').get('checked'));
|
||||
|
||||
container.toggleClass('show-deprecated',
|
||||
Y.one('#api-show-deprecated').get('checked'));
|
||||
|
||||
container.toggleClass('show-protected',
|
||||
Y.one('#api-show-protected').get('checked'));
|
||||
|
||||
container.toggleClass('show-private',
|
||||
Y.one('#api-show-private').get('checked'));
|
||||
|
||||
pjax.checkVisibility();
|
||||
};
|
||||
|
||||
// -- Route Handlers -----------------------------------------------------------
|
||||
|
||||
pjax.handleClasses = function (req, res, next) {
|
||||
var status = res.ioResponse.status;
|
||||
|
||||
// Handles success and local filesystem XHRs.
|
||||
if (!status || (status >= 200 && status < 300)) {
|
||||
pjax.initClassTabView();
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
pjax.handleFiles = function (req, res, next) {
|
||||
var status = res.ioResponse.status;
|
||||
|
||||
// Handles success and local filesystem XHRs.
|
||||
if (!status || (status >= 200 && status < 300)) {
|
||||
pjax.initLineNumbers();
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
// -- Event Handlers -----------------------------------------------------------
|
||||
|
||||
pjax.onNavigate = function (e) {
|
||||
var hash = e.hash,
|
||||
originTarget = e.originEvent && e.originEvent.target,
|
||||
tab;
|
||||
|
||||
if (hash) {
|
||||
tab = originTarget && originTarget.ancestor('.yui3-tab', true);
|
||||
|
||||
if (hash === win.location.hash) {
|
||||
pjax.updateTabState('hashchange');
|
||||
} else if (!tab) {
|
||||
win.location.hash = hash;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Only scroll to the top of the page when the URL doesn't have a hash.
|
||||
this.set('scrollToTop', !e.url.match(/#.+$/));
|
||||
|
||||
bdNode.addClass('loading');
|
||||
};
|
||||
|
||||
pjax.onOptionClick = function (e) {
|
||||
pjax.updateVisibility();
|
||||
};
|
||||
|
||||
pjax.onTabSelectionChange = function (e) {
|
||||
var tab = e.newVal,
|
||||
tabId = tab.get('contentBox').getAttribute('href').substring(1);
|
||||
|
||||
selectedTab = tab;
|
||||
|
||||
// If switching from a previous tab (i.e., this is not the default tab),
|
||||
// replace the history entry with a hash URL that will cause this tab to
|
||||
// be selected if the user navigates away and then returns using the back
|
||||
// or forward buttons.
|
||||
if (e.prevVal && localStorage) {
|
||||
localStorage.setItem('tab_' + pjax.getPath(), tabId);
|
||||
}
|
||||
|
||||
pjax.checkVisibility(tab);
|
||||
};
|
||||
|
||||
// -- Init ---------------------------------------------------------------------
|
||||
|
||||
pjax.on('navigate', pjax.onNavigate);
|
||||
|
||||
pjax.initRoot();
|
||||
pjax.upgrade();
|
||||
pjax.initClassTabView();
|
||||
pjax.initLineNumbers();
|
||||
pjax.updateVisibility();
|
||||
|
||||
Y.APIList.rootPath = pjax.get('root');
|
||||
|
||||
Y.one('#api-options').delegate('click', pjax.onOptionClick, 'input');
|
||||
|
||||
Y.on('hashchange', function (e) {
|
||||
pjax.updateTabState('hashchange');
|
||||
}, win);
|
||||
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
YUI().use('node', function(Y) {
|
||||
var code = Y.all('.prettyprint.linenums');
|
||||
if (code.size()) {
|
||||
code.each(function(c) {
|
||||
var lis = c.all('ol li'),
|
||||
l = 1;
|
||||
lis.each(function(n) {
|
||||
n.prepend('<a name="LINENUM_' + l + '"></a>');
|
||||
l++;
|
||||
});
|
||||
});
|
||||
var h = location.hash;
|
||||
location.hash = '';
|
||||
h = h.replace('LINE_', 'LINENUM_');
|
||||
location.hash = h;
|
||||
}
|
||||
});
|
||||
@@ -1,130 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Change Log</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
<a style="float:right" href="README.html">README</a>
|
||||
|
||||
<h1>Known Issues</h1>
|
||||
<ul>
|
||||
<li>Perl formatting is really crappy. Partly because the author is lazy and
|
||||
partly because Perl is
|
||||
<a href="http://www.perlmonks.org/?node_id=663393">hard</a> to parse.
|
||||
<li>On some browsers, <code><code></code> elements with newlines in the text
|
||||
which use CSS to specify <code>white-space:pre</code> will have the newlines
|
||||
improperly stripped if the element is not attached to the document at the time
|
||||
the stripping is done. Also, on IE 6, all newlines will be stripped from
|
||||
<code><code></code> elements because of the way IE6 produces
|
||||
<code>innerHTML</code>. Workaround: use <code><pre></code> for code with
|
||||
newlines.
|
||||
</ul>
|
||||
|
||||
<h1>Change Log</h1>
|
||||
<h2>29 March 2007</h2>
|
||||
<ul>
|
||||
<li>Added <a href="tests/prettify_test.html#PHP">tests</a> for PHP support
|
||||
to address
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=3"
|
||||
>issue 3</a>.
|
||||
<li>Fixed
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=6"
|
||||
>bug</a>: <code>prettyPrintOne</code> was not halting. This was not
|
||||
reachable through the normal entry point.
|
||||
<li>Fixed
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=4"
|
||||
>bug</a>: recursing into a script block or PHP tag that was not properly
|
||||
closed would not silently drop the content.
|
||||
(<a href="tests/prettify_test.html#issue4">test</a>)
|
||||
<li>Fixed
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=8"
|
||||
>bug</a>: was eating tabs
|
||||
(<a href="tests/prettify_test.html#issue8">test</a>)
|
||||
<li>Fixed entity handling so that the caveat
|
||||
<blockquote>
|
||||
<p>Caveats: please properly escape less-thans. <tt>x&lt;y</tt>
|
||||
instead of <tt>x<y</tt>, and use <tt>"</tt> instead of
|
||||
<tt>&quot;</tt> for string delimiters.</p>
|
||||
</blockquote>
|
||||
is no longer applicable.
|
||||
<li>Added noisefree's C#
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=4"
|
||||
>patch</a>
|
||||
<li>Added a <a href="http://google-code-prettify.googlecode.com/files/prettify-small.zip">distribution</a> that has comments and
|
||||
whitespace removed to reduce download size from 45.5kB to 12.8kB.
|
||||
</ul>
|
||||
<h2>4 Jul 2008</h2>
|
||||
<ul>
|
||||
<li>Added <a href="http://code.google.com/p/google-code-prettify/issues/detail?id=17">language specific formatters</a> that are triggered by the presence
|
||||
of a <code>lang-<language-file-extension></code></li>
|
||||
<li>Fixed <a href="http://code.google.com/p/google-code-prettify/issues/detail?id=29">bug</a>: python handling of <code>'''string'''</code>
|
||||
<li>Fixed bug: <code>/</code> in regex <code>[charsets] should not end regex</code>
|
||||
</ul>
|
||||
<h2>5 Jul 2008</h2>
|
||||
<ul>
|
||||
<li>Defined language extensions for Lisp and Lua</code>
|
||||
</ul>
|
||||
<h2>14 Jul 2008</h2>
|
||||
<ul>
|
||||
<li>Language handlers for F#, OCAML, SQL</code>
|
||||
<li>Support for <code>nocode</code> spans to allow embedding of line
|
||||
numbers and code annotations which should not be styled or otherwise
|
||||
affect the tokenization of prettified code.
|
||||
See the issue 22
|
||||
<a href="tests/prettify_test.html#issue22">testcase</a>.</code>
|
||||
</ul>
|
||||
<h2>6 Jan 2009</h2>
|
||||
<ul>
|
||||
<li>Language handlers for Visual Basic, Haskell, CSS, and WikiText</li>
|
||||
<li>Added <tt>.mxml</tt> extension to the markup style handler for
|
||||
Flex <a href="http://en.wikipedia.org/wiki/MXML">MXML files</a>. See
|
||||
<a
|
||||
href="http://code.google.com/p/google-code-prettify/issues/detail?id=37"
|
||||
>issue 37</a>.
|
||||
<li>Added <tt>.m</tt> extension to the C style handler so that Objective
|
||||
C source files properly highlight. See
|
||||
<a
|
||||
href="http://code.google.com/p/google-code-prettify/issues/detail?id=58"
|
||||
>issue 58</a>.
|
||||
<li>Changed HTML lexer to use the same embedded source mechanism as the
|
||||
wiki language handler, and changed to use the registered
|
||||
CSS handler for STYLE element content.
|
||||
</ul>
|
||||
<h2>21 May 2009</h2>
|
||||
<ul>
|
||||
<li>Rewrote to improve performance on large files.
|
||||
See <a href="http://mikesamuel.blogspot.com/2009/05/efficient-parsing-in-javascript.html">benchmarks</a>.</li>
|
||||
<li>Fixed bugs with highlighting of Haskell line comments, Lisp
|
||||
number literals, Lua strings, C preprocessor directives,
|
||||
newlines in Wiki code on Windows, and newlines in IE6.</li>
|
||||
</ul>
|
||||
<h2>14 August 2009</h2>
|
||||
<ul>
|
||||
<li>Fixed prettifying of <code><code></code> blocks with embedded newlines.
|
||||
</ul>
|
||||
<h2>3 October 2009</h2>
|
||||
<ul>
|
||||
<li>Fixed prettifying of XML/HTML tags that contain uppercase letters.
|
||||
</ul>
|
||||
<h2>19 July 2010</h2>
|
||||
<ul>
|
||||
<li>Added support for line numbers. Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=22"
|
||||
>22</a></li>
|
||||
<li>Added YAML support. Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=123"
|
||||
>123</a></li>
|
||||
<li>Added VHDL support courtesy Le Poussin.</li>
|
||||
<li>IE performance improvements. Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=102"
|
||||
>102</a> courtesy jacobly.</li>
|
||||
<li>A variety of markup formatting fixes courtesy smain and thezbyg.</li>
|
||||
<li>Fixed copy and paste in IE[678].
|
||||
<li>Changed output to use <code>&#160;</code> instead of
|
||||
<code>&nbsp;</code> so that the output works when embedded in XML.
|
||||
Bug
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/detail?id=108"
|
||||
>108</a>.</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,203 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Javascript code prettifier</title>
|
||||
|
||||
<link href="src/prettify.css" type="text/css" rel="stylesheet" />
|
||||
|
||||
<script src="src/prettify.js" type="text/javascript"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body { margin-left: .5in }
|
||||
h1, h2, h3, h4, .footer { margin-left: -.4in; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body onload="prettyPrint()" bgcolor="white">
|
||||
<small style="float: right">Languages : <a href="README-zh-Hans.html">CH</a></small>
|
||||
<h1>Javascript code prettifier</h1>
|
||||
|
||||
<h2>Setup</h2>
|
||||
<ol>
|
||||
<li><a href="http://code.google.com/p/google-code-prettify/downloads/list">Download</a> a distribution
|
||||
<li>Include the script and stylesheets in your document
|
||||
(you will need to make sure the css and js file are on your server, and
|
||||
adjust the paths in the <tt>script</tt> and <tt>link</tt> tag)
|
||||
<pre class="prettyprint">
|
||||
<link href="prettify.css" type="text/css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="prettify.js"></script></pre>
|
||||
<li>Add <code class="prettyprint lang-html">onload="prettyPrint()"</code> to your
|
||||
document's body tag.
|
||||
<li>Modify the stylesheet to get the coloring you prefer</li>
|
||||
</ol>
|
||||
|
||||
<h2>Usage</h2>
|
||||
<p>Put code snippets in
|
||||
<tt><pre class="prettyprint">...</pre></tt>
|
||||
or <tt><code class="prettyprint">...</code></tt>
|
||||
and it will automatically be pretty printed.
|
||||
|
||||
<table summary="code examples">
|
||||
<tr>
|
||||
<th>The original
|
||||
<th>Prettier
|
||||
<tr>
|
||||
<td><pre style="border: 1px solid #888;padding: 2px"
|
||||
><a name="voila1"></a>class Voila {
|
||||
public:
|
||||
// Voila
|
||||
static const string VOILA = "Voila";
|
||||
|
||||
// will not interfere with embedded <a href="#voila1">tags</a>.
|
||||
}</pre>
|
||||
|
||||
<td><pre class="prettyprint"><a name="voila2"></a>class Voila {
|
||||
public:
|
||||
// Voila
|
||||
static const string VOILA = "Voila";
|
||||
|
||||
// will not interfere with embedded <a href="#voila2">tags</a>.
|
||||
}</pre>
|
||||
</table>
|
||||
|
||||
<h2>FAQ</h2>
|
||||
<h3 id="langs">Which languages does it work for?</h3>
|
||||
<p>The comments in <tt>prettify.js</tt> are authoritative but the lexer
|
||||
should work on a number of languages including C and friends,
|
||||
Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles.
|
||||
It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl
|
||||
and Ruby, but, because of commenting conventions, doesn't work on
|
||||
Smalltalk, or CAML-like languages.</p>
|
||||
|
||||
<p>LISPy languages are supported via an extension:
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lisp.js"
|
||||
><code>lang-lisp.js</code></a>.</p>
|
||||
<p>And similarly for
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-css.js"
|
||||
><code>CSS</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-hs.js"
|
||||
><code>Haskell</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lua.js"
|
||||
><code>Lua</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-ml.js"
|
||||
><code>OCAML, SML, F#</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-vb.js"
|
||||
><code>Visual Basic</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-sql.js"
|
||||
><code>SQL</code></a>,
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-proto.js"
|
||||
><code>Protocol Buffers</code></a>, and
|
||||
<a href="http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-wiki.js"
|
||||
><code>WikiText</code></a>..
|
||||
|
||||
<p>If you'd like to add an extension for your favorite language, please
|
||||
look at <tt>src/lang-lisp.js</tt> and file an
|
||||
<a href="http://code.google.com/p/google-code-prettify/issues/list"
|
||||
>issue</a> including your language extension, and a testcase.</p>
|
||||
|
||||
<h3>How do I specify which language my code is in?</h3>
|
||||
<p>You don't need to specify the language since <code>prettyprint()</code>
|
||||
will guess. You can specify a language by specifying the language extension
|
||||
along with the <code>prettyprint</code> class like so:</p>
|
||||
<pre class="prettyprint lang-html"
|
||||
><pre class="prettyprint <b>lang-html</b>">
|
||||
The lang-* class specifies the language file extensions.
|
||||
File extensions supported by default include
|
||||
"bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
|
||||
"java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
|
||||
"xhtml", "xml", "xsl".
|
||||
</pre></pre>
|
||||
|
||||
<h3>It doesn't work on <tt><obfuscated code sample></tt>?</h3>
|
||||
<p>Yes. Prettifying obfuscated code is like putting lipstick on a pig
|
||||
— i.e. outside the scope of this tool.</p>
|
||||
|
||||
<h3>Which browsers does it work with?</h3>
|
||||
<p>It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4.
|
||||
Look at <a href="tests/prettify_test.html">the test page</a> to see if it
|
||||
works in your browser.</p>
|
||||
|
||||
<h3>What's changed?</h3>
|
||||
<p>See the <a href="CHANGES.html">change log</a></p>
|
||||
|
||||
<h3>Why doesn't Prettyprinting of strings work on WordPress?</h3>
|
||||
<p>Apparently wordpress does "smart quoting" which changes close quotes.
|
||||
This causes end quotes to not match up with open quotes.
|
||||
<p>This breaks prettifying as well as copying and pasting of code samples.
|
||||
See
|
||||
<a href="http://wordpress.org/support/topic/125038"
|
||||
>WordPress's help center</a> for info on how to stop smart quoting of code
|
||||
snippets.</p>
|
||||
|
||||
<h3 id="linenums">How do I put line numbers in my code?</h3>
|
||||
<p>You can use the <code>linenums</code> class to turn on line
|
||||
numbering. If your code doesn't start at line number 1, you can
|
||||
add a colon and a line number to the end of that class as in
|
||||
<code>linenums:52</code>.
|
||||
|
||||
<p>For example
|
||||
<pre class="prettyprint"><pre class="prettyprint linenums:<b>4</b>"
|
||||
>// This is line 4.
|
||||
foo();
|
||||
bar();
|
||||
baz();
|
||||
boo();
|
||||
far();
|
||||
faz();
|
||||
<pre></pre>
|
||||
produces
|
||||
<pre class="prettyprint linenums:4"
|
||||
>// This is line 4.
|
||||
foo();
|
||||
bar();
|
||||
baz();
|
||||
boo();
|
||||
far();
|
||||
faz();
|
||||
</pre>
|
||||
|
||||
<h3>How do I prevent a portion of markup from being marked as code?</h3>
|
||||
<p>You can use the <code>nocode</code> class to identify a span of markup
|
||||
that is not code.
|
||||
<pre class="prettyprint"><pre class=prettyprint>
|
||||
int x = foo(); /* This is a comment <span class="nocode">This is not code</span>
|
||||
Continuation of comment */
|
||||
int y = bar();
|
||||
</pre></pre>
|
||||
produces
|
||||
<pre class="prettyprint">
|
||||
int x = foo(); /* This is a comment <span class="nocode">This is not code</span>
|
||||
Continuation of comment */
|
||||
int y = bar();
|
||||
</pre>
|
||||
|
||||
<p>For a more complete example see the issue22
|
||||
<a href="tests/prettify_test.html#issue22">testcase</a>.</p>
|
||||
|
||||
<h3>I get an error message "a is not a function" or "opt_whenDone is not a function"</h3>
|
||||
<p>If you are calling <code>prettyPrint</code> via an event handler, wrap it in a function.
|
||||
Instead of doing
|
||||
<blockquote>
|
||||
<code class="prettyprint lang-js"
|
||||
>addEventListener('load', prettyPrint, false);</code>
|
||||
</blockquote>
|
||||
wrap it in a closure like
|
||||
<blockquote>
|
||||
<code class="prettyprint lang-js"
|
||||
>addEventListener('load', function (event) { prettyPrint() }, false);</code>
|
||||
</blockquote>
|
||||
so that the browser does not pass an event object to <code>prettyPrint</code> which
|
||||
will confuse it.
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<div class="footer">
|
||||
<!-- Created: Tue Oct 3 17:51:56 PDT 2006 -->
|
||||
<!-- hhmts start -->
|
||||
Last modified: Wed Jul 19 13:56:00 PST 2010
|
||||
<!-- hhmts end -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,364 +0,0 @@
|
||||
{
|
||||
"project": {
|
||||
"name": "Phaser",
|
||||
"description": "HTML5 Game Framework",
|
||||
"version": "1.0.0",
|
||||
"url": "http://www.phaser.io/"
|
||||
},
|
||||
"files": {
|
||||
"..\\Phaser\\time\\TimeManager.ts": {
|
||||
"name": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"modules": {
|
||||
"Phaser": 1
|
||||
},
|
||||
"classes": {
|
||||
"TimeManager": 1
|
||||
},
|
||||
"fors": {},
|
||||
"namespaces": {}
|
||||
}
|
||||
},
|
||||
"modules": {
|
||||
"Phaser": {
|
||||
"name": "Phaser",
|
||||
"submodules": {},
|
||||
"classes": {
|
||||
"TimeManager": 1
|
||||
},
|
||||
"fors": {},
|
||||
"namespaces": {},
|
||||
"tag": "module",
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 13,
|
||||
"author": "Richard Davey <rich@photonstorm.com>",
|
||||
"copyright": "2013 Photon Storm Ltd.",
|
||||
"license": "https://github.com/photonstorm/phaser/blob/master/license.txt MIT License"
|
||||
}
|
||||
},
|
||||
"classes": {
|
||||
"TimeManager": {
|
||||
"name": "TimeManager",
|
||||
"shortname": "TimeManager",
|
||||
"classitems": [],
|
||||
"plugins": [],
|
||||
"extensions": [],
|
||||
"plugin_for": [],
|
||||
"extension_for": [],
|
||||
"module": "Phaser",
|
||||
"namespace": "",
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 13,
|
||||
"description": "This is the core internal game clock. It manages the elapsed time and calculation of delta values,\nused for game object motion and tweens.",
|
||||
"is_constructor": 1,
|
||||
"params": [
|
||||
{
|
||||
"name": "game",
|
||||
"description": "A reference to the currently running game.",
|
||||
"type": "Phaser.Game"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"classitems": [
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 34,
|
||||
"description": "A reference to the currently running Game.",
|
||||
"itemtype": "property",
|
||||
"name": "game",
|
||||
"type": "{Phaser.Game}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 41,
|
||||
"description": "The time at which the Game instance started.",
|
||||
"itemtype": "property",
|
||||
"name": "_started",
|
||||
"access": "private",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 49,
|
||||
"description": "Number of milliseconds elapsed since the last frame update.",
|
||||
"itemtype": "property",
|
||||
"name": "elapsed",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 57,
|
||||
"description": "Game time counter.",
|
||||
"itemtype": "property",
|
||||
"name": "time",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 65,
|
||||
"description": "Records how long the game has been paused for. Is reset each time the game pauses.",
|
||||
"itemtype": "property",
|
||||
"name": "pausedTime",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 73,
|
||||
"description": "The time right now.",
|
||||
"itemtype": "property",
|
||||
"name": "now",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 81,
|
||||
"description": "Elapsed time since the last frame.",
|
||||
"itemtype": "property",
|
||||
"name": "delta",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 89,
|
||||
"description": "The number of seconds that have elapsed since the game was started.",
|
||||
"itemtype": "method",
|
||||
"name": "totalElapsedSeconds",
|
||||
"return": {
|
||||
"description": "",
|
||||
"type": "Number"
|
||||
},
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 100,
|
||||
"description": "Frames per second.",
|
||||
"itemtype": "property",
|
||||
"name": "fps",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 108,
|
||||
"description": "The lowest rate the fps has dropped to.",
|
||||
"itemtype": "property",
|
||||
"name": "fpsMin",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 116,
|
||||
"description": "The highest rate the fps has reached (usually no higher than 60fps).",
|
||||
"itemtype": "property",
|
||||
"name": "fpsMax",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 124,
|
||||
"description": "The minimum amount of time the game has taken between two frames.",
|
||||
"itemtype": "property",
|
||||
"name": "msMin",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 132,
|
||||
"description": "The maximum amount of time the game has taken between two frames.",
|
||||
"itemtype": "property",
|
||||
"name": "msMax",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 140,
|
||||
"description": "The number of frames record in the last second.",
|
||||
"itemtype": "property",
|
||||
"name": "frames",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 148,
|
||||
"description": "The time (in ms) that the last second counter ticked over.",
|
||||
"itemtype": "property",
|
||||
"name": "_timeLastSecond",
|
||||
"access": "private",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 156,
|
||||
"description": "Update clock and calculate the fps.\nThis is called automatically by Game._raf",
|
||||
"itemtype": "method",
|
||||
"name": "update",
|
||||
"params": [
|
||||
{
|
||||
"name": "raf",
|
||||
"description": "The current timestamp, either performance.now or Date.now",
|
||||
"type": "Number"
|
||||
}
|
||||
],
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 192,
|
||||
"description": "Called when the game enters a paused state.",
|
||||
"itemtype": "method",
|
||||
"name": "gamePaused",
|
||||
"access": "private",
|
||||
"tagname": "",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 201,
|
||||
"description": "Called when the game resumes from a paused state.",
|
||||
"itemtype": "method",
|
||||
"name": "gameResumed",
|
||||
"access": "private",
|
||||
"tagname": "",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 211,
|
||||
"description": "Records how long the game was paused for in miliseconds.",
|
||||
"itemtype": "property",
|
||||
"name": "pauseDuration",
|
||||
"access": "public",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 219,
|
||||
"description": "The time the game started being paused.",
|
||||
"itemtype": "property",
|
||||
"name": "_pauseStarted",
|
||||
"access": "private",
|
||||
"tagname": "",
|
||||
"type": "{Number}",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 227,
|
||||
"description": "How long has passed since the given time.",
|
||||
"itemtype": "method",
|
||||
"name": "elapsedSince",
|
||||
"params": [
|
||||
{
|
||||
"name": "since",
|
||||
"description": "The time you want to measure against.",
|
||||
"type": "Number"
|
||||
}
|
||||
],
|
||||
"return": {
|
||||
"description": "The difference between the given time and now.",
|
||||
"type": "Number"
|
||||
},
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 239,
|
||||
"description": "How long has passed since the given time (in seconds).",
|
||||
"itemtype": "method",
|
||||
"name": "elapsedSecondsSince",
|
||||
"params": [
|
||||
{
|
||||
"name": "since",
|
||||
"description": "The time you want to measure (in seconds).",
|
||||
"type": "Number"
|
||||
}
|
||||
],
|
||||
"return": {
|
||||
"description": "Duration between given time and now (in seconds).",
|
||||
"type": "Number"
|
||||
},
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
},
|
||||
{
|
||||
"file": "..\\Phaser\\time\\TimeManager.ts",
|
||||
"line": 251,
|
||||
"description": "Resets the private _started value to now.",
|
||||
"itemtype": "method",
|
||||
"name": "reset",
|
||||
"class": "TimeManager",
|
||||
"module": "Phaser"
|
||||
}
|
||||
],
|
||||
"warnings": [
|
||||
{
|
||||
"message": "unknown tag: copyright",
|
||||
"line": " ..\\Phaser\\time\\TimeManager.ts:3"
|
||||
},
|
||||
{
|
||||
"message": "unknown tag: license",
|
||||
"line": " ..\\Phaser\\time\\TimeManager.ts:3"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,372 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>..\Phaser\time\TimeManager.ts - Phaser</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="../assets/css/logo.png" title="Phaser"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/TimeManager.html">TimeManager</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/Phaser.html">Phaser</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1 class="file-heading">File: ..\Phaser\time\TimeManager.ts</h1>
|
||||
|
||||
<div class="file">
|
||||
<pre class="code prettyprint linenums">
|
||||
/// <reference path="../_definitions.ts" />
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser
|
||||
*/
|
||||
module Phaser {
|
||||
|
||||
export class TimeManager {
|
||||
|
||||
/**
|
||||
* This is the core internal game clock. It manages the elapsed time and calculation of delta values,
|
||||
* used for game object motion and tweens.
|
||||
*
|
||||
* @class TimeManager
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
*/
|
||||
constructor(game: Phaser.Game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
this._started = 0;
|
||||
this._timeLastSecond = this._started;
|
||||
this.time = this._started;
|
||||
|
||||
this.game.onPause.add(this.gamePaused, this);
|
||||
this.game.onResume.add(this.gameResumed, this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference to the currently running Game.
|
||||
* @property game
|
||||
* @type {Phaser.Game}
|
||||
*/
|
||||
public game: Phaser.Game;
|
||||
|
||||
/**
|
||||
* The time at which the Game instance started.
|
||||
* @property _started
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
private _started: number;
|
||||
|
||||
/**
|
||||
* Number of milliseconds elapsed since the last frame update.
|
||||
* @property elapsed
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public elapsed: number = 0;
|
||||
|
||||
/**
|
||||
* Game time counter.
|
||||
* @property time
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public time: number = 0;
|
||||
|
||||
/**
|
||||
* Records how long the game has been paused for. Is reset each time the game pauses.
|
||||
* @property pausedTime
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public pausedTime: number = 0;
|
||||
|
||||
/**
|
||||
* The time right now.
|
||||
* @property now
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public now: number = 0;
|
||||
|
||||
/**
|
||||
* Elapsed time since the last frame.
|
||||
* @property delta
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public delta: number = 0;
|
||||
|
||||
/**
|
||||
* The number of seconds that have elapsed since the game was started.
|
||||
* @method totalElapsedSeconds
|
||||
* @return {Number}
|
||||
*/
|
||||
public get totalElapsedSeconds(): number {
|
||||
|
||||
return (this.now - this._started) * 0.001;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Frames per second.
|
||||
* @property fps
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public fps: number = 0;
|
||||
|
||||
/**
|
||||
* The lowest rate the fps has dropped to.
|
||||
* @property fpsMin
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public fpsMin: number = 1000;
|
||||
|
||||
/**
|
||||
* The highest rate the fps has reached (usually no higher than 60fps).
|
||||
* @property fpsMax
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public fpsMax: number = 0;
|
||||
|
||||
/**
|
||||
* The minimum amount of time the game has taken between two frames.
|
||||
* @property msMin
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public msMin: number = 1000;
|
||||
|
||||
/**
|
||||
* The maximum amount of time the game has taken between two frames.
|
||||
* @property msMax
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public msMax: number = 0;
|
||||
|
||||
/**
|
||||
* The number of frames record in the last second.
|
||||
* @property frames
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public frames: number = 0;
|
||||
|
||||
/**
|
||||
* The time (in ms) that the last second counter ticked over.
|
||||
* @property _timeLastSecond
|
||||
* @private
|
||||
* @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.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
|
||||
|
||||
// Paused?
|
||||
if (this.game.paused)
|
||||
{
|
||||
this.pausedTime = this.now - this._pauseStarted;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game enters a paused state.
|
||||
* @method gamePaused
|
||||
* @private
|
||||
*/
|
||||
private gamePaused() {
|
||||
this._pauseStarted = this.now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game resumes from a paused state.
|
||||
* @method gameResumed
|
||||
* @private
|
||||
*/
|
||||
private gameResumed() {
|
||||
// Level out the delta timer to avoid spikes
|
||||
this.pauseDuration = this.pausedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records how long the game was paused for in miliseconds.
|
||||
* @property pauseDuration
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
public pauseDuration: number = 0;
|
||||
|
||||
/**
|
||||
* The time the game started being paused.
|
||||
* @property _pauseStarted
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
private _pauseStarted: number = 0;
|
||||
|
||||
/**
|
||||
* How long has passed since the given time.
|
||||
* @method elapsedSince
|
||||
* @param {Number} since The time you want to measure against.
|
||||
* @return {Number} The difference between the given time and now.
|
||||
*/
|
||||
public elapsedSince(since: number): number {
|
||||
|
||||
return this.now - since;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* How long has passed since the given 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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the private _started value to now.
|
||||
* @method reset
|
||||
*/
|
||||
public reset() {
|
||||
|
||||
this._started = this.now;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,124 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="./assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="./assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="./assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="./assets/css/logo.png" title="Phaser"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="./classes/TimeManager.html">TimeManager</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="./modules/Phaser.html">Phaser</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<div class="apidocs">
|
||||
<div id="docs-main" class="content">
|
||||
<p>
|
||||
Browse to a module or class using the sidebar to view its API documentation.
|
||||
</p>
|
||||
|
||||
<h2>Keyboard Shortcuts</h2>
|
||||
|
||||
<ul>
|
||||
<li><p>Press <kbd>s</kbd> to focus the API search box.</p></li>
|
||||
|
||||
<li><p>Use <kbd>Up</kbd> and <kbd>Down</kbd> to select classes, modules, and search results.</p></li>
|
||||
|
||||
<li class="mac-only"><p>With the API search box or sidebar focused, use <kbd><span class="cmd">⌘</span>-Left</kbd> or <kbd><span class="cmd">⌘</span>-Right</kbd> to switch sidebar tabs.</p></li>
|
||||
|
||||
<li class="pc-only"><p>With the API search box or sidebar focused, use <kbd>Ctrl+Left</kbd> and <kbd>Ctrl+Right</kbd> to switch sidebar tabs.</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="./assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="./assets/js/yui-prettify.js"></script>
|
||||
<script src="./assets/../api.js"></script>
|
||||
<script src="./assets/js/api-filter.js"></script>
|
||||
<script src="./assets/js/api-list.js"></script>
|
||||
<script src="./assets/js/api-search.js"></script>
|
||||
<script src="./assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,147 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser - Phaser</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="../assets/css/logo.png" title="Phaser"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/TimeManager.html">TimeManager</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/Phaser.html">Phaser</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>Phaser Module</h1>
|
||||
<div class="box clearfix meta">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/.._Phaser_time_TimeManager.ts.html#l13"><code>..\Phaser\time\TimeManager.ts:13</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="yui3-g">
|
||||
<div class="yui3-u-1-2">
|
||||
|
||||
<p>This module provides the following classes:</p>
|
||||
|
||||
<ul class="module-classes">
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/TimeManager.html">
|
||||
TimeManager
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="yui3-u-1-2">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,37 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>phaser - hello world</title>
|
||||
<script src="phaser-min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('logo', 'logo.png');
|
||||
|
||||
}
|
||||
|
||||
var logo;
|
||||
|
||||
function create() {
|
||||
|
||||
logo = game.add.sprite(0, 0, 'logo');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 204 KiB |
@@ -1 +0,0 @@
|
||||
yuidoc -c ../Phaser/yuidoc.json -o API/ -t yuidoc-theme-dana -e .ts ../Phaser/time
|
||||
@@ -1 +0,0 @@
|
||||
yuidoc -n -e .ts --server 3000 ../Phaser/time
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser
|
||||
*/
|
||||
|
||||
/**
|
||||
* The class constructor
|
||||
*
|
||||
* @class Name
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A reference to the currently running Game.
|
||||
* @property game
|
||||
* @type {Phaser.Game}
|
||||
*/
|
||||
public game: Phaser.Game;
|
||||
|
||||
/**
|
||||
* My method description. Like other pieces of your comment blocks,
|
||||
* this can span multiple lines.
|
||||
*
|
||||
* @method methodName
|
||||
* @param {String} foo Argument 1
|
||||
* @param {Object} config A config object
|
||||
* @param {String} config.name The name on the config object
|
||||
* @param {Function} config.callback A callback function on the config object
|
||||
* @param {Boolean} [extra=false] Do extra, optional work
|
||||
* @return {Boolean} Returns true on success
|
||||
*/
|
||||
|
||||
/**
|
||||
* My property description. Like other pieces of your comment blocks,
|
||||
* this can span multiple lines.
|
||||
*
|
||||
* @property propertyName
|
||||
* @public
|
||||
* @type {Object}
|
||||
* @default "foo"
|
||||
*/
|
||||
|
||||
@param {Type} Name Description
|
||||
Object, Array, String, Boolean, Number, Mixed, MyType
|
||||
|
||||
@@ -1,80 +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
|
||||
}
|
||||
},
|
||||
},
|
||||
copy: {
|
||||
main: {
|
||||
files: [{
|
||||
src: 'build/phaser.js',
|
||||
dest: 'Tests/phaser.js'
|
||||
}]
|
||||
},
|
||||
mainAmd: {
|
||||
files: [{
|
||||
src: 'build/phaser.js',
|
||||
dest: 'build/phaser.amd.js'
|
||||
}],
|
||||
options: {
|
||||
processContent: wrapPhaserInUmd
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
files: '**/*.ts',
|
||||
tasks: ['typescript', 'copy']
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['typescript', 'copy', 'watch']);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
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/geom/Line.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,81 +1,184 @@
|
||||

|
||||

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

|
||||
|
||||
|
||||
Help Test 2.0
|
||||
-------------
|
||||
|
||||
September 15th 2013
|
||||
Originally we were going to release Phaser 1.2 next, however after working solidly on it for a while we realise it's such a large and API breaking/changing update that we need to step-up the version to 2.0 to avoid any possible confusion. Progress has been rapid and we'd love for you to help test it. You'll notice a new [1.2 branch](https://github.com/photonstorm/phaser/tree/1.2) on github - we're going to keep the branch name as 1.2 as we're nearly at the end of development now, but please understand this is what will actually be the 2.0 release.
|
||||
|
||||
Version 1.0.1 and 1.0.2 have been tagged and released. See the Change Log for full details. As 1.0 is so fresh please expect small minor updates every few days, but we will be sure to tag them.
|
||||
Please help test out 1.2/2.0 as much as you can. It features the brand new Pixi 1.5 internally as well as nearly complete integration with p2.js for all physics (dropping ArcadePhysics entirely). New versions are being pushed several times a day, so be sure to update and pull often. Don't expect to just run old games right under it yet, but please do check out the new tests, experiment and poke it around as much as you can - thank you!
|
||||
|
||||
September 13th 2013
|
||||
|
||||
We're very pleased to have finally shipped the 1.0 release of Phaser. This version represents many months of hard work, feedback and refactoring based on the previous 0.5 through to 0.97 releases. You can see the full gory details in our change log.
|
||||
Getting Started Guides
|
||||
----------------------
|
||||
|
||||
Sorry but the jsdocs aren't yet finished, but it is now our priority (along with bug fixing). If you run into problems, or just want to chat about how to best use Phaser then please do join our forums. It's an active and inspiring community.
|
||||
We have a new [Getting Started Guide](http://phaser.io/getting-started-js.php) which covers all you need to begin developing games with Phaser. From setting up a web server to picking an IDE. If you're new to HTML5 game development, or are coming from another language like AS3, then we recommend starting there.
|
||||
|
||||
Now 1.0 is released we'll focus on getting the docs and more examples completed. Both of these will be pushed to the master repo on a regular basis. We will tag new releases of Phaser, but changes to the examples or docs won't be release tagged.
|
||||
There is a comprehensive [How to Learn Phaser](http://gamedevelopment.tutsplus.com/articles/how-to-learn-the-phaser-html5-game-engine--gamedev-13643) guide on the GameDevTuts+ site which is a great place to learn where to find tutorials, examples and support.
|
||||
|
||||
Thank you to everyone who has encouraged us along the way. To those of you who worked with Phaser during its various incarnations, and who released full games with it despite there being zero API documentation available: you are our heroes. It's your kind words and enthusiasm, as well as our commercial need for Phaser that has kept us going. Now we're at 1.0 we will continue releasing rapidly and jumping on patches and bug reports quickly.
|
||||
There is also an [un-official Getting Started Guide](http://www.antonoffplus.com/coding-an-html5-game-for-30-minutes-or-an-introduction-to-the-phaser-framework).
|
||||
|
||||
Phaser is everything we ever wanted from an HTML5 game framework. It will power all our client work going forward and we look forward to you joining us on this journey.
|
||||
|
||||

|
||||
|
||||
Change Log
|
||||
----------
|
||||
|
||||
Version 1.0.2
|
||||
Version 1.1.6 - "Shienar" - 24th February 2014 (amended 21:34 GMT)
|
||||
|
||||
* Added optional parameter to Animation.stop: resetFrame. If true the animation will be stopped and then the current frame reset to the first frame in the animation.
|
||||
New Examples:
|
||||
|
||||
Version 1.0.1
|
||||
* Added lovely new little mini golf game by jpcloud.
|
||||
|
||||
|
||||
Updates:
|
||||
|
||||
* Loader can now load JSON files natively (thanks lucas)
|
||||
* TilemapParser now errors if the tileset isn't the right size
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Physics.processRebound now takes Body direction into account, helps with body-body collision bounces (thanks ram64)
|
||||
* Fixed the Example / physics / mass velocity test.
|
||||
* Updated Physics.Body.applyDamping so that velocity is reduced down to zero properly (thanks caezs)
|
||||
* ArcadePhysics.collideSpriteVsTilemapLayer wouldn't call the process or collide callbacks if only 1 tile was involved in the check (thanks mandarinx)
|
||||
* Lots of documentation fixes (thanks nhowell)
|
||||
* Fix for PixiPatch so it renders masks again (thanks georgios)
|
||||
* Modified ArcadePhysics.intersects so it returns a value as well as asigns (thanks bunnyhero)
|
||||
* Lots of TypeScript defs fixes (thanks clark)
|
||||
|
||||
|
||||
See the full Change Log for all the 1.1.4 and 1.1.5 updates and API changes (as there were a lot of them!)
|
||||
|
||||
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
|
||||
|
||||
|
||||
How to Build
|
||||
------------
|
||||
|
||||
We provide a fully compiled version of Phaser in the `build` directory, in both plain and minified formats.
|
||||
|
||||
We also provide a Grunt script that will build Phaser from source along with all the examples.
|
||||
|
||||
Run `grunt` in the phaser folder for a list of command-line options.
|
||||
|
||||
|
||||
Koding
|
||||
------
|
||||
|
||||
You can [][koding] and then start editing and previewing code right away using their web based VM development system.
|
||||
|
||||
|
||||
Bower
|
||||
-----
|
||||
|
||||
If you use bowser you can install phaser with:
|
||||
|
||||
`bower install phaser`
|
||||
|
||||
Nice and easy :)
|
||||
|
||||

|
||||
|
||||
|
||||
CDNJS
|
||||
-----
|
||||
|
||||
Thanks to a community member Phaser is now available on [CDNJS](http://cdnjs.com). You can include the following in your html:
|
||||
|
||||
`http://cdnjs.cloudflare.com/ajax/libs/phaser/1.1.5/phaser.min.js`
|
||||
|
||||
Or if you prefer you can leave the protocol off, so it works via http and https:
|
||||
|
||||
`//cdnjs.cloudflare.com/ajax/libs/phaser/1.1.5/phaser.min.js`
|
||||
|
||||
* Added checks into every Group function to ensure that the Group has children before running them.
|
||||
* Added optional flag to Group.create which allows you to set the default exists state of the Sprites.
|
||||
* Sprite.animation.stop no longer needs an animation name parameter, will default to stopping the current animation.
|
||||
* Fixed the license in package.json
|
||||
* Fixed a logic bug in the separateTileX function that would sometimes cause tunneling of big sprites through small tiles.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Games created with Phaser require a modern web browser that supports the canvas tag. This includes Internet Explorer 9+, Firefox, Chrome, Safari and Opera. It also works on mobile web browsers including stock Android 2.x browser and above and iOS5 Mobile Safari and above.
|
||||
|
||||
For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/). We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you.
|
||||
For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/) using the provided TypeScript definitions file. We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you.
|
||||
|
||||
Phaser is 321 KB minified and 72 KB gzipped.
|
||||
|
||||
|
||||
Learn By Example
|
||||
----------------
|
||||
|
||||
Phaser comes with an ever growing suite of Examples. Personally I feel that we learn better by looking at small refined code examples, so we created over 200 of them and create new ones to test every new feature added. Inside the `examples` folder you'll find the current set. If you write a particularly good example then please send it to us.
|
||||
|
||||
The examples need to be run through a local web server (in order to avoid file access permission errors from your browser). You can use your own web server, or start the included web server using grunt.
|
||||
|
||||
Using a locally installed web server browse to the examples folder:
|
||||
|
||||
examples/index.html
|
||||
|
||||
Alternatively in order to start the included web server, after you've cloned the repo, run `npm install` to install all dependencies, then `grunt connect` to start a local server. After running this command you should be able to access your local webserver at `http://127.0.0.1:8000`. Then browse to the examples folder: `http://127.0.0.1:8000/examples/index.html`
|
||||
|
||||
There is a new 'Side View' example viewer as well. This loads all the examples into a left-hand frame for faster navigation.
|
||||
|
||||
You can also browse all [Phaser Examples](http://gametest.mobi/phaser/) online.
|
||||
|
||||
Phaser is 275 KB minified and 62 KB gzipped.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
**WebGL & Canvas**
|
||||
|
||||
Phaser uses both a Canvas and WebGL renderer internally and can automatically swap between them based on browser support. This allows for lightning fast rendering across Desktop and Mobile. Phaser uses and contributes towards the excellent Pixi.js library for rendering.
|
||||
Phaser uses both a Canvas and WebGL renderer internally and can automatically swap between them based on browser support. This allows for lightning fast rendering across Desktop and Mobile. When running under WebGL Phaser now supports shaders, allowing for some incredible in-game effects. Phaser uses and contributes towards the excellent Pixi.js library for rendering.
|
||||
|
||||
**Preloader**
|
||||
|
||||
We've made the loading of assets as simple as one line of code. Images, Sounds, Sprite Sheets, Tilemaps, JSON data, XML - all parsed and handled automatically, ready for use in game and stored in a global Cache for Sprites to share.
|
||||
We've made the loading of assets as simple as one line of code. Images, Sounds, Sprite Sheets, Tilemaps, JSON data, XML and JavaScrtip files - all parsed and handled automatically, ready for use in game and stored in a global Cache for Sprites to share.
|
||||
|
||||
**Physics**
|
||||
|
||||
Phaser ships with our Arcade Physics system. An extremely light-weight AABB physics library perfect for low-powered devices and fast collision response. Control velocity, acceleration, bounce, drag and full collision and separation control.
|
||||
Phaser ships with our Arcade Physics system. A SAT based collision and physics library perfect for low-powered devices and fast collision response. Control velocity, acceleration, bounce, damping and full collision and separation control. As of version 1.1.4 we now support rectangles, circles and polygon collision with full rotation.
|
||||
|
||||
**Sprites**
|
||||
|
||||
@@ -128,89 +231,84 @@ We use Phaser every day on our many client projects. As a result it's constantly
|
||||
|
||||
**Battle Tested**
|
||||
|
||||
Although Phaser 1.0 is a brand new release it is born from years of experience building some of the biggest HTML5 games out there. We're not saying it is 100% bug free, but we use it for our client work every day, so issues get resolved <em>fast</em> and we stay on-top of the changing browser landscape.
|
||||
Although Phaser 1.0 is a brand new release it is born from years of experience building some of the biggest mobile HTML5 games out there. We're not saying it is 100% bug free, but we use it for our client work every day, so issues get resolved <em>fast</em> and we stay on-top of the changing browser landscape.
|
||||
|
||||

|
||||

|
||||
|
||||
Known Issues
|
||||
------------
|
||||
|
||||
* The TypeScript definition file isn't yet complete.
|
||||
* The JSDOCS are not yet complete.
|
||||
Road Map
|
||||
--------
|
||||
|
||||
Future Plans
|
||||
------------
|
||||
Here is what's on our road map for the coming months:
|
||||
|
||||
The following list is not exhaustive and is subject to change:
|
||||
March 2014 will see Phaser 2.0 ("Aes Sedai") Released. The new features and fixes already implemented are vast, and include:
|
||||
|
||||
* Integrate Advanced Physics system.
|
||||
* Integrate Advanced Particle system.
|
||||
* Better sound controls and audio effects.
|
||||
* Google Play Game Services.
|
||||
* Ability to layer another DOM object and have it controlled by the game.
|
||||
* More GUI components: checkbox, radio button, window, etc.
|
||||
* Tilemap: more advanced Tiled support and support for DAME tilemaps.
|
||||
* Joypad support.
|
||||
* Gestures input class.
|
||||
* Update to Pixi 1.5 - this newly released build has lots of internal changes and new features we want to take advantage of.
|
||||
* Integration of the p2.js physics system and removal of the old ArcadePhysics. Full body dynamics are go!
|
||||
* Better CocoonJS packaging features (screencanvas, audio checks, etc)
|
||||
* Fixed width bitmap font support, plus enhanced Bitmap font rendering.
|
||||
* Significantly optimised render and update loops. We're seeing significant fps improvements across the board.
|
||||
* Literally hundreds of bug fixes across all core classes.
|
||||
|
||||
Right now our main focus is on documentation.
|
||||
Beyond version 2.0 here are some of the features planned for the future:
|
||||
|
||||
Test Suite
|
||||
----------
|
||||
Version 2.1 ("Shienar")
|
||||
|
||||
Phaser comes with an ever growing Test Suite. Personally we learn better by looking at small refined code examples, so we create lots of them to test each new feature we add. Inside the Tests folder you'll find the current set. If you write a particularly good test then please send it to us.
|
||||
* Enhance the State Management, so you can perform non-destructive State swaps and persistence.
|
||||
* A more advanced Particle system, one that can render to a single canvas (rather than spawn hundreds of Sprites), more advanced effects, etc.
|
||||
* Ability to control DOM elements from the core game and layer them into the game.
|
||||
* Touch Gestures.
|
||||
* Support for parallel asset loading.
|
||||
|
||||
The tests need running through a local web server (to avoid file access permission errors from your browser).
|
||||
Version 2.2 ("Tarabon")
|
||||
|
||||
Make sure you can browse to the Tests folder via your web server. If you've got php installed then launch:
|
||||
* Comprehensive testing across Firefox OS devices, CocoonJS and Ejecta.
|
||||
* Integration with third party services like Google Play Game Services and Amazon JS SDK.
|
||||
* Flash CC HTML5 export integration.
|
||||
* Massively enhance the audio side of Phaser. Take more advantage of Web Audio: echo effects, positional sound, etc.
|
||||
|
||||
examples/index.php
|
||||
Beyond version 2.2
|
||||
|
||||
Right now the Test Suite requires PHP, but we will remove this requirement soon.
|
||||
* Test out packaging with Node-webkit.
|
||||
* Game parameters stored in Google Docs.
|
||||
* Look at HiDPI Canvas settings.
|
||||
* Multiple Camera support.
|
||||
* DragonBones support.
|
||||
|
||||
You can also browse the [Phaser Test Suite](http://gametest.mobi/phaser/) online.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Phaser is in early stages and although we've still got a lot to add to it, we wanted to just get it out there and share it with the world.
|
||||
We now have a full [Contributors Guide][contribute] which goes into the process in more detail, but here are the headlines:
|
||||
|
||||
If you find a bug (highly likely!) then please report it on github.
|
||||
- If you find a bug then please report it on [GitHub Issues][issues] or our [Support Forum][forum].
|
||||
|
||||
If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you.
|
||||
- If you have a feature request, or have written a game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you! Either post to our [forum][forum] or email: rich@photonstorm.com
|
||||
|
||||
- If you issue a Pull Request for Phaser, please only do so againt the `dev` branch and *not* against the `master` branch.
|
||||
|
||||
- Before submitting a Pull Request please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, first install it by running `npm install jshint`, then test your code by running `jshint src`. This isn't a strict requirement and we are happy to receive Pull Requests that haven't been JSHinted, so don't let it put you off contributing, but do know that we'll reformat your source before going live with it.
|
||||
|
||||
You can do this on the Phaser board that is part of the [HTML5 Game Devs forum](http://www.html5gamedevs.com/forum/14-phaser/) or email: rich@photonstorm.com
|
||||
|
||||
Bugs?
|
||||
-----
|
||||
|
||||
Please add them to the [Issue Tracker][1] with as much info as possible.
|
||||
Please add them to the [Issue Tracker][issues] with as much info as possible, especially source code demonstrating the issue.
|
||||
|
||||

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

|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
The MIT License (MIT)
|
||||
Phaser is released under the [MIT License](http://opensource.org/licenses/MIT).
|
||||
|
||||
Copyright (c) 2013 Richard Davey, Photon Storm Ltd.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
[1]: https://github.com/photonstorm/phaser/issues
|
||||
[issues]: https://github.com/photonstorm/phaser/issues
|
||||
[contribute]: https://github.com/photonstorm/phaser/blob/master/CONTRIBUTING.md
|
||||
[phaser]: https://github.com/photonstorm/phaser
|
||||
[forum]: http://www.html5gamedevs.com/forum/14-phaser/
|
||||
[koding]: https://koding.com/Teamwork?import=https://github.com/photonstorm/phaser/archive/master.zip&c=git1
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "phaser",
|
||||
"version": "1.1.6",
|
||||
"homepage": "http://phaser.io",
|
||||
"authors": [
|
||||
"photonstorm <rich@photonstorm.com>"
|
||||
],
|
||||
"description": "A fun, free and fast 2D game framework for making HTML5 games for desktop and mobile, supporting Canvas and WebGL.",
|
||||
"main": "build/phaser.js",
|
||||
"keywords": [
|
||||
"html5",
|
||||
"game",
|
||||
"games",
|
||||
"framework",
|
||||
"canvas",
|
||||
"WebGL",
|
||||
"tilemaps",
|
||||
"physics",
|
||||
"sprites",
|
||||
"fonts",
|
||||
"images",
|
||||
"audio",
|
||||
"Web",
|
||||
"Audio",
|
||||
"touch",
|
||||
"input",
|
||||
"mobile"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
<a href="http://yui.2clics.net/">Minify it</a><br />
|
||||
|
||||
<textarea style="width: 800px; height: 800px">
|
||||
<?php
|
||||
|
||||
$js = file('../examples/js.php');
|
||||
// NOTE: This script is deprecated. The build process is managed by grunt now.
|
||||
// Keeping this file here for those that I know use it, but if you're trying to build fresh, use grunt.
|
||||
|
||||
date_default_timezone_set('Europe/London');
|
||||
|
||||
// Get the version number
|
||||
// VERSION: '1.0.5',
|
||||
$vf = file_get_contents(dirname(__FILE__) . '/../src/Phaser.js');
|
||||
$version = substr($vf, strpos($vf, 'VERSION: ') + 10, 5);
|
||||
$buildLog = "Building version $version \n\n";
|
||||
$header = "";
|
||||
|
||||
$js = file(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.php');
|
||||
$output = "";
|
||||
|
||||
for ($i = 0; $i < count($js); $i++)
|
||||
@@ -14,26 +22,61 @@
|
||||
if (strpos($line, '<script') !== false)
|
||||
{
|
||||
$line = str_replace('<script src="', '', $line);
|
||||
$line = str_replace('"></script>', '', $line);
|
||||
$line = dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('"></script>', '', $line);
|
||||
$filename = substr($line, strrpos($line, '/') + 1);
|
||||
|
||||
echo $line . "\n";
|
||||
$buildLog .= $line . "\n";
|
||||
// echo $filename . "\n";
|
||||
|
||||
// Read the file in
|
||||
$source = file_get_contents($line);
|
||||
|
||||
if ($i == 4)
|
||||
if (file_exists($line))
|
||||
{
|
||||
// Built at: {buildDate}
|
||||
$source = str_replace('{buildDate}', date('r'), $source);
|
||||
}
|
||||
$source = file_get_contents($line);
|
||||
|
||||
$output .= $source . "\n";
|
||||
if ($filename == 'Intro.js')
|
||||
{
|
||||
// Built at: {buildDate}
|
||||
$source = str_replace('{buildDate}', date('r'), $source);
|
||||
|
||||
// {version}
|
||||
$source = str_replace('{version}', $version, $source);
|
||||
|
||||
// Set the header
|
||||
$header = $source;
|
||||
}
|
||||
else
|
||||
{
|
||||
$output .= $source . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//echo $output;
|
||||
// Create a UMD wrapper, to allow Phaser to be exposed to AMD, Node and Browsers
|
||||
$template = <<<EOT
|
||||
%s(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
} else {
|
||||
root.Phaser = factory();
|
||||
}
|
||||
}(this, function (b) {
|
||||
%s
|
||||
return Phaser;
|
||||
}));
|
||||
EOT;
|
||||
|
||||
file_put_contents('phaser.js', $output);
|
||||
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phaser.js', sprintf($template, $header, $output));
|
||||
|
||||
if(php_sapi_name() == 'cli' || empty($_SERVER['REMOTE_ADDR'])) {
|
||||
echo "\ndone\n\n";
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<a href="http://yui.2clics.net/">Minify it</a><br />
|
||||
|
||||
<textarea style="width: 800px; height: 800px">
|
||||
<?php echo $buildLog; ?>
|
||||
</textarea>
|
||||
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
// All JS files in build order.
|
||||
// Much easier for debugging re: line numbers
|
||||
if (!isset($path))
|
||||
{
|
||||
$path = '..';
|
||||
}
|
||||
|
||||
echo <<<EOL
|
||||
|
||||
<script src="$path/src/Intro.js"></script>
|
||||
<script src="$path/src/pixi/Pixi.js"></script>
|
||||
<script src="$path/src/Phaser.js"></script>
|
||||
<script src="$path/src/utils/Utils.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/core/Matrix.js"></script>
|
||||
<script src="$path/src/pixi/core/Point.js"></script>
|
||||
<script src="$path/src/pixi/core/Rectangle.js"></script>
|
||||
<script src="$path/src/pixi/core/Polygon.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="$path/src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="$path/src/pixi/display/Sprite.js"></script>
|
||||
<script src="$path/src/pixi/display/Stage.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/extras/CustomRenderable.js"></script>
|
||||
<script src="$path/src/pixi/extras/Strip.js"></script>
|
||||
<script src="$path/src/pixi/extras/Rope.js"></script>
|
||||
<script src="$path/src/pixi/extras/TilingSprite.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/filters/AbstractFilter.js"></script>
|
||||
<script src="$path/src/pixi/filters/FilterBlock.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/primitives/Graphics.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
<script src="$path/src/pixi/renderers/canvas/CanvasRenderer.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/renderers/webgl/PixiShader.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/PrimitiveShader.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/StripShader.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLBatch.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLFilterManager.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLGraphics.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLRenderer.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
|
||||
<script src="$path/src/pixi/renderers/webgl/WebGLShaders.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/text/BitmapText.js"></script>
|
||||
<script src="$path/src/pixi/text/Text.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/textures/BaseTexture.js"></script>
|
||||
<script src="$path/src/pixi/textures/Texture.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/utils/EventTarget.js"></script>
|
||||
<script src="$path/src/pixi/utils/Polyk.js"></script>
|
||||
|
||||
<script src="$path/src/core/Camera.js"></script>
|
||||
<script src="$path/src/core/State.js"></script>
|
||||
<script src="$path/src/core/StateManager.js"></script>
|
||||
<script src="$path/src/core/LinkedList.js"></script>
|
||||
<script src="$path/src/core/Signal.js"></script>
|
||||
<script src="$path/src/core/SignalBinding.js"></script>
|
||||
<script src="$path/src/core/Filter.js"></script>
|
||||
<script src="$path/src/core/Plugin.js"></script>
|
||||
<script src="$path/src/core/PluginManager.js"></script>
|
||||
<script src="$path/src/core/Stage.js"></script>
|
||||
<script src="$path/src/core/Group.js"></script>
|
||||
<script src="$path/src/core/World.js"></script>
|
||||
<script src="$path/src/core/Game.js"></script>
|
||||
|
||||
<script src="$path/src/input/Input.js"></script>
|
||||
<script src="$path/src/input/Key.js"></script>
|
||||
<script src="$path/src/input/Keyboard.js"></script>
|
||||
<script src="$path/src/input/Mouse.js"></script>
|
||||
<script src="$path/src/input/MSPointer.js"></script>
|
||||
<script src="$path/src/input/Pointer.js"></script>
|
||||
<script src="$path/src/input/Touch.js"></script>
|
||||
<script src="$path/src/input/Gamepad.js"></script>
|
||||
<script src="$path/src/input/SinglePad.js"></script>
|
||||
<script src="$path/src/input/GamepadButton.js"></script>
|
||||
<script src="$path/src/input/InputHandler.js"></script>
|
||||
|
||||
<script src="$path/src/gameobjects/Events.js"></script>
|
||||
<script src="$path/src/gameobjects/GameObjectFactory.js"></script>
|
||||
<script src="$path/src/gameobjects/BitmapData.js"></script>
|
||||
<script src="$path/src/gameobjects/Sprite.js"></script>
|
||||
<script src="$path/src/gameobjects/TileSprite.js"></script>
|
||||
<script src="$path/src/gameobjects/Text.js"></script>
|
||||
<script src="$path/src/gameobjects/BitmapText.js"></script>
|
||||
<script src="$path/src/gameobjects/Button.js"></script>
|
||||
<script src="$path/src/gameobjects/Graphics.js"></script>
|
||||
<script src="$path/src/gameobjects/RenderTexture.js"></script>
|
||||
|
||||
<script src="$path/src/system/Canvas.js"></script>
|
||||
<script src="$path/src/system/StageScaleMode.js"></script>
|
||||
<script src="$path/src/system/Device.js"></script>
|
||||
<script src="$path/src/system/RequestAnimationFrame.js"></script>
|
||||
|
||||
<script src="$path/src/math/RandomDataGenerator.js"></script>
|
||||
<script src="$path/src/math/Math.js"></script>
|
||||
<script src="$path/src/math/QuadTree.js"></script>
|
||||
|
||||
<script src="$path/src/geom/Circle.js"></script>
|
||||
<script src="$path/src/geom/Point.js"></script>
|
||||
<script src="$path/src/geom/Rectangle.js"></script>
|
||||
<script src="$path/src/geom/Line.js"></script>
|
||||
|
||||
<script src="$path/src/net/Net.js"></script>
|
||||
|
||||
<script src="$path/src/tween/TweenManager.js"></script>
|
||||
<script src="$path/src/tween/Tween.js"></script>
|
||||
<script src="$path/src/tween/Easing.js"></script>
|
||||
|
||||
<script src="$path/src/time/Time.js"></script>
|
||||
<script src="$path/src/time/Timer.js"></script>
|
||||
<script src="$path/src/time/TimerEvent.js"></script>
|
||||
|
||||
<script src="$path/src/animation/AnimationManager.js"></script>
|
||||
<script src="$path/src/animation/Animation.js"></script>
|
||||
<script src="$path/src/animation/Frame.js"></script>
|
||||
<script src="$path/src/animation/FrameData.js"></script>
|
||||
<script src="$path/src/animation/AnimationParser.js"></script>
|
||||
|
||||
<script src="$path/src/loader/Cache.js"></script>
|
||||
<script src="$path/src/loader/Loader.js"></script>
|
||||
<script src="$path/src/loader/LoaderParser.js"></script>
|
||||
|
||||
<script src="$path/src/sound/Sound.js"></script>
|
||||
<script src="$path/src/sound/SoundManager.js"></script>
|
||||
|
||||
<script src="$path/src/utils/Debug.js"></script>
|
||||
<script src="$path/src/utils/Color.js"></script>
|
||||
|
||||
<script src="$path/src/physics/arcade/SAT.js"></script>
|
||||
<script src="$path/src/physics/arcade/ArcadePhysics.js"></script>
|
||||
<script src="$path/src/physics/arcade/Body.js"></script>
|
||||
|
||||
<script src="$path/src/particles/Particles.js"></script>
|
||||
<script src="$path/src/particles/arcade/ArcadeParticles.js"></script>
|
||||
<script src="$path/src/particles/arcade/Emitter.js"></script>
|
||||
|
||||
<script src="$path/src/tilemap/Tile.js"></script>
|
||||
<script src="$path/src/tilemap/Tilemap.js"></script>
|
||||
<script src="$path/src/tilemap/TilemapLayer.js"></script>
|
||||
<script src="$path/src/tilemap/TilemapParser.js"></script>
|
||||
<script src="$path/src/tilemap/Tileset.js"></script>
|
||||
|
||||
<script src="$path/src/PixiPatch.js"></script>
|
||||
EOL;
|
||||
?>
|
||||
@@ -1,7 +1,529 @@
|
||||
Change Log
|
||||
----------
|
||||
==========
|
||||
|
||||
V0.9.8
|
||||
Version 1.1.5 - "Saldaea" - 12th February 2014
|
||||
----------------------------------------------
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Explicitly paused Timer continues if you un-focus and focus the browser window (thanks georgiee)
|
||||
* Added TimerEvent.pendingDelete and checks in Timer.update, so that removing an event in a callback no longer throws an exception (thanks georgiee)
|
||||
* Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy)
|
||||
* Added SAT.js to TypeScript definition. Now compiles properly.
|
||||
* Added missing Line.js to the Grunt file.
|
||||
* Tilemap#paste diffX and diffY equations changed, fixed issue #393 (thanks brejep)
|
||||
* Added missing return value in Body.hitLeft and hitRight, fixes issue #398 (thanks ram64).
|
||||
* Fixed easing tween example case. Issue #379 (thanks wesleywerner)
|
||||
* Removed SAT.js UMD wrapped, fixes issue #361 (thanks luizbills)
|
||||
* Removed inContact check from Body.separate.
|
||||
* Fixed Tilemap docs (wrongly pointed to Tileset methods)
|
||||
|
||||
|
||||
Version 1.1.4 - "Kandor" - February 5th 2014
|
||||
--------------------------------------------
|
||||
|
||||
Significant API changes:
|
||||
|
||||
* Loader.tileset has been removed as it's no longer required, this was as part of the Tilemap system overhaul.
|
||||
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
|
||||
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
|
||||
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.
|
||||
* Button.forceOut default value has changed from true to false, so Buttons will revert to an Up state (if set) when pressed and released.
|
||||
* The way the collision process callback works has changed significantly and now works as originally intended.
|
||||
* The World level quadtree is no longer created, they are now built and ripped down each time you collide a Group, this helps collision accuracy.
|
||||
* A SAT system has been integrated for Body collision and separation.
|
||||
* Bodies are no longer added to a world quadtree, so have had all of their quadtree properties removed such as skipQuadtree, quadTreeIndex, etc.
|
||||
* Body.drag has been removed. Please use the new Body.linearDamping value instead (which is a number value, not a Point object)
|
||||
* Body.embedded and Body.wasTouching have been removed as they are no longer required.
|
||||
* Body.customSeparateX/Y have been removed as you should now use Body.customSeparateCallback.
|
||||
* Body.maxVelocity defaults have been removed from 10,000 to 2000.
|
||||
* Body.customSeparateCallback allows you to set your own callback when two Bodies need to separate rather than using the built-in method.
|
||||
* Body.collideCallback allows you to set a callback that is fired whenever the Body is hit on any of its active faces.
|
||||
* Body.allowCollision has been renamed to Body.checkCollision.
|
||||
* Body.rebound is a boolean that controls if a body will exchange velocity on collision. Set to false to allow it to be 'pushed' (see new examples).
|
||||
* Removed Body.deltaAbsX and deltaAbsY as they are no longer used internally.
|
||||
* Body.screenX and screenY moved to getters, no longer calculated every frame.
|
||||
* ArcadePhysics now has setBounds and setBoundsToWorld, and you can specify which walls are created or not (left, right, up, down)
|
||||
* Removed: Debug.renderSpriteTouching, Debug.renderLocalTransformInfo, Debug.renderWorldTransformInfo, Debug.renderSpriteCollision and Debug.dumpLinkedList.
|
||||
* Body.setSize has been removed. Please use Body.setCircle, setRectangle or setPolygon instead.
|
||||
|
||||
|
||||
New features:
|
||||
|
||||
* Phaser.Timer is now feature complete and fully documented. You can create Phaser.TimerEvents on a Timer and lots of new examples have been provided.
|
||||
* Gamepad API support has been added with lots of new examples (thanks Karl Macklin)
|
||||
* Phaser.Game constructor can now be passed a single object containing all of your game settings + Stage settings. Useful for advanced configurations.
|
||||
* The width/height given to Phaser.Game can now be percentages, i.e. "100%" will set the width to the maximum window innerWidth.
|
||||
* Added a stage.fullScreenScaleMode property to determine scaling when fullscreen (thanks oysterCrusher)
|
||||
* Added support for margin and spacing around a frame in Loader.spritesheet.
|
||||
* Added Device.vibration to check if the Vibration API is available or not.
|
||||
* Added Device.trident and Device.tridentVersion for testing IE11.
|
||||
* Added Device.silk for detecting a Kindle Fire and updated desktop OS check to exclude Kindles (thanks LuckieLordie)
|
||||
* TilemapLayers now have debug and debugAlpha values, this turns on the drawing of the collision edges (very handy for debugging, as the name implies!)
|
||||
* Tweens have a new event: onLoop.
|
||||
* You can now load any binary file via the Loader: game.load.binary(key, url, callback) - the optional callback allows for post-load processing before entering the Cache.
|
||||
* Group.set will let you deep set a new propery on a single child of the Group.
|
||||
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
|
||||
* Added Ejecta detection to Device (thanks endel)
|
||||
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value.
|
||||
* Buttons now properly use their upFrame if set.
|
||||
* InputHandler now has snapOffsetX and snapOffsetY properties so your snap grid doesn't have to be 0,0 aligned (thanks srmeier)
|
||||
* Loader.progressFloat contains the actual non-rounded progress value, where-as Loader.progress contains a rounded value. Use progressFloat if you've > 100 files to load.
|
||||
* Groups can now be added to other Groups as children via group.add() and group.addAt()
|
||||
* Groups now have an 'alive' property, which can be useful when iterating through child groups with functions like forEachAlive.
|
||||
* Added a new Project Template "Full Screen Mobile" which you can find in the resources folder. Contains html / css / layout needed for a deployed Phaser game.
|
||||
* Body.speed - the current speed of the body.
|
||||
* Body.angle - the current angle the Body is facing based on its velocity. This is not the same as the Sprite angle that may own the body.
|
||||
* Body.linearDamping - This now replaces Body.drag and provides for a much smoother damping (friction) experience.
|
||||
* Body.minBounceVelocity - If a Body has bounce set, this threshold controls if it should rebound or not. Use it to stop 'jittering' on bounds/tiles with super-low velocities.
|
||||
* QuadTree.populate - you can pass it a Group and it'll automatically insert all of the children ready for inspection.
|
||||
* Input.setMoveCallback allows you to set a callback that will be fired each time the activePointer receives a DOM move event.
|
||||
* Math.distancePow(x1,y1,x2,y2,power) returns the distance between two coordinates at the given power.
|
||||
* Physics.collide now supports the 2nd parameter as an array, for when you want to collide an object against a number of sprites that aren't all in the same Group.
|
||||
* Physics.overlap now supports the 2nd parameter as an array, for when you want to overlap test an object against a number of sprites that aren't all in the same Group.
|
||||
* Math.reverseAngle - reverses an angle (in radians).
|
||||
* Math.normalizeAngle - normalises an angle, now in radians only.
|
||||
* Math.normalizeLatitude - Normalizes a latitude to the [-90,90] range.
|
||||
* Math.normalizeLongitude - Normalizes a longitude to the [-180,180] range.
|
||||
* Phaser.Line added to the geometry classes, with full point on line/segment and intersection tests (see new examples)
|
||||
* Phaser.CANVAS_PX_ROUND is a boolean. If 'true' the Canvas renderer will Math.floor() all coordinates before drawImage, stopping pixel interpolation. Defaults to false.
|
||||
* Phaser.CANVAS_CLEAR_RECT is a boolean. If 'true' (the default) it will context.clearRect() every frame. If false this is skipped (useful if you know you don't need it)
|
||||
* Collision now works between Sprites positioned via sprite.x/y, sprite.body.x/y or sprite.body.velocity.
|
||||
* If you are tweening a sprite and still want physics collision, set `sprite.body.moves = false` otherwise it will fight against the tween motion.
|
||||
* Game.enableStep will enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?), very useful for debugging!
|
||||
* Game.disableStep turns core update loop stepping off.
|
||||
* Debug.renderPhysicsBody(body, color) is extremely useful for debugging the new physics bodies. Will draw the outline + points in the color given.
|
||||
* Debug.renderBodyInfo(sprite, x, y, color) will display lots of Sprite body data.
|
||||
* Sprite.events.onBeginContact will be fired when a Body makes contact with another Body. Once contact is over an onEndContact event will be dispatched.
|
||||
|
||||
|
||||
New Examples:
|
||||
|
||||
* Physics - Bounce by Patrick OReilly.
|
||||
* Physics - Bounce with gravity by Patrick OReilly.
|
||||
* Physics - Bounce accelerator (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Bounce knock (use the keyboard) by Patrick OReilly.
|
||||
* Physics - Snake (use the keyboard to control the snake like creature) by Patrick OReilly and Richard Davey.
|
||||
* Physics - Launcher - Angry Birds style ball launcher demo by Patrick OReilly.
|
||||
* Physics - Launcher Follow - throw the sprite anywhere in the world by Patrick OReilly.
|
||||
* Physics - Launcher Follow World - an advanced version of the Launcher Follow example by Patrick OReilly.
|
||||
* Input - Touch Joystick example showing how to use the clay.io virtual game controller (thanks gabehollombe)
|
||||
* Games - Matching Pairs by Patrick OReilly.
|
||||
* Games - Simon Says by Patrick OReilly.
|
||||
* Tweens - Example showing how to use the tween events, onStart, onLoop and onComplete.
|
||||
* Display - Pixi Render Texture. A Phaser conversion of the Pixi.js Render Texture example.
|
||||
* Input - 5 new examples showing how to use the Gamepad API (thanks Karl Macklin)
|
||||
* Animation - Group Creation, showing how to create animations across all Group children in one call.
|
||||
* Particles - Rain by Jens Anders Bakke.
|
||||
* Particles - Snow by Jens Anders Bakke.
|
||||
* Groups - Nested Groups - showing how to embed one Group into another Group.
|
||||
* Time - Lots of new examples showing how to use the updated Phaser.Timer class.
|
||||
|
||||
|
||||
Updates:
|
||||
|
||||
* Updated to latest Pixi.js dev branch build (pre 1.4 release)
|
||||
* When a Sprite is destroyed any active filters are removed at the same time.
|
||||
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
|
||||
* Phaser.Canvas.create updated so it can be given an ID as the 3rd parameter (can also be set via new Game configuration object).
|
||||
* Updated display/fullscreen example to reflect new full screen change.
|
||||
* Loads of updates to the TypeScript definitions files - games fully compile now and lots of missing classes added :) (thanks Niondir)
|
||||
* Removed 'null parent' check from Group constructor. Will parent to game.world only if parent value is undefined.
|
||||
* The tutorials have now been translated into Spanish - thanks feiss :)
|
||||
* separateY updated to re-implement the 'riding platforms' special condition (thanks cocoademon)
|
||||
* SoundManager.onSoundDecode now dispatches the key followed by the sound object, also now dispatched by the Cache when doing an auto-decode on load.
|
||||
* Switch method of using trimmed sprites to support scaling and rotation (thanks cocoademon)
|
||||
* Most of the GameObjectFactory functions now have a group parameter, so you can do: game.add.sprite(x, y, frame, frameName, group) rather than defaulting to the World group.
|
||||
* Group.countLiving and countDead used to return -1 if the Group was empty, but now return 0.
|
||||
* Text can now be fixedToCamera, updated world/fixed to camera example to show this.
|
||||
* ArcadePhysics.overlap and collide now recognise TileSprites in the collision checks.
|
||||
* Lots of documentation fixes in the Tween class.
|
||||
* Tweens fire an onLoop event if they are set to repeat. onComplete is now only fired for the final repeat (or never if the repeat is infinite)
|
||||
* Pointer used to un-pause a paused game every time it was clicked/touched (this avoided some rogue browser plugins). Now only happens if Stage.disableVisibilityChange is true.
|
||||
* Input doesn't set the cursor to default if it's already set to none.
|
||||
* You can now collide a group against itself. This will check all children against each other, but not themselves (thanks cocoademon)
|
||||
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
|
||||
* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata)
|
||||
* Group.destroy has a new parameter: destroyChildren (boolean) which will optionally call the destroy method of all Group children.
|
||||
* Button.clearFrames method has been added.
|
||||
* Device.quirksMode is a boolean that informs you if the page is in strict (false) or quirks (true) mode.
|
||||
* Canvas.getOffset now runs a strict/quirks check and uses document.documentElement when calculating scrollTop and scrollLeft to avoid Chrome console warnings.
|
||||
* The Time class now has its own Phaser.Timer which you can access through game.time.events. See the new Timer examples to show how to use them.
|
||||
* Added StateManager.getCurrentState to return the currently running State object (thanks Niondir)
|
||||
* Removed the console.log redirect from Utils as it was messing with Firefox.
|
||||
* Body.acceleration is now much smoother and less eratic at high speeds.
|
||||
* Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system.
|
||||
* Removed ArcadePhysics.preUpdate and postUpdate as neither are needed any more.
|
||||
* Body.bottom and Body.right are no longer rounded, so will give accurate sub-pixel values.
|
||||
* Fixed lots of documentation in the Emitter class.
|
||||
* The delta timer value used for physics calculations has had its cap limit modified from 1.0 to 0.05 in line with the core updates.
|
||||
* Phaser.Math.min enhanced so you can now pass in either an array of numbers or lots of numbers as parameters to get the lowest.
|
||||
* Phaser.Math.max added as the opposite of Math.min.
|
||||
* Phaser.Math.minProperty and maxProperty added. Like Math.min/max but can be given a property an an array or list of objects to inspect.
|
||||
* Added 'full' paramter to Body.reset, allowing you to control if motion or all data is reset or not.
|
||||
* Exposed Group.pivot and Sprite.pivot to allow you to directly set the pivot points for rotation.
|
||||
* Swapped to using the native and faster Array.isArray check.
|
||||
* Added callback context parameter to Tween.onUpdateCallback(callback, context) to avoid having to bind or create anonymous functions.
|
||||
* Updated TweenManager.removeAll so it flags all tweens as pendingDelete rather than nuking the array, to avoid tween callback array size errors (thanks DarkDev)
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Cache.getImageKeys returned __missing in the array, now excluded.
|
||||
* Fixed Group.scale so you can now scale a Group directly.
|
||||
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
|
||||
* Moved 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
|
||||
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group has no children.
|
||||
* Switch Camera.setBoundsToWorld to match world.bounds instead of world (thanks cocoademon)
|
||||
* Fixed an issue where passing null as the Group parent wouldn't set it to game.world as it should have (thanks tito100)
|
||||
* Fixed Pixi bug (#425) incorrect width property for multi-line BitmapText (thanks jcd-as)
|
||||
* Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma)
|
||||
* Sprites that are fixedToCamera can now be input dragged regardless of world position (thanks RafaelOliveira)
|
||||
* RenderTexture now displays correctly in Canvas games.
|
||||
* Canvas.addToDOM is now more robust when applying the overflowHidden style.
|
||||
* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital)
|
||||
* Patched desyrel.xml so it doesn't contain any zero width/height characters, as they broke Firefox 25.
|
||||
* Cache.addSound now implements a locked attribute (thanks haden)
|
||||
* Sound now checks for CocoonJS during playback to avoid readyState clash (thanks haden)
|
||||
* Buttons now clear previously set frames correctly if you call setFrames.
|
||||
* Sounds will now loop correctly if they are paused and resumed (thanks haden)
|
||||
* InputHandler.checkBoundsRect and checkBoundsSprite now take into account if the Sprite is fixedToCamera or not.
|
||||
* Removed the frame property from TileSprites as it cannot use them, it tiles the whole image only, not just a section of it.
|
||||
* Fixed WebGLRenderer updateGraphics bug (thanks theadam)
|
||||
* Removed duplicate Timer.create line (thanks hstolte)
|
||||
* Fixed issue with the camera being slightly out of sync with 'fixedToCamera' sprites.
|
||||
* 1px camera jitter issue fixed where map is same size, or smaller than the game size.
|
||||
|
||||
|
||||
Version 1.1.3 - "Arafel" - November 29th 2013
|
||||
---------------------------------------------
|
||||
|
||||
New features:
|
||||
|
||||
* Phaser.Filter. A new way to use the new WebGL shaders/filters that the new version of Pixi supports.
|
||||
* Phaser.BitmapData object. A Canvas you can freely draw to with lots of functions. Can be used as a texture for Sprites. See the new examples and docs for details.
|
||||
* The entire Phaser library has been updated to match the new JSHint configuration.
|
||||
* Added a .jshintrc so contributions can be run through JSHint to help retain formatting across the library (thanks kevinthompson)
|
||||
* Added a new in-built texture. Sprites now use __default if no texture was provided (a 32x32 transparent PNG) or __missing if one was given but not found (a 32x32 black box with a green cross through it)
|
||||
* Loader can now load JavaScript files. Just use game.load.script('key', 'url') - the file will be turned into a script tag in the document head on successful load.
|
||||
* RenderTexture.render now takes a Phaser.Group. Also added renderXY for when you don't want to make a new Point object.
|
||||
* Physics.overlap now supports Sprites, Groups or Emitters and can perform group vs. group (etc) overlap checks with a custom callback and process handler.
|
||||
* Added Sound.externalNode which allows you to connect a Sound to an external node input rather than the SoundManager gain node.
|
||||
* Added SoundManager.connectToMaster boolean. Used in conjunction with Sound.externalNode you can easily configure audio nodes to connect together for special effects.
|
||||
* PluginManager.remove, added PluginManager.removeAll (thanks crazysam)
|
||||
* scrollFactorX/scrollFactorY have been added to TilemapLayers (thanks jcd-as)
|
||||
* Phaser.Game parent can now be an HTMLElement or a string (thanks beeglebug)
|
||||
* Now using the latest version of Pixi.js. Which means you can use all the sexy new WebGL filters :)
|
||||
* Sprite.animations.getAnimation will return an animation instance which was added by name.
|
||||
* Added Mouse.button which is set to the button that was pressed: Phaser.Mouse.LEFT_BUTTON, MIDDLE_BUTTON or RIGHT_BUTTON (thanks wKLV)
|
||||
* Added Mouse.pointerLock signal which you can listen to whenever the browser enters or leaves pointer lock mode.
|
||||
* StageScaleMode.forceOrientation allows you to lock your game to one orientation and display a Sprite (i.e. a "please rotate" screen) when incorrect.
|
||||
* World.visible boolean added, toggles rendering of the world on/off entirely.
|
||||
* Polygon class & drawPolygon method added to Graphics (thanks rjimenezda)
|
||||
* Added Group.iterate, a powerful way to count or return children that match a certain criteria. Refactored Group to use iterate, lots of repeated code cut.
|
||||
* Added Group.sort. You can now sort the Group based on any given numeric property (x, y, health), finally you can do depth-sorting :) Example created to show.
|
||||
* Enhanced renderTexture so it can accept a Phaser.Group object and improved documentation and examples.
|
||||
* Device.littleEndian boolean added. Only safe to use if the browser supports TypedArrays (which IE9 doesn't, but nearly all others do)
|
||||
* You can now call game.sound.play() and simply pass it a key. The sound will play if the audio system is unlocked and optionally destroy itself on complete.
|
||||
* Mouse.capture is a boolean. If set to true then DOM mouse events will have event.preventDefault() applied, if false they will propogate fully.
|
||||
* The object returned by Math.sinCosGenerator now contains a length property.
|
||||
|
||||
Updates:
|
||||
|
||||
* Lots of documentation fixes and updates across nearly all files. Tilemap now documented for example and lots of instances of 'Description' filled out.
|
||||
* ArcadePhysics.updateMotion applies the dt to the velocity calculations as well as position now (thanks jcs)
|
||||
* RequestAnimationFrame now retains the callbackID which is passed to cancelRequestAnimationFrame.
|
||||
* Button now goes back to over state when setFrames used in action (thanks beeglebug)
|
||||
* plugins now have a postUpdate callback (thanks cocoademon)
|
||||
* Tided up the Graphics object (thanks BorisKozo)
|
||||
* If running in Canvas mode and you have a render function it will save the context and reset the transform before running your render function.
|
||||
* Sprite will now check the exists property of the Group it is in, if the Group.exists = false the Sprite won't update.
|
||||
* If you specify 'null' as a Group parent it will now revert to using the World as the parent (before only 'undefined' worked)
|
||||
* Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist (thanks cocoademon)
|
||||
* Loader.audio can now accept either an array of URL strings or a single URL string (thanks crazysam + kevinthompson)
|
||||
* MSPointer updated to support IE11 by dropping the prefix from the event listeners.
|
||||
* Device.cocoonJS added to detect if the game is running under Cocoon or a native browser.
|
||||
* Loader now uses a new queue system internally, meaning you can have assets with the same key spread across different types.
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
* Lots of fixes to the TypeScript definitions file (many thanks gltovar)
|
||||
* Tilemap commands use specified layer when one given (thanks Izzimach)
|
||||
* Mouse.stop now uses the true useCapture, which means the event listeners stop listening correctly (thanks beeglebug)
|
||||
* Input Keyboard example fix (thanks Atrodilla)
|
||||
* BitmapText.destroy now checks if it has a canvas before calling parentNode on it.
|
||||
* Group.swap had a hellish to find bug that only manifested when B-A upward swaps occured. Hours of debugging later = bug crushed.
|
||||
* Point.rotate asDegrees fixed (thanks BorisKozo)
|
||||
* ArcadePhysics.separateTile wasn't returning the value, so the custom process callback wasn't getting called (thanks flameiguana)
|
||||
* StageScaleMode.forceOrientation now correctly stores the forcePortrait value (thanks haden)
|
||||
* Fixes to Math and Loader (thanks theJare)
|
||||
* Tween - isRunning not reset when non-looped tween completes (thanks crazysam + kevinthompson)
|
||||
* Math.normalizeAngle and Math.wrapAngle (thanks theJare)
|
||||
* Device.isTouch modified to test maxTouchPointers instead of MSPointer.
|
||||
* InputHandler.checkPointerOver now checks the visible status of the Sprite Group before processing.
|
||||
* The Sprite hulls (used for tile collision) were not being updated in sprite->sprite separations (thanks jcs)
|
||||
* Plugins that had a postUpdate but no Update weren't being marked as active (thanks crazysam)
|
||||
* StateManager.onPausedCallback function is not called when the game is paused (thanks haden)
|
||||
* Fix for 'jitter' in scrolling where tilemaps & sprites are one frame off (thanks jcs)
|
||||
|
||||
|
||||
Version 1.1.2 - November 1st 2013
|
||||
---------------------------------
|
||||
|
||||
* New: You'll now find a complete Basic project Template in the resources/Project Templates folder. Will add more complex ones soon.
|
||||
* New: Phaser.Button now has the ability to set over/out/up/down sound effects so they play automatically based on those events.
|
||||
* New: Added init method to plugins, to be called as they are added to the PluginManager (thanks beeglebug)
|
||||
* New: Physics.Body now has a center property (issue 142, thanks MikeMnD)
|
||||
* New: Lots of fixes across Full Screen Mode support. Input now works, scaling restores properly, world scale is correct and anti-alias support added.
|
||||
* New: Added Group.cursor. This points to the first item added to a Group. You can move the cursor with Group.next() and Group.previous().
|
||||
* New: Added Tween.isTweening(object) to check if an object is currently being tweened or not (thanks mikehamil10)
|
||||
* New: Added getMagnitude, setMagnitude, normalize and isZero methods to Point (thanks beeglebug)
|
||||
* New/Change: Group.callAll now supports nested functions and a context, making it really powerful!
|
||||
* Updated: Fixed a few final bugs in the Sprite body and bounds calculations, in turn this resolved the Tilemap collision issues in the 1.1 release.
|
||||
* Updated: Finished documentation for the Phaser.Button class.
|
||||
* Updated: Fixed the Invaders game sample and enhanced it.
|
||||
* Updated: Fixed the Star Struck game sample and enhanced it.
|
||||
* Updated: If you pause an Animation, when you next play it it'll resume (un-pause itself).
|
||||
* Updated: hexToRGB now accepts short hex codes (#EEE) (thanks beeglebug)
|
||||
* Updated: State functions (preload, update, render, etc) are now passed the current game as a parameter (thanks beeglebug)
|
||||
* Updated: If your game is running in Canvas (not WebGL) you can now set Stage.backgroundColor to rgba style CSS strings, allowing for semi-transparent game backgrounds.
|
||||
* Updated: event.preventDefault() has been added to all Mouse event handlers.
|
||||
* Updated: Sprite.deltaX/Y removed due to non-use. prevX/Y values moved to Sprite._cache.prevX/Y.
|
||||
* Updated: Due to missing extends parameter the Sprite prototype was picking up functions from classes it never meant to (Button, TilemapLayer), now fully isolated.
|
||||
* Fixed issue 135 - Added typeof checks into most ArcadePhysics functions to avoid errors with zero values.
|
||||
* Fixed issue 136 - distanceTo using worldX/Y instead of x/y.
|
||||
* Fixed lots of examples where the cursor keys / space bar were not locked from moving the browser page (if you find any more, please tell us!)
|
||||
* Fixed issue 149 - Starling XML files now load properly again, also created an Example to show use of them (thanks haden)
|
||||
* Fixed an issue where if the Starling XML file didn't contain a frameX/Y value it would crash on import.
|
||||
* Fixed the Multiple Animations Example - it's now a lovely underwater scene :)
|
||||
* Fixed issue 141 - If a Sprite is dragged and you release the Pointer while not over the Sprite, it will think it's still over it (thanks Paratron)
|
||||
* Fixed issue 88 - Incorrect game.input.x/y values on click with scaled stage (thanks DrHackenstein)
|
||||
* Fixed issue 143 - Entering full screen mode made the Input x/y coordinates go wrong.
|
||||
|
||||
|
||||
Version 1.1.1 - October 26th 2013
|
||||
---------------------------------
|
||||
|
||||
* Quick patch to get Phaser.AUTO working again on Firefox / Android.
|
||||
* Any key added via addKey now automatically adds it to the capture list.
|
||||
|
||||
|
||||
Version 1.1 - October 25th 2013
|
||||
-------------------------------
|
||||
|
||||
What's New:
|
||||
|
||||
* JSDoc is go! We've added jsdoc3 blocks to every property and function, in every file and published the API docs to the docs folder.
|
||||
* Brand new Example system (no more php!) and over 150 examples to learn from too.
|
||||
* New TypeScript definitions file generated (in the build folder - thanks to TomTom1229 for manually enhancing this).
|
||||
* New Grunt based build system added (thanks to Florent Cailhol)
|
||||
* New: Phaser.Animation.generateFrameNames - really useful when creating animation data from texture atlases using file names, not indexes.
|
||||
* Added Sprite.play as a handy short-cut to play an animation already loaded onto a Sprite.
|
||||
* Added Canvas.setUserSelect() to disable touchCallouts and user selections within the canvas.
|
||||
* Added Keyboard.addKey() which creates a new Phaser.Key object that can be polled for updates, pressed states, etc. See the 2 new examples showing use.
|
||||
* Added Button.freezeFrames boolean. Stops the frames being set on mouse events if true.
|
||||
* Extended the Loader 404 error to display the url of the file that didn't load as well as the key.
|
||||
* New: Direction constants have been added to Sprites and adjust based on body motion.
|
||||
* Brand new Sprite.update loop handler. Combined with the transform cache fix and further optimisations this is now much quicker to execute.
|
||||
* Added Keyboard.createCursorKeys() which creates an object with 4 Key objects inside it mapped to up, down, left and right. See the new example in the input folder.
|
||||
* Added Body.skipQuadTree boolean for more fine-grained control over when a body is added to the World QuadTree.
|
||||
* Re-implemented Angular Velocity and Angular Acceleration on the Sprite.body and created 2 new examples to show use.
|
||||
* Added Sprite.fixedToCamera boolean. A Sprite that is fixed to the camera doesn't move with the world, but has its x/y coordinates relative to the top-left of the camera.
|
||||
* Added Group.createMultiple - useful when you need to create a Group of identical sprites for pooling, such as bullets.
|
||||
* Added Group.total. Same as Group.length, but more in line with the rest of the Group naming.
|
||||
* Added Sprite.outOfBoundsKill boolean flag. Will automatically kill a sprite that leaves the game World bounds (off by default).
|
||||
* Lots of changes and fixes in ArcadePhysics, including:
|
||||
* Functions with "mouse" in the title have been updated to "pointer" to more accurately reflect what they do.
|
||||
* New velocity functions: moveToObject, moveToPointer, moveToXY
|
||||
* New acceleration functions: accelerateToObject, accelerateToPointer, accelerateToXY
|
||||
* New distance functions: distanceBetween, distanceToXY, distanceToPointer
|
||||
* New angle functions: angleBetween, angleToXY, angleToPointer
|
||||
* velocityFromAngle and velocityFromRotation added with examples created.
|
||||
* Added killOnComplete parameter to Animation.play. Really useful in situations where you want a Sprite to animate once then kill itself on complete, like an explosion effect.
|
||||
* Added Sprite.loadTexture(key, frame) which allows you to load a new texture set into an existing sprite rather than having to create a new sprite.
|
||||
* Added Sprite.destroy back in again and made it a lot more robust at cleaning up child objects.
|
||||
* Added 'return this' to all the core Loader functions so you can chain load calls if you so wish.
|
||||
* Added Text.destroy() and BitmapText.destroy(), also updated Group.remove to make it more bullet-proof when an element doesn't have any events.
|
||||
* Added Phaser.Utils.shuffle to shuffle an array.
|
||||
* Added Graphics.destroy, x, y and updated angle functions.
|
||||
* Added AnimationManager.refreshFrame - will reset the texture being used for a Sprite (useful after a crop rect clear)
|
||||
* Added Physics.overlap(sprite1, sprite2) for quick body vs. body overlap tests with no separation performed.
|
||||
* On a busy page it's possible for the game to boot with an incorrect stage offset x/y which can cause input events to be calculated wrong. A new property has been added to Stage to combat this issue: Stage.checkOffsetInterval. By default it will check the canvas offset every 2500ms and adjust it accordingly. You can set the value to 'false' to disable the check entirely, or set a higher or lower value. We recommend that you get the value quite low during your games preloader, but once the game has fully loaded hopefully the containing page will have settled down, so it's probably safe to disable the check entirely.
|
||||
* Added Rectangle.floorAll to floor all values in a Rectangle (x, y, width and height).
|
||||
|
||||
What's changed:
|
||||
|
||||
* Renamed Phaser.Text.text to Phaser.Text.content to avoid conflict and overwrite from Pixi local var.
|
||||
* Renamed Phaser.Text.style to Phaser.Text.font to avoid conflict and overwrite from Pixi local var.
|
||||
* Phaser.Button now sets useHandCursor to true by default.
|
||||
* Change: When you start a new State all active tweens are now purged.
|
||||
* When the game boots it will now by default disable user-select and touch action events on the game canvas.
|
||||
* Moved LinkedList.dump to Debug.dumpLinkedList(list)
|
||||
* Phaser.Animation.Frame is now Phaser.Frame
|
||||
* Phaser.Animation.FrameData is now Phaser.FrameData
|
||||
* Phaser.Animation.Parser is now Phaser.AnimationParser (also the file has renamed from Parser.js to AnimationParser.js)
|
||||
* Phaser.Loader.Parser is now Phaser.LoaderParser (also the file has renamed from Parser.js to LoaderParser.js)
|
||||
* Change: We've removed the scrollFactor property from all Game Objects. Sorry, but the new Camera system doesn't work with it and it caused all kinds of issues anyway. We will sort out a replacement for it at a later date.
|
||||
* Change: World now extends Phaser.Group. As a result we've updated GameObjectFactory and other classes that linked to it. If you have anywhere in your code that used to reference world.group you can just remove 'group' from that. So before, world.group.add() is now just world.add().
|
||||
* Change: The Camera has been completely revamped. Rather than adjusting the position of all display objects (bad) it now just shifts the position of the single world container (good!), this is much quicker and also stops the game objects positions from self-adjusting all the time, allowing for them to be properly nested with other containers.
|
||||
* Made Sprite.body optional and added in checks, so you can safely null the Sprite body object if using your own physics system and not impact rendering.
|
||||
* Moved the Camera update checks to World.postUpdate, so all the sprites get the correct adjusted camera position.
|
||||
* The default Game.antialias value is now 'true', so graphics will be smoothed automatically in canvas. Disable it via the Game constructor or Canvas utils.
|
||||
* Phaser.Group now automatically calls updateTransform on any child added to it (avoids temp. frame glitches when new objects are rendered on their first frame).
|
||||
|
||||
What has been updated:
|
||||
|
||||
* Complete overhaul of Physics.Arcade.Body - now significantly more stable and faster too.
|
||||
* Updated ArcadePhysics.separateX/Y to use new body system - much better results now.
|
||||
* Added World.postUpdate - all sprite position changes, as a result of physics, happen here before the render.
|
||||
* Added Animation.paused - can be set to true/false.
|
||||
* Added support for Body.maxVelocity (thanks cocoademon)
|
||||
* InputHandler now creates the _pointerData array on creation and populates with one empty set of values, so pointerOver etc all work before a start call.
|
||||
* Removed the callbackContext parameter from Group.callAll because it's no longer needed.
|
||||
* Updated Group.forEach, forEachAlive and forEachDead so you can now pass as many parameters as you want, which will all be given to the callback after the child.
|
||||
* Updated build script so it can be run from the command-line and includes UMD wrappers (thanks iaincarsberg)
|
||||
* World.randomX/Y now returns values anywhere in the world.bounds range (if set, otherwise 0), including negative values.
|
||||
* Updated InputHandler to use Math.round rather than Math.floor when snapping an object during drag.
|
||||
* If you didn't provide the useNumericIndex parameter then AnimationManager.add will set the value by looking at the datatype of the first element in the frames array.
|
||||
* Group.create now sets the visible and alive properties of the Sprite to the same value as the 'exists' parameter.
|
||||
* World.randomX/Y now works with negative World.bounds values.
|
||||
* Tweens .to will now always return the parent (thanks powerfear)
|
||||
* You can now pass a PIXI.Texture to Sprite (you also need to pass a Phaser.Frame as the frame parameter) but this is useful for Sprites sharing joint canvases.
|
||||
* Group.alpha is now exposed publically and changes the Group container object (not the children directly, who can still have their own alpha values)
|
||||
* Device.webGL uses new inspection code to accurately catch more webGL capable devices.
|
||||
* Debug.renderSpriteBody updated to use a the new Sprite.Body.screenX/Y properties.
|
||||
* Additional checks added to AnimationManager.frame/frameName on the given values.
|
||||
* You can now null a Sprite.crop and it will clear down the crop rect area correctly.
|
||||
* Phaser.Time physicsElapsed delta timer clamp added. Stops rogue iOS / slow mobile timer errors causing crazy high deltas.
|
||||
* Animation.generateFrameNames can now work in reverse, so the start/stop values can create frames that increment or decrement respectively.
|
||||
* Loader updated to use xhr.responseText when loading json, csv or text files. xhr.response is still used for Web Audio binary files (thanks bubba)
|
||||
* Input.onDown and onUp events now dispatch the original event that triggered them (i.e. a MouseEvent or TouchEvent) as the 2nd parameter, after the Pointer (thanks rezoner)
|
||||
* Updated Sprite.crop significantly. Values are now cached, stopping constant Texture frame updates and you can do sprite.crop.width++ for example (thanks haden)
|
||||
* Change: Sprite.crop needs to be enabled with sprite.cropEnabled = true.
|
||||
* Sprite.loadTexture now works correctly with static images, RenderTextures and Animations.
|
||||
* Lots of fixes within Sprite.bounds. The bounds is now correct regardless of rotation, anchor or scale of the Sprite or any of its parent objects.
|
||||
|
||||
What has been fixed:
|
||||
|
||||
* QuadTree bug found in 1.0.5 now fixed. The QuadTree is updated properly now using localTransform values.
|
||||
* Fixed the Bounce.In and Bounce.InOut tweens (thanks XekeDeath)
|
||||
* Fixed an issue in Animation.update where if the game was paused it would get an insane delta timer throwing a uuid error.
|
||||
* Added PixiPatch.js to patch in a few essential features until Pixi is updated.
|
||||
* Fixed issue in Animation.play where the given frameRate and loop values wouldn't overwrite those set on construction.
|
||||
* Fixed small bug stopping Tween.pause / resume from resuming correctly when called directly.
|
||||
* Fixed an issue where Tweens.removeAll wasn't clearing tweens in the addition queue.
|
||||
* Fixed Particle Emitters when using Emitter width/height (thanks XekeDeath)
|
||||
* Made animation looping more robust when skipping frames (thanks XekeDeath)
|
||||
* Fix for incorrect new particle positioning (issue #73) (thanks cottonflop)
|
||||
* Fixed issue in Sound.play where if you gave a missing marker it would play the whole sound sprite instead.
|
||||
* Button.setFrames will set the current frame based on the button state immediately.
|
||||
* Loaded.setPreloadSprite now rounds the width/height values and starts from 1. This fixes canvas draw errors in IE9/10 and Firefox.
|
||||
* Fixed issue causing Keyboard.justPressed to always fire (thanks stemkoski)
|
||||
* Fixed bug in LinkedList#remove that could cause first to point to a dead node (thanks onedayitwillmake)
|
||||
* Fixed Cache.addDefaultImage so the default image works in Canvas as well as WebGL. Updated to a new image (32x32 black square with green outline)
|
||||
* Fixed a bug in the Sprite transform cache check that caused the skew/scale cache to get constantly invalidated - now only updates as needed, significant performance increase!
|
||||
* Fixed typo in StageScaleMode so it's not pageAlignVeritcally any longer, but pageAlignVertically.
|
||||
* Fixed issue in Group.countLiving / countDead where the value was off by one (thanks mjablonski)
|
||||
* Fixed issue with a jittery Camera if you moved a Sprite via velocity instead of x/y placement.
|
||||
* Fixed the RandomDataGenerator.sow method so if you give in the same seed you'll now get the same results (thanks Hsaka)
|
||||
* Fixed Issue #101 (Mouse Button 0 is not recognised, thanks rezoner)
|
||||
* Fixed an issue where creating an animation with just one frame with an index of zero would cause a UUID error (thanks SYNYST3R1)
|
||||
* Fixed Rectangle.union (thanks andron77)
|
||||
* Fixed Sound.resume so it now correctly resumes playback from the point it was paused (fixes issue 51, thanks Yora).
|
||||
* Fixed issue 105 where a dragged object that was destroyed would cause an Input error (thanks onedayitwillmake)
|
||||
* Fixed Issue 111 - calling Kill on a Phaser.Graphics instance causes error on undefined events.
|
||||
* Game.destroy will now stop the raf from running as well as close down all input related event listeners (issue 92, thanks astrism)
|
||||
* Pixel Perfect click detection now works even if the Sprite is part of a texture atlas.
|
||||
|
||||
|
||||
Version 1.0.6 - September 24th 2013
|
||||
-----------------------------------
|
||||
|
||||
* Added check into Pointer.move to always consider a Sprite that has pixelPerfect enabled, regardless of render ID.
|
||||
* BUG: The pixel perfect click check doesn't work if the sprite is part of a texture atlas yet.
|
||||
* Fixed issue with anti-alias in the Game constructor not being set correctly (thanks luizbills)
|
||||
* Added support for the Graphics game object back in and two examples (thanks earok for spotting)
|
||||
* New: Tweens can now be chained via multiple to() calls + example created (thanks to powerfear for adding)
|
||||
* Fixed Math.wrap (thanks TheJare)
|
||||
* New: When loading a Sprite Sheet you can now pass negative values for the frame sizes which specifies the number of rows/columns to load instead (thanks TheJare)
|
||||
* New: BitmapText now supports anchor and has fixed box dimensions (thanks TheJare)
|
||||
* Fixed bug where if a State contains an empty Preloader the Update will not be called (thanks TheJare)
|
||||
* Several new examples added (cameras, tweens, etc)
|
||||
* Added in extra checks to halt collision if it involves an empty Group (thanks cang)
|
||||
* Added time smoothing to Animation update to help frames hopefully not get too out of sync during long animations with high frame rates.
|
||||
* Added frame skip to Animation.update. If it gets too far behind it will now skip frames to try and catch up.
|
||||
|
||||
|
||||
Version 1.0.5 - September 20th 2013
|
||||
-----------------------------------
|
||||
|
||||
* Fixed issue in FrameData.getFrameIndexes where the input array was being ignored.
|
||||
* Added Math.numberArray - Returns an Array containing the numbers from min to max (inclusive), useful for animation frame construction.
|
||||
* Fixed a horrendously sneaky bug: If a new tween was created in the onComplete callback of a tween about to be deleted, it would get automatically spliced.
|
||||
* Added a pendingDelete property to Tween to stop tweens that were removed during a callback from causing update errors during the TweenManager loop.
|
||||
* Added Group.length property.
|
||||
* Added explicit x/y attributes to Phaser.Text to make it work with the camera system (thanks cocoademon).
|
||||
* Fixed issue stopping multiple animations from playing, only the most recent would play (frames array was being overwritten, thanks Legrandk)
|
||||
* Updated Debug.renderSpriteBounds() so it doesn't use the deprecated Sprite.worldView any more (thanks MikeMnD)
|
||||
* Added 2 new properties to the Text object: Text.text and Text.style, both are getter/setters and don't flag dirty unless changed, so safe for core loop use.
|
||||
* Removed the exists check from Group.callAll, it now runs on all children (as the name implies)
|
||||
* Added Group.callAllExists - you can now call a function on all children who have exists = the provided boolean.
|
||||
* Finished off the Breakout example game - now fully playable, proper rebound, scoring, lives, etc.
|
||||
* Removed Group.sort dummy entry until it's working.
|
||||
* Removed ArcadePhysics.postUpdate.
|
||||
* Updated Sprite.update to set renderable to false when the object goes out of Camera, not 'visible' false, otherwise it stops the transform being updated by Pixi.
|
||||
* BUG: There is a known issue where the wrong rect coordinates are given to the QuadTree if the Sprite is a child of a Group or another Sprite which has an x/y offset.
|
||||
|
||||
|
||||
Version 1.0.4 - September 18th 2013
|
||||
-----------------------------------
|
||||
|
||||
* Small fix to Phaser.Canvas to stop it from setting overflow hidden if the parent DOM element doesn't exist.
|
||||
* Added Loader.setPreloadSprite(sprite, direction) - this will automatically apply a crop rect to the Sprite which is updated in line with the load progress.
|
||||
* A lot of changes inside the StateManager. State functions are now passed through link() which automatically creates the key Game properties (load, input, etc)
|
||||
* Fixed a bug in getFrameByName that wouldn't return the first frame in the array.
|
||||
* Updated Phaser.Rectangle.intersects to use x and y instead of left and top so it can be used to check Physics bodies overlapping.
|
||||
* Fixed issue in Cache where the Frame index wasn't being set correctly (thanks Cameron)
|
||||
* Fixed issue in Sprite where boundsY wasn't set (thanks Cameron)
|
||||
* For some reason there were 2 copies of the Canvas class in the build file - fixed, a few KB saved :)
|
||||
|
||||
|
||||
Version 1.0.3 - September 17th 2013
|
||||
-----------------------------------
|
||||
|
||||
* FrameData.getFrameIndexes and getFrameIndexesByName refactored into a more versatile getFrames function.
|
||||
* Various fixes to looping parameters in the Sound system.
|
||||
* Documentation started across most classes. Keep track of progress in the Docs folder.
|
||||
* Optimised AnimationManager.add so it will only get the required frames rather than all of them and is now faster at parsing the frame data.
|
||||
* Fixed Phaser.Text and Phaser.BitmapText so they now render correctly and added several Text examples.
|
||||
|
||||
|
||||
Version 1.0.2 - September 16th 2013
|
||||
-----------------------------------
|
||||
|
||||
* Added optional parameter to Animation.stop: resetFrame. If true the animation will be stopped and then the current frame reset to the first frame in the animation.
|
||||
* Fixed an issue causing 'explode' particle bursts to ignore the quantity parameter.
|
||||
* Added 'collideWorldBounds' to Emitter.makeParticles function.
|
||||
* Added Emitter.angularDrag
|
||||
* Changed Emitter.bounce from a number to a Point, so now set its x/y properties to control different amounts of bounce per axis.
|
||||
* Fixed a bug in the AnimationManager where useNumericIndex was always set to true
|
||||
* Added in lots of Particle examples
|
||||
* Added in the start of a Breakout game
|
||||
* Added in the start of a Platformer game
|
||||
|
||||
|
||||
Version 1.0.1 - September 15th 2013
|
||||
-----------------------------------
|
||||
|
||||
* Added checks into every Group function to ensure that the Group has children before running them.
|
||||
* Added optional flag to Group.create which allows you to set the default exists state of the Sprites.
|
||||
* Sprite.animation.stop no longer needs an animation name parameter, will default to stopping the current animation.
|
||||
* Fixed the license in package.json
|
||||
* Fixed a logic bug in the separateTileX function that would sometimes cause tunneling of big sprites through small tiles.
|
||||
|
||||
|
||||
Version 0.9.8
|
||||
-------------
|
||||
|
||||
* Massive refactoring across the entire codebase.
|
||||
* Removed Basic and GameObject and put Sprite on a diet. 127 properties and methods cut down to 32.
|
||||
@@ -109,7 +631,8 @@ V0.9.8
|
||||
* Added CanvasUtils class, including ability to set image rendering, add a canvas to the dom and other handy things.
|
||||
|
||||
|
||||
V0.9.6
|
||||
Version 0.9.6
|
||||
-------------
|
||||
|
||||
* Virtually every class now has documentation - if you spot a typo or something missing please shout (thanks pixelpicosean).
|
||||
* Grunt file updated to produce the new Special FX JS file (thanks HackManiac).
|
||||
@@ -197,7 +720,9 @@ V0.9.6
|
||||
* Added the GameObjectFactory to Phaser.State
|
||||
* Added new format parameter to Loader.addTextureAtlas defining the format. Currently supported: JSON Array and Starling/Sparrow XML.
|
||||
|
||||
V0.9.5
|
||||
|
||||
Version 0.9.5
|
||||
-------------
|
||||
|
||||
* Moved the BootScreen and PauseScreen out of Stage into their own classes (system/screens/BootScreen and PauseScreen).
|
||||
* Updated the PauseScreen to show a subtle animation effect, making it easier to create your own interesting pause screens.
|
||||
@@ -231,7 +756,9 @@ V0.9.5
|
||||
* Added fun new "map draw" test - rebound those carrots! :)
|
||||
* Changed SoundManager class to respect volume on first play (thanks initials and hackmaniac)
|
||||
|
||||
V0.9.4
|
||||
|
||||
Version 0.9.4
|
||||
--------------
|
||||
|
||||
* Added Tilemap.getTile, getTileFromWorldXY, getTileFromInputXY
|
||||
* Added Tilemap.setCollisionByIndex and setCollisionByRange
|
||||
@@ -243,7 +770,9 @@ V0.9.4
|
||||
* Fixed: Circle.isEmpty properly checks diameter (thanks bapuna)
|
||||
* Updated Gruntfile to export new version of phaser.js wrapped in a UMD block for require.js/commonJS (thanks Hackmaniac)
|
||||
|
||||
V0.9.3
|
||||
|
||||
Version 0.9.3
|
||||
-------------
|
||||
|
||||
* Added the new ScrollZone game object. Endlessly useful but especially for scrolling backdrops. Created 6 example tests.
|
||||
* Added GameObject.hideFromCamera(cameraID) to stop an object rendering to specific cameras (also showToCamera and clearCameraList)
|
||||
@@ -261,7 +790,9 @@ V0.9.3
|
||||
* Removed the need for DynamicTextures to require a key property and updated test cases.
|
||||
* You can now pass an array or a single value to Input.Keyboard.addKeyCapture().
|
||||
|
||||
V0.9.2
|
||||
|
||||
Version 0.9.2
|
||||
-------------
|
||||
|
||||
* Fixed issue with create not being called if there was an empty init method.
|
||||
* Added ability to flip a sprite (Sprite.flipped = true) + a test case for it.
|
||||
@@ -269,7 +800,9 @@ V0.9.2
|
||||
* Sprite animations don't restart if you call play on them when they are already running.
|
||||
* Added Stage.disablePauseScreen. Set to true to stop your game pausing when the tab loses focus.
|
||||
|
||||
V0.9.1
|
||||
|
||||
Version 0.9.1
|
||||
-------------
|
||||
|
||||
* Added the new align property to GameObjects that controls placement when rendering.
|
||||
* Added an align example to the Sprites test group (click the mouse to change alignment position)
|
||||
@@ -279,7 +812,8 @@ for new collision system.
|
||||
* Game.Input now has 2 signals you can subscribe to for down/up events, see the Sprite align example for use.
|
||||
* Updated the States examples to bring in-line with 0.9 release.
|
||||
|
||||
V0.9
|
||||
Version 0.9
|
||||
-----------
|
||||
|
||||
* Large refactoring. Everything now lives inside the Phaser module, so all code and all tests have been updated to reflect this. Makes coding a tiny bit more verbose but stops the framework from globbing up the global namespace. Also should make code-insight work in WebStorm and similar editors.
|
||||
* Added the new GeomSprite object. This is a sprite that uses a geometry class for display (Circle, Rectangle, Point, Line). It's extremely flexible!
|
||||
@@ -290,27 +824,35 @@ V0.9
|
||||
* Added new Motion class which contains lots of handy functions like 'moveTowardsObject', 'velocityFromAngle' and more.
|
||||
* Tween Manager added. You can now create tweens via Game.createTween (or for more control game.tweens). All the usual suspects are here: Bounce, * Elastic, Quintic, etc and it's hooked into the core game clock, so if your game pauses and resumes your tweens adjust accordingly.
|
||||
|
||||
V0.8
|
||||
|
||||
Version 0.8
|
||||
-----------
|
||||
|
||||
* Added ability to set Sprite frame by name (sprite.frameName), useful when you've loaded a Texture Atlas with filename values set rather than using frame indexes.
|
||||
* Updated texture atlas 4 demo to show this.
|
||||
* Fixed a bug that would cause a run-time error if you tried to create a sprite using an invalid texture key.
|
||||
* Added in DynamicTexture support and a test case for it.
|
||||
|
||||
V0.7
|
||||
|
||||
Version 0.7
|
||||
-----------
|
||||
|
||||
* Renamed FullScreen to StageScaleMode as it's much more fitting. Tested across Android and iOS with the various scale modes.
|
||||
* Added in world x/y coordinates to the input class, and the ability to get world x/y input coordinates from any Camera.
|
||||
* Added the RandomDataGenerator for seeded random number generation.
|
||||
* Setting the game world size now resizes the default camera (optional bool flag)
|
||||
|
||||
V0.6
|
||||
|
||||
Version 0.6
|
||||
-----------
|
||||
|
||||
* Added in Touch support for mobile devices (and desktops that enable it) and populated x/y coords in Input with common values from touch and mouse.
|
||||
* Added new Circle geometry class (used by Touch) and moved them into a Geom folder.
|
||||
* Added in Device class for device inspection.
|
||||
* Added FullScreen class to enable full-screen support on mobile devices (scrolls URL bar out of the way on iOS and Android)
|
||||
|
||||
V0.5
|
||||
|
||||
Version 0.5
|
||||
-----------
|
||||
|
||||
* Initial release
|
||||
|
||||
@@ -0,0 +1,966 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: animation/Animation.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: animation/Animation.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Phaser.Animation
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Phaser.Sprite} parent - A reference to the owner of this Animation.
|
||||
* @param {string} name - The unique name for this animation, used in playback commands.
|
||||
* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
|
||||
* @param {(Array.<number>|Array.<string>)} frames - An array of numbers or strings indicating which frames to play in which order.
|
||||
* @param {number} delay - The time between each frame of the animation, given in ms.
|
||||
* @param {boolean} looped - Should this animation loop or play through once.
|
||||
*/
|
||||
Phaser.Animation = function (game, parent, name, frameData, frames, delay, looped) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Sprite} _parent - A reference to the parent Sprite that owns this Animation.
|
||||
* @private
|
||||
*/
|
||||
this._parent = parent;
|
||||
|
||||
/**
|
||||
* @property {Phaser.FrameData} _frameData - The FrameData the Animation uses.
|
||||
* @private
|
||||
*/
|
||||
this._frameData = frameData;
|
||||
|
||||
/**
|
||||
* @property {string} name - The user defined name given to this Animation.
|
||||
*/
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* @property {array} _frames
|
||||
* @private
|
||||
*/
|
||||
this._frames = [];
|
||||
this._frames = this._frames.concat(frames);
|
||||
|
||||
/**
|
||||
* @property {number} delay - The delay in ms between each frame of the Animation.
|
||||
*/
|
||||
this.delay = 1000 / delay;
|
||||
|
||||
/**
|
||||
* @property {boolean} looped - The loop state of the Animation.
|
||||
*/
|
||||
this.looped = looped;
|
||||
|
||||
/**
|
||||
* @property {boolean} killOnComplete - Should the parent of this Animation be killed when the animation completes?
|
||||
* @default
|
||||
*/
|
||||
this.killOnComplete = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback.
|
||||
* @default
|
||||
*/
|
||||
this.isFinished = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} isPlaying - The playing state of the Animation. Set to false once playback completes, true during playback.
|
||||
* @default
|
||||
*/
|
||||
this.isPlaying = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} isPaused - The paused state of the Animation.
|
||||
* @default
|
||||
*/
|
||||
this.isPaused = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} _pauseStartTime - The time the animation paused.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._pauseStartTime = 0;
|
||||
|
||||
/**
|
||||
* @property {number} _frameIndex
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._frameIndex = 0;
|
||||
|
||||
/**
|
||||
* @property {number} _frameDiff
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._frameDiff = 0;
|
||||
|
||||
/**
|
||||
* @property {number} _frameSkip
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._frameSkip = 1;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation.
|
||||
*/
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.prototype = {
|
||||
|
||||
/**
|
||||
* Plays this animation.
|
||||
*
|
||||
* @method Phaser.Animation#play
|
||||
* @memberof Phaser.Animation
|
||||
* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
|
||||
* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
|
||||
* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
|
||||
* @return {Phaser.Animation} - A reference to this Animation instance.
|
||||
*/
|
||||
play: function (frameRate, loop, killOnComplete) {
|
||||
|
||||
if (typeof frameRate === 'number')
|
||||
{
|
||||
// If they set a new frame rate then use it, otherwise use the one set on creation
|
||||
this.delay = 1000 / frameRate;
|
||||
}
|
||||
|
||||
if (typeof loop === 'boolean')
|
||||
{
|
||||
// If they set a new loop value then use it, otherwise use the one set on creation
|
||||
this.looped = loop;
|
||||
}
|
||||
|
||||
if (typeof killOnComplete !== 'undefined')
|
||||
{
|
||||
// Remove the parent sprite once the animation has finished?
|
||||
this.killOnComplete = killOnComplete;
|
||||
}
|
||||
|
||||
this.isPlaying = true;
|
||||
this.isFinished = false;
|
||||
this.paused = false;
|
||||
|
||||
this._timeLastFrame = this.game.time.now;
|
||||
this._timeNextFrame = this.game.time.now + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
||||
if (this._parent.events)
|
||||
{
|
||||
this._parent.events.onAnimationStart.dispatch(this._parent, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets this animation back to the first frame and restarts the animation.
|
||||
*
|
||||
* @method Phaser.Animation#restart
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
restart: function () {
|
||||
|
||||
this.isPlaying = true;
|
||||
this.isFinished = false;
|
||||
this.paused = false;
|
||||
|
||||
this._timeLastFrame = this.game.time.now;
|
||||
this._timeNextFrame = this.game.time.now + this.delay;
|
||||
|
||||
this._frameIndex = 0;
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation.
|
||||
*
|
||||
* @method Phaser.Animation#stop
|
||||
* @memberof Phaser.Animation
|
||||
* @param {boolean} [resetFrame=false] - If true after the animation stops the currentFrame value will be set to the first frame in this animation.
|
||||
*/
|
||||
stop: function (resetFrame) {
|
||||
|
||||
if (typeof resetFrame === 'undefined') { resetFrame = false; }
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
this.paused = false;
|
||||
|
||||
if (resetFrame)
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[0]);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates this animation. Called automatically by the AnimationManager.
|
||||
*
|
||||
* @method Phaser.Animation#update
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
if (this.isPaused)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isPlaying === true && this.game.time.now >= this._timeNextFrame)
|
||||
{
|
||||
this._frameSkip = 1;
|
||||
|
||||
// Lagging?
|
||||
this._frameDiff = this.game.time.now - this._timeNextFrame;
|
||||
|
||||
this._timeLastFrame = this.game.time.now;
|
||||
|
||||
if (this._frameDiff > this.delay)
|
||||
{
|
||||
// We need to skip a frame, work out how many
|
||||
this._frameSkip = Math.floor(this._frameDiff / this.delay);
|
||||
|
||||
this._frameDiff -= (this._frameSkip * this.delay);
|
||||
}
|
||||
|
||||
// And what's left now?
|
||||
this._timeNextFrame = this.game.time.now + (this.delay - this._frameDiff);
|
||||
|
||||
this._frameIndex += this._frameSkip;
|
||||
|
||||
if (this._frameIndex >= this._frames.length)
|
||||
{
|
||||
if (this.looped)
|
||||
{
|
||||
this._frameIndex %= this._frames.length;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
if (this.currentFrame)
|
||||
{
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
|
||||
this._parent.events.onAnimationLoop.dispatch(this._parent, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.onComplete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
if (this.currentFrame)
|
||||
{
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Cleans up this animation ready for deletion. Nulls all values and references.
|
||||
*
|
||||
* @method Phaser.Animation#destroy
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
this.game = null;
|
||||
this._parent = null;
|
||||
this._frames = null;
|
||||
this._frameData = null;
|
||||
this.currentFrame = null;
|
||||
this.isPlaying = false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent.
|
||||
*
|
||||
* @method Phaser.Animation#onComplete
|
||||
* @memberof Phaser.Animation
|
||||
*/
|
||||
onComplete: function () {
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
this.paused = false;
|
||||
|
||||
if (this._parent.events)
|
||||
{
|
||||
this._parent.events.onAnimationComplete.dispatch(this._parent, this);
|
||||
}
|
||||
|
||||
if (this.killOnComplete)
|
||||
{
|
||||
this._parent.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.prototype.constructor = Phaser.Animation;
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#paused
|
||||
* @property {boolean} paused - Gets and sets the paused state of this Animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'paused', {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.isPaused;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.isPaused = value;
|
||||
|
||||
if (value)
|
||||
{
|
||||
// Paused
|
||||
this._pauseStartTime = this.game.time.now;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Un-paused
|
||||
if (this.isPlaying)
|
||||
{
|
||||
this._timeNextFrame = this.game.time.now + this.delay;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'frameTotal', {
|
||||
|
||||
get: function () {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Animation#frame
|
||||
* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Animation.prototype, 'frame', {
|
||||
|
||||
get: function () {
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
{
|
||||
return this.currentFrame.index;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this._frameIndex;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
{
|
||||
this._frameIndex = value;
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers.
|
||||
* For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large'
|
||||
* You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion_', 1, 30, '-large', 4);
|
||||
*
|
||||
* @method Phaser.Animation.generateFrameNames
|
||||
* @param {string} prefix - The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'.
|
||||
* @param {number} start - The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1.
|
||||
* @param {number} stop - The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34.
|
||||
* @param {string} [suffix=''] - The end of the filename. If the filename was 'explosion_0001-large' the prefix would be '-large'.
|
||||
* @param {number} [zeroPad=0] - The number of zeroes to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4.
|
||||
*/
|
||||
Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zeroPad) {
|
||||
|
||||
if (typeof suffix == 'undefined') { suffix = ''; }
|
||||
|
||||
var output = [];
|
||||
var frame = '';
|
||||
|
||||
if (start < stop)
|
||||
{
|
||||
for (var i = start; i <= stop; i++)
|
||||
{
|
||||
if (typeof zeroPad == 'number')
|
||||
{
|
||||
// str, len, pad, dir
|
||||
frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = i.toString();
|
||||
}
|
||||
|
||||
frame = prefix + frame + suffix;
|
||||
|
||||
output.push(frame);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = start; i >= stop; i--)
|
||||
{
|
||||
if (typeof zeroPad == 'number')
|
||||
{
|
||||
// str, len, pad, dir
|
||||
frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = i.toString();
|
||||
}
|
||||
|
||||
frame = prefix + frame + suffix;
|
||||
|
||||
output.push(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,922 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: animation/AnimationManager.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: animation/AnimationManager.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Animation Manager is used to add, play and update Phaser Animations.
|
||||
* Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance.
|
||||
*
|
||||
* @class Phaser.AnimationManager
|
||||
* @constructor
|
||||
* @param {Phaser.Sprite} sprite - A reference to the Game Object that owns this AnimationManager.
|
||||
*/
|
||||
Phaser.AnimationManager = function (sprite) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Sprite} sprite - A reference to the parent Sprite that owns this AnimationManager.
|
||||
*/
|
||||
this.sprite = sprite;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = sprite.game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any.
|
||||
* @default
|
||||
*/
|
||||
this.currentFrame = null;
|
||||
|
||||
/**
|
||||
* @property {boolean} updateIfVisible - Should the animation data continue to update even if the Sprite.visible is set to false.
|
||||
* @default
|
||||
*/
|
||||
this.updateIfVisible = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} isLoaded - Set to true once animation data has been loaded.
|
||||
* @default
|
||||
*/
|
||||
this.isLoaded = false;
|
||||
|
||||
/**
|
||||
* @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._frameData = null;
|
||||
|
||||
/**
|
||||
* @property {object} _anims - An internal object that stores all of the Animation instances.
|
||||
* @private
|
||||
*/
|
||||
this._anims = {};
|
||||
|
||||
/**
|
||||
* @property {object} _outputFrames - An internal object to help avoid gc.
|
||||
* @private
|
||||
*/
|
||||
this._outputFrames = [];
|
||||
|
||||
};
|
||||
|
||||
Phaser.AnimationManager.prototype = {
|
||||
|
||||
/**
|
||||
* Loads FrameData into the internal temporary vars and resets the frame index to zero.
|
||||
* This is called automatically when a new Sprite is created.
|
||||
*
|
||||
* @method Phaser.AnimationManager#loadFrameData
|
||||
* @private
|
||||
* @param {Phaser.FrameData} frameData - The FrameData set to load.
|
||||
*/
|
||||
loadFrameData: function (frameData) {
|
||||
|
||||
this._frameData = frameData;
|
||||
this.frame = 0;
|
||||
this.isLoaded = true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new animation under the given key. Optionally set the frames, frame rate and loop.
|
||||
* Animations added in this way are played back with the play function.
|
||||
*
|
||||
* @method Phaser.AnimationManager#add
|
||||
* @param {string} name - The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk".
|
||||
* @param {Array} [frames=null] - An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used.
|
||||
* @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second.
|
||||
* @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once.
|
||||
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings?
|
||||
* @return {Phaser.Animation} The Animation object that was created.
|
||||
*/
|
||||
add: function (name, frames, frameRate, loop, useNumericIndex) {
|
||||
|
||||
if (this._frameData == null)
|
||||
{
|
||||
console.warn('No FrameData available for Phaser.Animation ' + name);
|
||||
return;
|
||||
}
|
||||
|
||||
frameRate = frameRate || 60;
|
||||
|
||||
if (typeof loop === 'undefined') { loop = false; }
|
||||
|
||||
// If they didn't set the useNumericIndex then let's at least try and guess it
|
||||
if (typeof useNumericIndex === 'undefined')
|
||||
{
|
||||
if (frames && typeof frames[0] === 'number')
|
||||
{
|
||||
useNumericIndex = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
useNumericIndex = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the signals the AnimationManager will emit
|
||||
if (this.sprite.events.onAnimationStart == null)
|
||||
{
|
||||
this.sprite.events.onAnimationStart = new Phaser.Signal();
|
||||
this.sprite.events.onAnimationComplete = new Phaser.Signal();
|
||||
this.sprite.events.onAnimationLoop = new Phaser.Signal();
|
||||
}
|
||||
|
||||
this._outputFrames.length = 0;
|
||||
|
||||
this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames);
|
||||
|
||||
this._anims[name] = new Phaser.Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop);
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
||||
return this._anims[name];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether the frames in the given array are valid and exist.
|
||||
*
|
||||
* @method Phaser.AnimationManager#validateFrames
|
||||
* @param {Array} frames - An array of frames to be validated.
|
||||
* @param {boolean} [useNumericIndex=true] - Validate the frames based on their numeric index (true) or string index (false)
|
||||
* @return {boolean} True if all given Frames are valid, otherwise false.
|
||||
*/
|
||||
validateFrames: function (frames, useNumericIndex) {
|
||||
|
||||
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
if (useNumericIndex === true)
|
||||
{
|
||||
if (frames[i] > this._frameData.total)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._frameData.checkFrameName(frames[i]) === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add()
|
||||
* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.
|
||||
*
|
||||
* @method Phaser.AnimationManager#play
|
||||
* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump".
|
||||
* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
|
||||
* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
|
||||
* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
|
||||
* @return {Phaser.Animation} A reference to playing Animation instance.
|
||||
*/
|
||||
play: function (name, frameRate, loop, killOnComplete) {
|
||||
|
||||
if (this._anims[name])
|
||||
{
|
||||
if (this.currentAnim == this._anims[name])
|
||||
{
|
||||
if (this.currentAnim.isPlaying === false)
|
||||
{
|
||||
this.currentAnim.paused = false;
|
||||
return this.currentAnim.play(frameRate, loop, killOnComplete);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentAnim.paused = false;
|
||||
return this.currentAnim.play(frameRate, loop, killOnComplete);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped.
|
||||
* The currentAnim property of the AnimationManager is automatically set to the animation given.
|
||||
*
|
||||
* @method Phaser.AnimationManager#stop
|
||||
* @param {string} [name=null] - The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped.
|
||||
* @param {boolean} [resetFrame=false] - When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false)
|
||||
*/
|
||||
stop: function (name, resetFrame) {
|
||||
|
||||
if (typeof resetFrame == 'undefined') { resetFrame = false; }
|
||||
|
||||
if (typeof name == 'string')
|
||||
{
|
||||
if (this._anims[name])
|
||||
{
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentAnim.stop(resetFrame);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.currentAnim)
|
||||
{
|
||||
this.currentAnim.stop(resetFrame);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events.
|
||||
*
|
||||
* @method Phaser.AnimationManager#update
|
||||
* @protected
|
||||
* @return {boolean} True if a new animation frame has been set, otherwise false.
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
if (this.updateIfVisible && this.sprite.visible === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.currentAnim && this.currentAnim.update() === true)
|
||||
{
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this.sprite.currentFrame = this.currentFrame;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an animation that was previously added by name.
|
||||
*
|
||||
* @method Phaser.AnimationManager#getAnimation
|
||||
* @param {string} name - The name of the animation to be returned, e.g. "fire".
|
||||
* @return {Phaser.Animation} The Animation instance, if found, otherwise null.
|
||||
*/
|
||||
getAnimation: function (name) {
|
||||
|
||||
if (typeof name == 'string')
|
||||
{
|
||||
if (this._anims[name])
|
||||
{
|
||||
return this._anims[name];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Refreshes the current frame data back to the parent Sprite and also resets the texture data.
|
||||
*
|
||||
* @method Phaser.AnimationManager#refreshFrame
|
||||
*/
|
||||
refreshFrame: function () {
|
||||
|
||||
this.sprite.currentFrame = this.currentFrame;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
|
||||
*
|
||||
* @method Phaser.AnimationManager#destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
this._anims = {};
|
||||
this._frameData = null;
|
||||
this._frameIndex = 0;
|
||||
this.currentAnim = null;
|
||||
this.currentFrame = null;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.AnimationManager.prototype.constructor = Phaser.AnimationManager;
|
||||
|
||||
/**
|
||||
* @name Phaser.AnimationManager#frameData
|
||||
* @property {Phaser.FrameData} frameData - The current animations FrameData.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, 'frameData', {
|
||||
|
||||
get: function () {
|
||||
return this._frameData;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.AnimationManager#frameTotal
|
||||
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, 'frameTotal', {
|
||||
|
||||
get: function () {
|
||||
|
||||
if (this._frameData)
|
||||
{
|
||||
return this._frameData.total;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.AnimationManager#paused
|
||||
* @property {boolean} paused - Gets and sets the paused state of the current animation.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, 'paused', {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.currentAnim.isPaused;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.currentAnim.paused = value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.AnimationManager#frame
|
||||
* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, 'frame', {
|
||||
|
||||
get: function () {
|
||||
|
||||
if (this.currentFrame)
|
||||
{
|
||||
return this._frameIndex;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null)
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
this._frameIndex = value;
|
||||
this.sprite.currentFrame = this.currentFrame;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.AnimationManager#frameName
|
||||
* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display.
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', {
|
||||
|
||||
get: function () {
|
||||
|
||||
if (this.currentFrame)
|
||||
{
|
||||
return this.currentFrame.name;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null)
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrameByName(value);
|
||||
this._frameIndex = this.currentFrame.index;
|
||||
this.sprite.currentFrame = this.currentFrame;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.warn('Cannot set frameName: ' + value);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,820 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: animation/AnimationParser.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: animation/AnimationParser.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
|
||||
*
|
||||
* @class Phaser.AnimationParser
|
||||
*/
|
||||
Phaser.AnimationParser = {
|
||||
|
||||
/**
|
||||
* Parse a Sprite Sheet and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.AnimationParser.spriteSheet
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {string} key - The Game.Cache asset key of the Sprite Sheet image.
|
||||
* @param {number} frameWidth - The fixed width of each frame of the animation.
|
||||
* @param {number} frameHeight - The fixed height of each frame of the animation.
|
||||
* @param {number} [frameMax=-1] - The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames".
|
||||
* @param {number} [margin=0] - If the frames have been drawn with a margin, specify the amount here.
|
||||
* @param {number} [spacing=0] - If the frames have been drawn with spacing between them, specify the amount here.
|
||||
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
spriteSheet: function (game, key, frameWidth, frameHeight, frameMax, margin, spacing) {
|
||||
|
||||
// How big is our image?
|
||||
var img = game.cache.getImage(key);
|
||||
|
||||
if (img == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var width = img.width;
|
||||
var height = img.height;
|
||||
|
||||
if (frameWidth <= 0)
|
||||
{
|
||||
frameWidth = Math.floor(-width / Math.min(-1, frameWidth));
|
||||
}
|
||||
|
||||
if (frameHeight <= 0)
|
||||
{
|
||||
frameHeight = Math.floor(-height / Math.min(-1, frameHeight));
|
||||
}
|
||||
|
||||
var row = Math.round(width / frameWidth);
|
||||
var column = Math.round(height / frameHeight);
|
||||
var total = row * column;
|
||||
|
||||
if (frameMax !== -1)
|
||||
{
|
||||
total = frameMax;
|
||||
}
|
||||
|
||||
// Zero or smaller than frame sizes?
|
||||
if (width === 0 || height === 0 || width < frameWidth || height < frameHeight || total === 0)
|
||||
{
|
||||
console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Let's create some frames then
|
||||
var data = new Phaser.FrameData();
|
||||
var x = margin;
|
||||
var y = margin;
|
||||
|
||||
for (var i = 0; i < total; i++)
|
||||
{
|
||||
var uuid = game.rnd.uuid();
|
||||
|
||||
data.addFrame(new Phaser.Frame(i, x, y, frameWidth, frameHeight, '', uuid));
|
||||
|
||||
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[key], {
|
||||
x: x,
|
||||
y: y,
|
||||
width: frameWidth,
|
||||
height: frameHeight
|
||||
});
|
||||
|
||||
x += frameWidth + spacing;
|
||||
|
||||
if (x === width)
|
||||
{
|
||||
x = margin;
|
||||
y += frameHeight + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.AnimationParser.JSONData
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} json - The JSON data from the Texture Atlas. Must be in Array format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
JSONData: function (game, json, cacheKey) {
|
||||
|
||||
// Malformed?
|
||||
if (!json['frames'])
|
||||
{
|
||||
console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array");
|
||||
console.log(json);
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's create some frames then
|
||||
var data = new Phaser.FrameData();
|
||||
|
||||
// By this stage frames is a fully parsed array
|
||||
var frames = json['frames'];
|
||||
var newFrame;
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
var uuid = game.rnd.uuid();
|
||||
|
||||
newFrame = data.addFrame(new Phaser.Frame(
|
||||
i,
|
||||
frames[i].frame.x,
|
||||
frames[i].frame.y,
|
||||
frames[i].frame.w,
|
||||
frames[i].frame.h,
|
||||
frames[i].filename,
|
||||
uuid
|
||||
));
|
||||
|
||||
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], {
|
||||
x: frames[i].frame.x,
|
||||
y: frames[i].frame.y,
|
||||
width: frames[i].frame.w,
|
||||
height: frames[i].frame.h
|
||||
});
|
||||
|
||||
if (frames[i].trimmed)
|
||||
{
|
||||
newFrame.setTrim(
|
||||
frames[i].trimmed,
|
||||
frames[i].sourceSize.w,
|
||||
frames[i].sourceSize.h,
|
||||
frames[i].spriteSourceSize.x,
|
||||
frames[i].spriteSourceSize.y,
|
||||
frames[i].spriteSourceSize.w,
|
||||
frames[i].spriteSourceSize.h
|
||||
);
|
||||
|
||||
// We had to hack Pixi to get this to work :(
|
||||
PIXI.TextureCache[uuid].trimmed = true;
|
||||
PIXI.TextureCache[uuid].trim.x = frames[i].spriteSourceSize.x;
|
||||
PIXI.TextureCache[uuid].trim.y = frames[i].spriteSourceSize.y;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.AnimationParser.JSONDataHash
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} json - The JSON data from the Texture Atlas. Must be in JSON Hash format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
JSONDataHash: function (game, json, cacheKey) {
|
||||
|
||||
// Malformed?
|
||||
if (!json['frames'])
|
||||
{
|
||||
console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object");
|
||||
console.log(json);
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's create some frames then
|
||||
var data = new Phaser.FrameData();
|
||||
|
||||
// By this stage frames is a fully parsed array
|
||||
var frames = json['frames'];
|
||||
var newFrame;
|
||||
var i = 0;
|
||||
|
||||
for (var key in frames)
|
||||
{
|
||||
var uuid = game.rnd.uuid();
|
||||
|
||||
newFrame = data.addFrame(new Phaser.Frame(
|
||||
i,
|
||||
frames[key].frame.x,
|
||||
frames[key].frame.y,
|
||||
frames[key].frame.w,
|
||||
frames[key].frame.h,
|
||||
key,
|
||||
uuid
|
||||
));
|
||||
|
||||
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], {
|
||||
x: frames[key].frame.x,
|
||||
y: frames[key].frame.y,
|
||||
width: frames[key].frame.w,
|
||||
height: frames[key].frame.h
|
||||
});
|
||||
|
||||
if (frames[key].trimmed)
|
||||
{
|
||||
newFrame.setTrim(
|
||||
frames[key].trimmed,
|
||||
frames[key].sourceSize.w,
|
||||
frames[key].sourceSize.h,
|
||||
frames[key].spriteSourceSize.x,
|
||||
frames[key].spriteSourceSize.y,
|
||||
frames[key].spriteSourceSize.w,
|
||||
frames[key].spriteSourceSize.h
|
||||
);
|
||||
|
||||
// We had to hack Pixi to get this to work :(
|
||||
PIXI.TextureCache[uuid].trimmed = true;
|
||||
PIXI.TextureCache[uuid].trim.x = frames[key].spriteSourceSize.x;
|
||||
PIXI.TextureCache[uuid].trim.y = frames[key].spriteSourceSize.y;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the XML data and extract the animation frame data from it.
|
||||
*
|
||||
* @method Phaser.AnimationParser.XMLData
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} xml - The XML data from the Texture Atlas. Must be in Starling XML format.
|
||||
* @param {string} cacheKey - The Game.Cache asset key of the texture image.
|
||||
* @return {Phaser.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
XMLData: function (game, xml, cacheKey) {
|
||||
|
||||
// Malformed?
|
||||
if (!xml.getElementsByTagName('TextureAtlas'))
|
||||
{
|
||||
console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's create some frames then
|
||||
var data = new Phaser.FrameData();
|
||||
var frames = xml.getElementsByTagName('SubTexture');
|
||||
var newFrame;
|
||||
|
||||
var uuid;
|
||||
var name;
|
||||
var frame;
|
||||
var x;
|
||||
var y;
|
||||
var width;
|
||||
var height;
|
||||
var frameX;
|
||||
var frameY;
|
||||
var frameWidth;
|
||||
var frameHeight;
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
uuid = game.rnd.uuid();
|
||||
|
||||
frame = frames[i].attributes;
|
||||
|
||||
name = frame.name.nodeValue;
|
||||
x = parseInt(frame.x.nodeValue, 10);
|
||||
y = parseInt(frame.y.nodeValue, 10);
|
||||
width = parseInt(frame.width.nodeValue, 10);
|
||||
height = parseInt(frame.height.nodeValue, 10);
|
||||
|
||||
frameX = null;
|
||||
frameY = null;
|
||||
|
||||
if (frame.frameX)
|
||||
{
|
||||
frameX = Math.abs(parseInt(frame.frameX.nodeValue, 10));
|
||||
frameY = Math.abs(parseInt(frame.frameY.nodeValue, 10));
|
||||
frameWidth = parseInt(frame.frameWidth.nodeValue, 10);
|
||||
frameHeight = parseInt(frame.frameHeight.nodeValue, 10);
|
||||
}
|
||||
|
||||
newFrame = data.addFrame(new Phaser.Frame(i, x, y, width, height, name, uuid));
|
||||
|
||||
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], {
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
});
|
||||
|
||||
// Trimmed?
|
||||
if (frameX !== null || frameY !== null)
|
||||
{
|
||||
newFrame.setTrim(true, width, height, frameX, frameY, frameWidth, frameHeight);
|
||||
|
||||
PIXI.TextureCache[uuid].realSize = { x: frameX, y: frameY, w: frameWidth, h: frameHeight };
|
||||
|
||||
// We had to hack Pixi to get this to work :(
|
||||
PIXI.TextureCache[uuid].trimmed = true;
|
||||
PIXI.TextureCache[uuid].trim.x = frameX;
|
||||
PIXI.TextureCache[uuid].trim.y = frameY;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,726 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: gameobjects/BitmapText.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: gameobjects/BitmapText.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new BitmapText object.
|
||||
*
|
||||
* @class Phaser.BitmapText
|
||||
*
|
||||
* @classdesc BitmapText objects work by taking a texture file and an XML file that describes the font layout.
|
||||
*
|
||||
* On Windows you can use the free app BMFont: http://www.angelcode.com/products/bmfont/
|
||||
*
|
||||
* On OS X we recommend Glyph Designer: http://www.71squared.com/en/glyphdesigner
|
||||
*
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {number} x - X position of the new bitmapText object.
|
||||
* @param {number} y - Y position of the new bitmapText object.
|
||||
* @param {string} text - The actual text that will be written.
|
||||
* @param {object} style - The style object containing style attributes like font, font size , etc.
|
||||
*/
|
||||
Phaser.BitmapText = function (game, x, y, text, style) {
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
text = text || '';
|
||||
style = style || '';
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
|
||||
* @default
|
||||
*/
|
||||
this.alive = true;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Group} group - The parent Group of this BitmapText.
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - The user defined name given to this BitmapText.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* @property {number} type - The const type of this object.
|
||||
* @readonly
|
||||
*/
|
||||
this.type = Phaser.BITMAPTEXT;
|
||||
|
||||
PIXI.BitmapText.call(this, text, style);
|
||||
|
||||
/**
|
||||
* @property {number} position.x - The x position of this object.
|
||||
*/
|
||||
this.position.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} position.y - The y position of this object.
|
||||
*/
|
||||
this.position.y = y;
|
||||
|
||||
/**
|
||||
* The anchor sets the origin point of the texture.
|
||||
* The default is 0,0 this means the textures origin is the top left
|
||||
* Setting than anchor to 0.5,0.5 means the textures origin is centered
|
||||
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
|
||||
*
|
||||
* @property {Phaser.Point} anchor - The anchor around which rotation and scaling takes place.
|
||||
*/
|
||||
this.anchor = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} scale - The scale of the object when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc.
|
||||
*/
|
||||
this.scale = new Phaser.Point(1, 1);
|
||||
|
||||
/**
|
||||
* @property {object} _cache - A mini cache for storing all of the calculated values.
|
||||
* @private
|
||||
*/
|
||||
this._cache = {
|
||||
|
||||
dirty: false,
|
||||
|
||||
// Transform cache
|
||||
a00: 1,
|
||||
a01: 0,
|
||||
a02: x,
|
||||
a10: 0,
|
||||
a11: 1,
|
||||
a12: y,
|
||||
id: 1,
|
||||
|
||||
// The previous calculated position
|
||||
x: -1,
|
||||
y: -1,
|
||||
|
||||
// The actual scale values based on the worldTransform
|
||||
scaleX: 1,
|
||||
scaleY: 1
|
||||
|
||||
};
|
||||
|
||||
this._cache.x = this.x;
|
||||
this._cache.y = this.y;
|
||||
|
||||
};
|
||||
|
||||
Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
|
||||
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
|
||||
|
||||
/**
|
||||
* Automatically called by World.update
|
||||
* @method Phaser.BitmapText.prototype.update
|
||||
*/
|
||||
Phaser.BitmapText.prototype.update = function() {
|
||||
|
||||
if (!this.exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._cache.dirty = false;
|
||||
|
||||
this._cache.x = this.x;
|
||||
this._cache.y = this.y;
|
||||
|
||||
if (this.position.x != this._cache.x || this.position.y != this._cache.y)
|
||||
{
|
||||
this.position.x = this._cache.x;
|
||||
this.position.y = this._cache.y;
|
||||
this._cache.dirty = true;
|
||||
}
|
||||
|
||||
this.pivot.x = this.anchor.x * this.width;
|
||||
this.pivot.y = this.anchor.y * this.height;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @method Phaser.BitmapText.prototype.destroy
|
||||
*/
|
||||
Phaser.BitmapText.prototype.destroy = function() {
|
||||
|
||||
if (this.group)
|
||||
{
|
||||
this.group.remove(this);
|
||||
}
|
||||
|
||||
if (this.canvas && this.canvas.parentNode)
|
||||
{
|
||||
this.canvas.parentNode.removeChild(this.canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.canvas = null;
|
||||
this.context = null;
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
|
||||
this.group = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the rotation of the BitmapText, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
||||
* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
|
||||
* If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
|
||||
* @name Phaser.BitmapText#angle
|
||||
* @property {number} angle - Gets or sets the angle of rotation in degrees.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
||||
|
||||
get: function() {
|
||||
return Phaser.Math.radToDeg(this.rotation);
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.rotation = Phaser.Math.degToRad(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The x coordinate of this object in world space.
|
||||
* @name Phaser.BitmapText#x
|
||||
* @property {number} x - The x coordinate of this object in world space.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
|
||||
|
||||
get: function() {
|
||||
return this.position.x;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.x = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The y coordinate of this object in world space.
|
||||
* @name Phaser.BitmapText#y
|
||||
* @property {number} y - The y coordinate of this object in world space.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'y', {
|
||||
|
||||
get: function() {
|
||||
return this.position.y;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.y = value;
|
||||
}
|
||||
|
||||
});
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,910 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: core/Camera.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: core/Camera.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view.
|
||||
* The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y
|
||||
*
|
||||
* @class Phaser.Camera
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Game reference to the currently running game.
|
||||
* @param {number} id - Not being used at the moment, will be when Phaser supports multiple camera
|
||||
* @param {number} x - Position of the camera on the X axis
|
||||
* @param {number} y - Position of the camera on the Y axis
|
||||
* @param {number} width - The width of the view rectangle
|
||||
* @param {number} height - The height of the view rectangle
|
||||
*/
|
||||
Phaser.Camera = function (game, id, x, y, width, height) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.World} world - A reference to the game world.
|
||||
*/
|
||||
this.world = game.world;
|
||||
|
||||
/**
|
||||
* @property {number} id - Reserved for future multiple camera set-ups.
|
||||
* @default
|
||||
*/
|
||||
this.id = 0;
|
||||
|
||||
/**
|
||||
* Camera view.
|
||||
* The view into the world we wish to render (by default the game dimensions).
|
||||
* The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render.
|
||||
* Objects outside of this view are not rendered if set to camera cull.
|
||||
* @property {Phaser.Rectangle} view
|
||||
*/
|
||||
this.view = new Phaser.Rectangle(x, y, width, height);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} screenView - Used by Sprites to work out Camera culling.
|
||||
*/
|
||||
this.screenView = new Phaser.Rectangle(x, y, width, height);
|
||||
|
||||
/**
|
||||
* The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World.
|
||||
* The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound
|
||||
* at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the center of the world.
|
||||
* @property {Phaser.Rectangle} bounds - The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere.
|
||||
*/
|
||||
this.bounds = new Phaser.Rectangle(x, y, width, height);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving.
|
||||
*/
|
||||
this.deadzone = null;
|
||||
|
||||
/**
|
||||
* @property {boolean} visible - Whether this camera is visible or not.
|
||||
* @default
|
||||
*/
|
||||
this.visible = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not.
|
||||
*/
|
||||
this.atLimit = { x: false, y: false };
|
||||
|
||||
/**
|
||||
* @property {Phaser.Sprite} target - If the camera is tracking a Sprite, this is a reference to it, otherwise null.
|
||||
* @default
|
||||
*/
|
||||
this.target = null;
|
||||
|
||||
/**
|
||||
* @property {number} edge - Edge property.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._edge = 0;
|
||||
|
||||
/**
|
||||
* @property {PIXI.DisplayObject} displayObject - The display object to which all game objects are added. Set by World.boot
|
||||
*/
|
||||
this.displayObject = null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Camera.FOLLOW_LOCKON = 0;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Camera.FOLLOW_PLATFORMER = 1;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Camera.FOLLOW_TOPDOWN = 2;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3;
|
||||
|
||||
Phaser.Camera.prototype = {
|
||||
|
||||
/**
|
||||
* Tells this camera which sprite to follow.
|
||||
* @method Phaser.Camera#follow
|
||||
* @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything.
|
||||
* @param {number} [style] Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
|
||||
*/
|
||||
follow: function (target, style) {
|
||||
|
||||
if (typeof style === "undefined") { style = Phaser.Camera.FOLLOW_LOCKON; }
|
||||
|
||||
this.target = target;
|
||||
|
||||
var helper;
|
||||
|
||||
switch (style) {
|
||||
|
||||
case Phaser.Camera.FOLLOW_PLATFORMER:
|
||||
var w = this.width / 8;
|
||||
var h = this.height / 3;
|
||||
this.deadzone = new Phaser.Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h);
|
||||
break;
|
||||
|
||||
case Phaser.Camera.FOLLOW_TOPDOWN:
|
||||
helper = Math.max(this.width, this.height) / 4;
|
||||
this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
|
||||
break;
|
||||
|
||||
case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT:
|
||||
helper = Math.max(this.width, this.height) / 8;
|
||||
this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
|
||||
break;
|
||||
|
||||
case Phaser.Camera.FOLLOW_LOCKON:
|
||||
this.deadzone = null;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.deadzone = null;
|
||||
break;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Move the camera focus on a display object instantly.
|
||||
* @method Phaser.Camera#focusOn
|
||||
* @param {any} displayObject - The display object to focus the camera on. Must have visible x/y properties.
|
||||
*/
|
||||
focusOn: function (displayObject) {
|
||||
|
||||
this.setPosition(Math.round(displayObject.x - this.view.halfWidth), Math.round(displayObject.y - this.view.halfHeight));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Move the camera focus on a location instantly.
|
||||
* @method Phaser.Camera#focusOnXY
|
||||
* @param {number} x - X position.
|
||||
* @param {number} y - Y position.
|
||||
*/
|
||||
focusOnXY: function (x, y) {
|
||||
|
||||
this.setPosition(Math.round(x - this.view.halfWidth), Math.round(y - this.view.halfHeight));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Update focusing and scrolling.
|
||||
* @method Phaser.Camera#update
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
if (this.target)
|
||||
{
|
||||
this.updateTarget();
|
||||
}
|
||||
|
||||
if (this.bounds)
|
||||
{
|
||||
this.checkBounds();
|
||||
}
|
||||
|
||||
this.displayObject.position.x = -this.view.x;
|
||||
this.displayObject.position.y = -this.view.y;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal method
|
||||
* @method Phaser.Camera#updateTarget
|
||||
* @private
|
||||
*/
|
||||
updateTarget: function () {
|
||||
|
||||
if (this.deadzone)
|
||||
{
|
||||
this._edge = this.target.x - this.deadzone.x;
|
||||
|
||||
if (this.view.x > this._edge)
|
||||
{
|
||||
this.view.x = this._edge;
|
||||
}
|
||||
|
||||
this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width;
|
||||
|
||||
if (this.view.x < this._edge)
|
||||
{
|
||||
this.view.x = this._edge;
|
||||
}
|
||||
|
||||
this._edge = this.target.y - this.deadzone.y;
|
||||
|
||||
if (this.view.y > this._edge)
|
||||
{
|
||||
this.view.y = this._edge;
|
||||
}
|
||||
|
||||
this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height;
|
||||
|
||||
if (this.view.y < this._edge)
|
||||
{
|
||||
this.view.y = this._edge;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.focusOnXY(this.target.x, this.target.y);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the Camera bounds to match the game world.
|
||||
* @method Phaser.Camera#setBoundsToWorld
|
||||
*/
|
||||
setBoundsToWorld: function () {
|
||||
|
||||
this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Method called to ensure the camera doesn't venture outside of the game world.
|
||||
* @method Phaser.Camera#checkWorldBounds
|
||||
*/
|
||||
checkBounds: function () {
|
||||
|
||||
this.atLimit.x = false;
|
||||
this.atLimit.y = false;
|
||||
|
||||
// Make sure we didn't go outside the cameras bounds
|
||||
if (this.view.x < this.bounds.x)
|
||||
{
|
||||
this.atLimit.x = true;
|
||||
this.view.x = this.bounds.x;
|
||||
}
|
||||
|
||||
if (this.view.right > this.bounds.right)
|
||||
{
|
||||
this.atLimit.x = true;
|
||||
this.view.x = this.bounds.right - this.width;
|
||||
}
|
||||
|
||||
if (this.view.y < this.bounds.top)
|
||||
{
|
||||
this.atLimit.y = true;
|
||||
this.view.y = this.bounds.top;
|
||||
}
|
||||
|
||||
if (this.view.bottom > this.bounds.bottom)
|
||||
{
|
||||
this.atLimit.y = true;
|
||||
this.view.y = this.bounds.bottom - this.height;
|
||||
}
|
||||
|
||||
this.view.floor();
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper function to set both the X and Y properties of the camera at once
|
||||
* without having to use game.camera.x and game.camera.y.
|
||||
*
|
||||
* @method Phaser.Camera#setPosition
|
||||
* @param {number} x - X position.
|
||||
* @param {number} y - Y position.
|
||||
*/
|
||||
setPosition: function (x, y) {
|
||||
|
||||
this.view.x = x;
|
||||
this.view.y = y;
|
||||
|
||||
if (this.bounds)
|
||||
{
|
||||
this.checkBounds();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the size of the view rectangle given the width and height in parameters.
|
||||
*
|
||||
* @method Phaser.Camera#setSize
|
||||
* @param {number} width - The desired width.
|
||||
* @param {number} height - The desired height.
|
||||
*/
|
||||
setSize: function (width, height) {
|
||||
|
||||
this.view.width = width;
|
||||
this.view.height = height;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Camera.prototype.constructor = Phaser.Camera;
|
||||
|
||||
/**
|
||||
* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds.
|
||||
* @name Phaser.Camera#x
|
||||
* @property {number} x - Gets or sets the cameras x position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Camera.prototype, "x", {
|
||||
|
||||
get: function () {
|
||||
return this.view.x;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.view.x = value;
|
||||
|
||||
if (this.bounds)
|
||||
{
|
||||
this.checkBounds();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds.
|
||||
* @name Phaser.Camera#y
|
||||
* @property {number} y - Gets or sets the cameras y position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Camera.prototype, "y", {
|
||||
|
||||
get: function () {
|
||||
return this.view.y;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.view.y = value;
|
||||
|
||||
if (this.bounds)
|
||||
{
|
||||
this.checkBounds();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The Cameras width. By default this is the same as the Game size and should not be adjusted for now.
|
||||
* @name Phaser.Camera#width
|
||||
* @property {number} width - Gets or sets the cameras width.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Camera.prototype, "width", {
|
||||
|
||||
get: function () {
|
||||
return this.view.width;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
this.view.width = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The Cameras height. By default this is the same as the Game size and should not be adjusted for now.
|
||||
* @name Phaser.Camera#height
|
||||
* @property {number} height - Gets or sets the cameras height.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Camera.prototype, "height", {
|
||||
|
||||
get: function () {
|
||||
return this.view.height;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
this.view.height = value;
|
||||
}
|
||||
|
||||
});
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,779 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: system/Canvas.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: system/Canvas.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Canvas class handles everything related to creating the `canvas` DOM tag that Phaser will use, including styles, offset and aspect ratio.
|
||||
*
|
||||
* @class Phaser.Canvas
|
||||
* @static
|
||||
*/
|
||||
Phaser.Canvas = {
|
||||
|
||||
/**
|
||||
* Creates a `canvas` DOM element. The element is not automatically added to the document.
|
||||
*
|
||||
* @method Phaser.Canvas.create
|
||||
* @param {number} [width=256] - The width of the canvas element.
|
||||
* @param {number} [height=256] - The height of the canvas element..
|
||||
* @param {string} [id=''] - If given this will be set as the ID of the canvas element, otherwise no ID will be set.
|
||||
* @return {HTMLCanvasElement} The newly created canvas element.
|
||||
*/
|
||||
create: function (width, height, id) {
|
||||
|
||||
width = width || 256;
|
||||
height = height || 256;
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
|
||||
if (typeof id === 'string')
|
||||
{
|
||||
canvas.id = id;
|
||||
}
|
||||
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
canvas.style.display = 'block';
|
||||
|
||||
return canvas;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the DOM offset values of any given element
|
||||
* @method Phaser.Canvas.getOffset
|
||||
* @param {HTMLElement} element - The targeted element that we want to retrieve the offset.
|
||||
* @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset.
|
||||
* @return {Phaser.Point} - A point objet with the offsetX and Y as its properties.
|
||||
*/
|
||||
getOffset: function (element, point) {
|
||||
|
||||
point = point || new Phaser.Point();
|
||||
|
||||
var box = element.getBoundingClientRect();
|
||||
var clientTop = element.clientTop || document.body.clientTop || 0;
|
||||
var clientLeft = element.clientLeft || document.body.clientLeft || 0;
|
||||
|
||||
// Without this check Chrome is now throwing console warnings about strict vs. quirks :(
|
||||
|
||||
var scrollTop = 0;
|
||||
var scrollLeft = 0;
|
||||
|
||||
if (document.compatMode === 'CSS1Compat')
|
||||
{
|
||||
scrollTop = window.pageYOffset || document.documentElement.scrollTop || element.scrollTop || 0;
|
||||
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || element.scrollLeft || 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollTop = window.pageYOffset || document.body.scrollTop || element.scrollTop || 0;
|
||||
scrollLeft = window.pageXOffset || document.body.scrollLeft || element.scrollLeft || 0;
|
||||
}
|
||||
|
||||
point.x = box.left + scrollLeft - clientLeft;
|
||||
point.y = box.top + scrollTop - clientTop;
|
||||
|
||||
return point;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the aspect ratio of the given canvas.
|
||||
*
|
||||
* @method Phaser.Canvas.getAspectRatio
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from.
|
||||
* @return {number} The ratio between canvas' width and height.
|
||||
*/
|
||||
getAspectRatio: function (canvas) {
|
||||
return canvas.width / canvas.height;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the background color behind the canvas. This changes the canvas style property.
|
||||
*
|
||||
* @method Phaser.Canvas.setBackgroundColor
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the background color on.
|
||||
* @param {string} [color] - The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
setBackgroundColor: function (canvas, color) {
|
||||
|
||||
color = color || 'rgb(0,0,0)';
|
||||
|
||||
canvas.style.backgroundColor = color;
|
||||
|
||||
return canvas;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
|
||||
*
|
||||
* @method Phaser.Canvas.setTouchAction
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {String} [value] - The touch action to set. Defaults to 'none'.
|
||||
* @return {HTMLCanvasElement} The source canvas.
|
||||
*/
|
||||
setTouchAction: function (canvas, value) {
|
||||
|
||||
value = value || 'none';
|
||||
|
||||
canvas.style.msTouchAction = value;
|
||||
canvas.style['ms-touch-action'] = value;
|
||||
canvas.style['touch-action'] = value;
|
||||
|
||||
return canvas;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.
|
||||
*
|
||||
* @method Phaser.Canvas.setUserSelect
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {String} [value] - The touch action to set. Defaults to 'none'.
|
||||
* @return {HTMLCanvasElement} The source canvas.
|
||||
*/
|
||||
setUserSelect: function (canvas, value) {
|
||||
|
||||
value = value || 'none';
|
||||
|
||||
canvas.style['-webkit-touch-callout'] = value;
|
||||
canvas.style['-webkit-user-select'] = value;
|
||||
canvas.style['-khtml-user-select'] = value;
|
||||
canvas.style['-moz-user-select'] = value;
|
||||
canvas.style['-ms-user-select'] = value;
|
||||
canvas.style['user-select'] = value;
|
||||
canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)';
|
||||
|
||||
return canvas;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent.
|
||||
* If no parent is given it will be added as a child of the document.body.
|
||||
*
|
||||
* @method Phaser.Canvas.addToDOM
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {string|HTMLElement} parent - The DOM element to add the canvas to.
|
||||
* @param {boolean} [overflowHidden=true] - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
addToDOM: function (canvas, parent, overflowHidden) {
|
||||
|
||||
var target;
|
||||
|
||||
if (typeof overflowHidden === 'undefined') { overflowHidden = true; }
|
||||
|
||||
if (parent)
|
||||
{
|
||||
if (typeof parent === 'string')
|
||||
{
|
||||
// hopefully an element ID
|
||||
target = document.getElementById(parent);
|
||||
}
|
||||
else if (typeof parent === 'object' && parent.nodeType === 1)
|
||||
{
|
||||
// quick test for a HTMLelement
|
||||
target = parent;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback, covers an invalid ID and a non HTMLelement object
|
||||
if (!target)
|
||||
{
|
||||
target = document.body;
|
||||
}
|
||||
|
||||
if (overflowHidden && target.style)
|
||||
{
|
||||
target.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
target.appendChild(canvas);
|
||||
|
||||
return canvas;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the transform of the given canvas to the matrix values provided.
|
||||
*
|
||||
* @method Phaser.Canvas.setTransform
|
||||
* @param {CanvasRenderingContext2D} context - The context to set the transform on.
|
||||
* @param {number} translateX - The value to translate horizontally by.
|
||||
* @param {number} translateY - The value to translate vertically by.
|
||||
* @param {number} scaleX - The value to scale horizontally by.
|
||||
* @param {number} scaleY - The value to scale vertically by.
|
||||
* @param {number} skewX - The value to skew horizontaly by.
|
||||
* @param {number} skewY - The value to skew vertically by.
|
||||
* @return {CanvasRenderingContext2D} Returns the source context.
|
||||
*/
|
||||
setTransform: function (context, translateX, translateY, scaleX, scaleY, skewX, skewY) {
|
||||
|
||||
context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
|
||||
|
||||
return context;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the Image Smoothing property on the given context. Set to false to disable image smoothing.
|
||||
* By default browsers have image smoothing enabled, which isn't always what you visually want, especially
|
||||
* when using pixel art in a game. Note that this sets the property on the context itself, so that any image
|
||||
* drawn to the context will be affected. This sets the property across all current browsers but support is
|
||||
* patchy on earlier browsers, especially on mobile.
|
||||
*
|
||||
* @method Phaser.Canvas.setSmoothingEnabled
|
||||
* @param {CanvasRenderingContext2D} context - The context to enable or disable the image smoothing on.
|
||||
* @param {boolean} value - If set to true it will enable image smoothing, false will disable it.
|
||||
* @return {CanvasRenderingContext2D} Returns the source context.
|
||||
*/
|
||||
setSmoothingEnabled: function (context, value) {
|
||||
|
||||
context['imageSmoothingEnabled'] = value;
|
||||
context['mozImageSmoothingEnabled'] = value;
|
||||
context['oImageSmoothingEnabled'] = value;
|
||||
context['webkitImageSmoothingEnabled'] = value;
|
||||
context['msImageSmoothingEnabled'] = value;
|
||||
|
||||
return context;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast on webkit').
|
||||
* Note that if this doesn't given the desired result then see the setSmoothingEnabled.
|
||||
*
|
||||
* @method Phaser.Canvas.setImageRenderingCrisp
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set image-rendering crisp on.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
setImageRenderingCrisp: function (canvas) {
|
||||
|
||||
canvas.style['image-rendering'] = 'optimizeSpeed';
|
||||
canvas.style['image-rendering'] = 'crisp-edges';
|
||||
canvas.style['image-rendering'] = '-moz-crisp-edges';
|
||||
canvas.style['image-rendering'] = '-webkit-optimize-contrast';
|
||||
canvas.style['image-rendering'] = 'optimize-contrast';
|
||||
canvas.style.msInterpolationMode = 'nearest-neighbor';
|
||||
|
||||
return canvas;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto').
|
||||
* Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.
|
||||
*
|
||||
* @method Phaser.Canvas.setImageRenderingBicubic
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set image-rendering bicubic on.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
setImageRenderingBicubic: function (canvas) {
|
||||
|
||||
canvas.style['image-rendering'] = 'auto';
|
||||
canvas.style.msInterpolationMode = 'bicubic';
|
||||
|
||||
return canvas;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,970 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: geom/Circle.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: geom/Circle.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created.
|
||||
* @class Circle
|
||||
* @classdesc Phaser - Circle
|
||||
* @constructor
|
||||
* @param {number} [x=0] - The x coordinate of the center of the circle.
|
||||
* @param {number} [y=0] - The y coordinate of the center of the circle.
|
||||
* @param {number} [diameter=0] - The diameter of the circle.
|
||||
* @return {Phaser.Circle} This circle object
|
||||
*/
|
||||
Phaser.Circle = function (x, y, diameter) {
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
diameter = diameter || 0;
|
||||
|
||||
/**
|
||||
* @property {number} x - The x coordinate of the center of the circle.
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} y - The y coordinate of the center of the circle.
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* @property {number} _diameter - The diameter of the circle.
|
||||
* @private
|
||||
*/
|
||||
this._diameter = diameter;
|
||||
|
||||
if (diameter > 0)
|
||||
{
|
||||
/**
|
||||
* @property {number} _radius - The radius of the circle.
|
||||
* @private
|
||||
*/
|
||||
this._radius = diameter * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._radius = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Circle.prototype = {
|
||||
|
||||
/**
|
||||
* The circumference of the circle.
|
||||
* @method Phaser.Circle#circumference
|
||||
* @return {number}
|
||||
*/
|
||||
circumference: function () {
|
||||
return 2 * (Math.PI * this._radius);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the members of Circle to the specified values.
|
||||
* @method Phaser.Circle#setTo
|
||||
* @param {number} x - The x coordinate of the center of the circle.
|
||||
* @param {number} y - The y coordinate of the center of the circle.
|
||||
* @param {number} diameter - The diameter of the circle in pixels.
|
||||
* @return {Circle} This circle object.
|
||||
*/
|
||||
setTo: function (x, y, diameter) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this._diameter = diameter;
|
||||
this._radius = diameter * 0.5;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Copies the x, y and diameter properties from any given object to this Circle.
|
||||
* @method Phaser.Circle#copyFrom
|
||||
* @param {any} source - The object to copy from.
|
||||
* @return {Circle} This Circle object.
|
||||
*/
|
||||
copyFrom: function (source) {
|
||||
return this.setTo(source.x, source.y, source.diameter);
|
||||
},
|
||||
|
||||
/**
|
||||
* Copies the x, y and diameter properties from this Circle to any given object.
|
||||
* @method Phaser.Circle#copyTo
|
||||
* @param {any} dest - The object to copy to.
|
||||
* @return {Object} This dest object.
|
||||
*/
|
||||
copyTo: function(dest) {
|
||||
dest.x = this.x;
|
||||
dest.y = this.y;
|
||||
dest.diameter = this._diameter;
|
||||
return dest;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the distance from the center of the Circle object to the given object
|
||||
* (can be Circle, Point or anything with x/y properties)
|
||||
* @method Phaser.Circle#distance
|
||||
* @param {object} dest - The target object. Must have visible x and y properties that represent the center of the 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.
|
||||
*/
|
||||
distance: function (dest, round) {
|
||||
|
||||
if (typeof round === "undefined") { round = false }
|
||||
|
||||
if (round)
|
||||
{
|
||||
return Phaser.Math.distanceRound(this.x, this.y, dest.x, dest.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Phaser.Math.distance(this.x, this.y, dest.x, dest.y);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object.
|
||||
* @method Phaser.Circle#clone
|
||||
* @param {Phaser.Circle} out - Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.
|
||||
* @return {Phaser.Circle} The cloned Circle object.
|
||||
*/
|
||||
clone: function(out) {
|
||||
|
||||
if (typeof out === "undefined") { out = new Phaser.Circle(); }
|
||||
|
||||
return out.setTo(this.x, this.y, this.diameter);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true if the given x/y coordinates are within this Circle object.
|
||||
* @method Phaser.Circle#contains
|
||||
* @param {number} x - The X value of the coordinate to test.
|
||||
* @param {number} y - The Y value of the coordinate to test.
|
||||
* @return {boolean} True if the coordinates are within this circle, otherwise false.
|
||||
*/
|
||||
contains: function (x, y) {
|
||||
return Phaser.Circle.contains(this, x, y);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
|
||||
* @method Phaser.Circle#circumferencePoint
|
||||
* @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 {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created.
|
||||
* @return {Phaser.Point} The Point object holding the result.
|
||||
*/
|
||||
circumferencePoint: function (angle, asDegrees, out) {
|
||||
return Phaser.Circle.circumferencePoint(this, angle, asDegrees, out);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts.
|
||||
* @method Phaser.Circle#offset
|
||||
* @param {number} dx - Moves the x value of the Circle object by this amount.
|
||||
* @param {number} dy - Moves the y value of the Circle object by this amount.
|
||||
* @return {Circle} This Circle object.
|
||||
*/
|
||||
offset: function (dx, dy) {
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter.
|
||||
* @method Phaser.Circle#offsetPoint
|
||||
* @param {Point} point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties).
|
||||
* @return {Circle} This Circle object.
|
||||
*/
|
||||
offsetPoint: function (point) {
|
||||
return this.offset(point.x, point.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* @method Phaser.Circle#toString
|
||||
* @return {string} a string representation of the instance.
|
||||
*/
|
||||
toString: function () {
|
||||
return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Circle.prototype.constructor = Phaser.Circle;
|
||||
|
||||
/**
|
||||
* The largest distance between any two points on the circle. The same as the radius * 2.
|
||||
* @name Phaser.Circle#diameter
|
||||
* @property {number} diameter - Gets or sets the diameter of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "diameter", {
|
||||
|
||||
get: function () {
|
||||
return this._diameter;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
if (value > 0) {
|
||||
this._diameter = value;
|
||||
this._radius = value * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.
|
||||
* @name Phaser.Circle#radius
|
||||
* @property {number} radius - Gets or sets the radius of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "radius", {
|
||||
|
||||
get: function () {
|
||||
return this._radius;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
if (value > 0) {
|
||||
this._radius = value;
|
||||
this._diameter = value * 2;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
|
||||
* @name Phaser.Circle#left
|
||||
* @propety {number} left - Gets or sets the value of the leftmost point of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "left", {
|
||||
|
||||
get: function () {
|
||||
return this.x - this._radius;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
if (value > this.x) {
|
||||
this._radius = 0;
|
||||
this._diameter = 0;
|
||||
} else {
|
||||
this.radius = this.x - value;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
|
||||
* @name Phaser.Circle#right
|
||||
* @property {number} right - Gets or sets the value of the rightmost point of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "right", {
|
||||
|
||||
get: function () {
|
||||
return this.x + this._radius;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
if (value < this.x) {
|
||||
this._radius = 0;
|
||||
this._diameter = 0;
|
||||
} else {
|
||||
this.radius = value - this.x;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter.
|
||||
* @name Phaser.Circle#top
|
||||
* @property {number} top - Gets or sets the top of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "top", {
|
||||
|
||||
get: function () {
|
||||
return this.y - this._radius;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
if (value > this.y) {
|
||||
this._radius = 0;
|
||||
this._diameter = 0;
|
||||
} else {
|
||||
this.radius = this.y - value;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.
|
||||
* @name Phaser.Circle#bottom
|
||||
* @property {number} bottom - Gets or sets the bottom of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "bottom", {
|
||||
|
||||
get: function () {
|
||||
return this.y + this._radius;
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value < this.y) {
|
||||
this._radius = 0;
|
||||
this._diameter = 0;
|
||||
} else {
|
||||
this.radius = value - this.y;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* The area of this Circle.
|
||||
* @name Phaser.Circle#area
|
||||
* @property {number} area - The area of this circle.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "area", {
|
||||
|
||||
get: function () {
|
||||
if (this._radius > 0) {
|
||||
return Math.PI * this._radius * this._radius;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false.
|
||||
* If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0.
|
||||
* @name Phaser.Circle#empty
|
||||
* @property {boolean} empty - Gets or sets the empty state of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "empty", {
|
||||
|
||||
get: function () {
|
||||
return (this._diameter === 0);
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value === true)
|
||||
{
|
||||
this.setTo(0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Return true if the given x/y coordinates are within the Circle object.
|
||||
* @method Phaser.Circle.contains
|
||||
* @param {Phaser.Circle} a - The Circle to be checked.
|
||||
* @param {number} x - The X value of the coordinate to test.
|
||||
* @param {number} y - The Y value of the coordinate to test.
|
||||
* @return {boolean} True if the coordinates are within this circle, otherwise false.
|
||||
*/
|
||||
Phaser.Circle.contains = function (a, x, y) {
|
||||
|
||||
// Check if x/y are within the bounds first
|
||||
if (x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) {
|
||||
|
||||
var dx = (a.x - x) * (a.x - x);
|
||||
var dy = (a.y - y) * (a.y - y);
|
||||
|
||||
return (dx + dy) <= (a.radius * a.radius);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the two Circle objects match. This method compares the x, y and diameter properties.
|
||||
* @method Phaser.Circle.equals
|
||||
* @param {Phaser.Circle} a - The first Circle object.
|
||||
* @param {Phaser.Circle} b - The second Circle object.
|
||||
* @return {boolean} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false.
|
||||
*/
|
||||
Phaser.Circle.equals = function (a, b) {
|
||||
return (a.x == b.x && a.y == b.y && a.diameter == b.diameter);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether the two Circle objects intersect.
|
||||
* This method checks the radius distances between the two Circle objects to see if they intersect.
|
||||
* @method Phaser.Circle.intersects
|
||||
* @param {Phaser.Circle} a - The first Circle object.
|
||||
* @param {Phaser.Circle} b - The second Circle object.
|
||||
* @return {boolean} A value of true if the specified object intersects with this Circle object; otherwise false.
|
||||
*/
|
||||
Phaser.Circle.intersects = function (a, b) {
|
||||
return (Phaser.Math.distance(a.x, a.y, b.x, b.y) <= (a.radius + b.radius));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
|
||||
* @method Phaser.Circle.circumferencePoint
|
||||
* @param {Phaser.Circle} a - The first Circle object.
|
||||
* @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 {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created.
|
||||
* @return {Phaser.Point} The Point object holding the result.
|
||||
*/
|
||||
Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) {
|
||||
|
||||
if (typeof asDegrees === "undefined") { asDegrees = false; }
|
||||
if (typeof out === "undefined") { out = new Phaser.Point(); }
|
||||
|
||||
if (asDegrees === true) {
|
||||
angle = Phaser.Math.radToDeg(angle);
|
||||
}
|
||||
|
||||
out.x = a.x + a.radius * Math.cos(angle);
|
||||
out.y = a.y + a.radius * Math.sin(angle);
|
||||
|
||||
return out;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the given Circle and Rectangle objects intersect.
|
||||
* @method Phaser.Circle.intersectsRectangle
|
||||
* @param {Phaser.Circle} c - The Circle object to test.
|
||||
* @param {Phaser.Rectangle} r - The Rectangle object to test.
|
||||
* @return {boolean} True if the two objects intersect, otherwise false.
|
||||
*/
|
||||
Phaser.Circle.intersectsRectangle = function (c, r) {
|
||||
|
||||
var cx = Math.abs(c.x - r.x - r.halfWidth);
|
||||
var xDist = r.halfWidth + c.radius;
|
||||
|
||||
if (cx > xDist) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var cy = Math.abs(c.y - r.y - r.halfHeight);
|
||||
var yDist = r.halfHeight + c.radius;
|
||||
|
||||
if (cy > yDist) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cx <= r.halfWidth || cy <= r.halfHeight) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var xCornerDist = cx - r.halfWidth;
|
||||
var yCornerDist = cy - r.halfHeight;
|
||||
var xCornerDistSq = xCornerDist * xCornerDist;
|
||||
var yCornerDistSq = yCornerDist * yCornerDist;
|
||||
var maxCornerDistSq = c.radius * c.radius;
|
||||
|
||||
return xCornerDistSq + yCornerDistSq <= maxCornerDistSq;
|
||||
|
||||
};
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,844 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: utils/Color.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: utils/Color.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* A collection of methods useful for manipulating and comparing colors.
|
||||
*
|
||||
* @class Phaser.Color
|
||||
*/
|
||||
Phaser.Color = {
|
||||
|
||||
/**
|
||||
* Given an alpha and 3 color values this will return an integer representation of it.
|
||||
*
|
||||
* @method Phaser.Color.getColor32
|
||||
* @static
|
||||
* @param {number} alpha - The Alpha value (between 0 and 255).
|
||||
* @param {number} red - The Red channel value (between 0 and 255).
|
||||
* @param {number} green - The Green channel value (between 0 and 255).
|
||||
* @param {number} blue - The Blue channel value (between 0 and 255).
|
||||
* @returns {number} A native color value integer (format: 0xAARRGGBB).
|
||||
*/
|
||||
getColor32: function (alpha, red, green, blue) {
|
||||
return alpha << 24 | red << 16 | green << 8 | blue;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given 3 color values this will return an integer representation of it.
|
||||
*
|
||||
* @method Phaser.Color.getColor
|
||||
* @static
|
||||
* @param {number} red - The Red channel value (between 0 and 255).
|
||||
* @param {number} green - The Green channel value (between 0 and 255).
|
||||
* @param {number} blue - The Blue channel value (between 0 and 255).
|
||||
* @returns {number} A native color value integer (format: 0xRRGGBB).
|
||||
*/
|
||||
getColor: function (red, green, blue) {
|
||||
return red << 16 | green << 8 | blue;
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts the given hex string into an integer color value.
|
||||
*
|
||||
* @method Phaser.Color.hexToRGB
|
||||
* @static
|
||||
* @param {string} h - The string hex color to convert.
|
||||
* @returns {number} The rgb color value.
|
||||
*/
|
||||
hexToRGB: function (h) {
|
||||
|
||||
var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h;
|
||||
|
||||
if (hex16.length==3)
|
||||
{
|
||||
hex16 = hex16.charAt(0) + hex16.charAt(0) + hex16.charAt(1) + hex16.charAt(1) + hex16.charAt(2) + hex16.charAt(2);
|
||||
}
|
||||
|
||||
var red = parseInt(hex16.substring(0, 2), 16);
|
||||
var green = parseInt(hex16.substring(2, 4), 16);
|
||||
var blue = parseInt(hex16.substring(4, 6), 16);
|
||||
|
||||
return red << 16 | green << 8 | blue;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a string containing handy information about the given color including string hex value,
|
||||
* RGB format information and HSL information. Each section starts on a newline, 3 lines in total.
|
||||
*
|
||||
* @method Phaser.Color.getColorInfo
|
||||
* @static
|
||||
* @param {number} color - A color value in the format 0xAARRGGBB.
|
||||
* @returns {string} String containing the 3 lines of information.
|
||||
*/
|
||||
getColorInfo: function (color) {
|
||||
|
||||
var argb = Phaser.Color.getRGB(color);
|
||||
var hsl = Phaser.Color.RGBtoHSV(color);
|
||||
|
||||
// Hex format
|
||||
var result = Phaser.Color.RGBtoHexstring(color) + "\n";
|
||||
|
||||
// RGB format
|
||||
result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n";
|
||||
|
||||
// HSL info
|
||||
result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness);
|
||||
|
||||
return result;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a string representation of the color in the format 0xAARRGGBB.
|
||||
*
|
||||
* @method Phaser.Color.RGBtoHexstring
|
||||
* @static
|
||||
* @param {number} color - The color to get the string representation for
|
||||
* @returns {string} A string of length 10 characters in the format 0xAARRGGBB
|
||||
*/
|
||||
RGBtoHexstring: function (color) {
|
||||
|
||||
var argb = Phaser.Color.getRGB(color);
|
||||
|
||||
return "0x" + Phaser.Color.colorToHexstring(argb.alpha) + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a string representation of the color in the format #RRGGBB.
|
||||
*
|
||||
* @method Phaser.Color.RGBtoWebstring
|
||||
* @static
|
||||
* @param {number} color - The color to get the string representation for.
|
||||
* @returns {string} A string of length 10 characters in the format 0xAARRGGBB.
|
||||
*/
|
||||
RGBtoWebstring: function (color) {
|
||||
|
||||
var argb = Phaser.Color.getRGB(color);
|
||||
|
||||
return "#" + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a string containing a hex representation of the given color.
|
||||
*
|
||||
* @method Phaser.Color.colorToHexstring
|
||||
* @static
|
||||
* @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255).
|
||||
* @returns {string} A string of length 2 characters, i.e. 255 = FF, 0 = 00.
|
||||
*/
|
||||
colorToHexstring: function (color) {
|
||||
|
||||
var digits = "0123456789ABCDEF";
|
||||
var lsd = color % 16;
|
||||
var msd = (color - lsd) / 16;
|
||||
var hexified = digits.charAt(msd) + digits.charAt(lsd);
|
||||
return hexified;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Interpolates the two given colours based on the supplied step and currentStep properties.
|
||||
* @method Phaser.Color.interpolateColor
|
||||
* @static
|
||||
* @param {number} color1 - The first color value.
|
||||
* @param {number} color2 - The second color value.
|
||||
* @param {number} steps - The number of steps to run the interpolation over.
|
||||
* @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two.
|
||||
* @param {number} alpha - The alpha of the returned color.
|
||||
* @returns {number} The interpolated color value.
|
||||
*/
|
||||
interpolateColor: function (color1, color2, steps, currentStep, alpha) {
|
||||
|
||||
if (typeof alpha === "undefined") { alpha = 255; }
|
||||
|
||||
var src1 = Phaser.Color.getRGB(color1);
|
||||
var src2 = Phaser.Color.getRGB(color2);
|
||||
var r = (((src2.red - src1.red) * currentStep) / steps) + src1.red;
|
||||
var g = (((src2.green - src1.green) * currentStep) / steps) + src1.green;
|
||||
var b = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue;
|
||||
|
||||
return Phaser.Color.getColor32(alpha, r, g, b);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Interpolates the two given colours based on the supplied step and currentStep properties.
|
||||
* @method Phaser.Color.interpolateColorWithRGB
|
||||
* @static
|
||||
* @param {number} color - The first color value.
|
||||
* @param {number} r - The red color value, between 0 and 0xFF (255).
|
||||
* @param {number} g - The green color value, between 0 and 0xFF (255).
|
||||
* @param {number} b - The blue color value, between 0 and 0xFF (255).
|
||||
* @param {number} steps - The number of steps to run the interpolation over.
|
||||
* @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two.
|
||||
* @returns {number} The interpolated color value.
|
||||
*/
|
||||
interpolateColorWithRGB: function (color, r, g, b, steps, currentStep) {
|
||||
|
||||
var src = Phaser.Color.getRGB(color);
|
||||
var or = (((r - src.red) * currentStep) / steps) + src.red;
|
||||
var og = (((g - src.green) * currentStep) / steps) + src.green;
|
||||
var ob = (((b - src.blue) * currentStep) / steps) + src.blue;
|
||||
|
||||
return Phaser.Color.getColor(or, og, ob);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Interpolates the two given colours based on the supplied step and currentStep properties.
|
||||
* @method Phaser.Color.interpolateRGB
|
||||
* @static
|
||||
* @param {number} r1 - The red color value, between 0 and 0xFF (255).
|
||||
* @param {number} g1 - The green color value, between 0 and 0xFF (255).
|
||||
* @param {number} b1 - The blue color value, between 0 and 0xFF (255).
|
||||
* @param {number} r2 - The red color value, between 0 and 0xFF (255).
|
||||
* @param {number} g2 - The green color value, between 0 and 0xFF (255).
|
||||
* @param {number} b2 - The blue color value, between 0 and 0xFF (255).
|
||||
* @param {number} steps - The number of steps to run the interpolation over.
|
||||
* @param {number} currentStep - The currentStep value. If the interpolation will take 100 steps, a currentStep value of 50 would be half-way between the two.
|
||||
* @returns {number} The interpolated color value.
|
||||
*/
|
||||
interpolateRGB: function (r1, g1, b1, r2, g2, b2, steps, currentStep) {
|
||||
|
||||
var r = (((r2 - r1) * currentStep) / steps) + r1;
|
||||
var g = (((g2 - g1) * currentStep) / steps) + g1;
|
||||
var b = (((b2 - b1) * currentStep) / steps) + b1;
|
||||
|
||||
return Phaser.Color.getColor(r, g, b);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a random color value between black and white
|
||||
* Set the min value to start each channel from the given offset.
|
||||
* Set the max value to restrict the maximum color used per channel.
|
||||
*
|
||||
* @method Phaser.Color.getRandomColor
|
||||
* @static
|
||||
* @param {number} min - The lowest value to use for the color.
|
||||
* @param {number} max - The highest value to use for the color.
|
||||
* @param {number} alpha - The alpha value of the returning color (default 255 = fully opaque).
|
||||
* @returns {number} 32-bit color value with alpha.
|
||||
*/
|
||||
getRandomColor: function (min, max, alpha) {
|
||||
|
||||
if (typeof min === "undefined") { min = 0; }
|
||||
if (typeof max === "undefined") { max = 255; }
|
||||
if (typeof alpha === "undefined") { alpha = 255; }
|
||||
|
||||
// Sanity checks
|
||||
if (max > 255) {
|
||||
return Phaser.Color.getColor(255, 255, 255);
|
||||
}
|
||||
|
||||
if (min > max) {
|
||||
return Phaser.Color.getColor(255, 255, 255);
|
||||
}
|
||||
|
||||
var red = min + Math.round(Math.random() * (max - min));
|
||||
var green = min + Math.round(Math.random() * (max - min));
|
||||
var blue = min + Math.round(Math.random() * (max - min));
|
||||
|
||||
return Phaser.Color.getColor32(alpha, red, green, blue);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the component parts of a color as an Object with the properties alpha, red, green, blue
|
||||
*
|
||||
* Alpha will only be set if it exist in the given color (0xAARRGGBB)
|
||||
*
|
||||
* @method Phaser.Color.getRGB
|
||||
* @static
|
||||
* @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).
|
||||
* @returns {object} An Object with properties: alpha, red, green, blue.
|
||||
*/
|
||||
getRGB: function (color) {
|
||||
|
||||
return {
|
||||
alpha: color >>> 24,
|
||||
red: color >> 16 & 0xFF,
|
||||
green: color >> 8 & 0xFF,
|
||||
blue: color & 0xFF
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a CSS friendly string value from the given color.
|
||||
* @method Phaser.Color.getWebRGB
|
||||
* @static
|
||||
* @param {number} color
|
||||
* @returns {string}A string in the format: 'rgba(r,g,b,a)'
|
||||
*/
|
||||
getWebRGB: function (color) {
|
||||
|
||||
var alpha = (color >>> 24) / 255;
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
|
||||
return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')';
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255.
|
||||
*
|
||||
* @method Phaser.Color.getAlpha
|
||||
* @static
|
||||
* @param {number} color - In the format 0xAARRGGBB.
|
||||
* @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
|
||||
*/
|
||||
getAlpha: function (color) {
|
||||
return color >>> 24;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1.
|
||||
*
|
||||
* @method Phaser.Color.getAlphaFloat
|
||||
* @static
|
||||
* @param {number} color - In the format 0xAARRGGBB.
|
||||
* @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
|
||||
*/
|
||||
getAlphaFloat: function (color) {
|
||||
return (color >>> 24) / 255;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255.
|
||||
*
|
||||
* @method Phaser.Color.getRed
|
||||
* @static
|
||||
* @param {number} color In the format 0xAARRGGBB.
|
||||
* @returns {number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red).
|
||||
*/
|
||||
getRed: function (color) {
|
||||
return color >> 16 & 0xFF;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255.
|
||||
*
|
||||
* @method Phaser.Color.getGreen
|
||||
* @static
|
||||
* @param {number} color - In the format 0xAARRGGBB.
|
||||
* @returns {number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green).
|
||||
*/
|
||||
getGreen: function (color) {
|
||||
return color >> 8 & 0xFF;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255.
|
||||
*
|
||||
* @method Phaser.Color.getBlue
|
||||
* @static
|
||||
* @param {number} color - In the format 0xAARRGGBB.
|
||||
* @returns {number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue).
|
||||
*/
|
||||
getBlue: function (color) {
|
||||
return color & 0xFF;
|
||||
}
|
||||
|
||||
};
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,581 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: gameobjects/DOMSprite.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: gameobjects/DOMSprite.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new DOMSprite.
|
||||
* @class Phaser.DOMSprite
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {string} id - DOM ID.
|
||||
* @param {number} x - X position of the new text object.
|
||||
* @param {number} y - Y position of the new text object.
|
||||
* @param {string} text - The actual text that will be written.
|
||||
* @param {object} style - The style object containing style attributes like font, font size ,
|
||||
*/
|
||||
Phaser.DOMSprite = function (game, element, x, y, style) {
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
style = style || '';
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
* @property {boolean} alive - This is a handy little var your game can use to determine if an object is alive or not, it doesn't effect rendering.
|
||||
* @default
|
||||
*/
|
||||
this.alive = true;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Group} group - The parent Group of this Text object.
|
||||
*/
|
||||
this.group = null;
|
||||
|
||||
/**
|
||||
* @property {string} name - The user defined name given to this object.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* @property {number} type - The const type of this object.
|
||||
* @default
|
||||
*/
|
||||
this.type = Phaser.DOMSPRITE;
|
||||
|
||||
/**
|
||||
* @property {boolean} visible - Sets the visible state of this DOMSprite.
|
||||
* @default
|
||||
*/
|
||||
this.visible = true;
|
||||
|
||||
/*
|
||||
if (parent)
|
||||
{
|
||||
if (typeof parent === 'string')
|
||||
{
|
||||
// hopefully an element ID
|
||||
target = document.getElementById(parent);
|
||||
}
|
||||
else if (typeof parent === 'object' && parent.nodeType === 1)
|
||||
{
|
||||
// quick test for a HTMLelement
|
||||
target = parent;
|
||||
}
|
||||
|
||||
if (overflowHidden)
|
||||
{
|
||||
target.style.overflow = 'hidden';
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
// Phaser.DOMSprite.prototype = Object.create(PIXI.DOMSprite.prototype);
|
||||
// Phaser.DOMSprite.prototype.constructor = Phaser.DOMSprite;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,575 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: gameobjects/Events.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: gameobjects/Events.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Phaser.Events
|
||||
*
|
||||
* @classdesc The Events component is a collection of events fired by the parent game object.
|
||||
*
|
||||
* For example to tell when a Sprite has been added to a new group:
|
||||
*
|
||||
* ```sprite.events.onAddedToGroup.add(yourFunction, this);```
|
||||
*
|
||||
* Where `yourFunction` is the function you want called when this event occurs.
|
||||
*
|
||||
* Note that the Input related events only exist if the Sprite has had `inputEnabled` set to `true`.
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Sprite} sprite - A reference to Description.
|
||||
*/
|
||||
Phaser.Events = function (sprite) {
|
||||
|
||||
this.parent = sprite;
|
||||
|
||||
this.onAddedToGroup = new Phaser.Signal();
|
||||
this.onRemovedFromGroup = new Phaser.Signal();
|
||||
this.onKilled = new Phaser.Signal();
|
||||
this.onRevived = new Phaser.Signal();
|
||||
this.onOutOfBounds = new Phaser.Signal();
|
||||
|
||||
this.onInputOver = null;
|
||||
this.onInputOut = null;
|
||||
this.onInputDown = null;
|
||||
this.onInputUp = null;
|
||||
this.onDragStart = null;
|
||||
this.onDragStop = null;
|
||||
|
||||
this.onAnimationStart = null;
|
||||
this.onAnimationComplete = null;
|
||||
this.onAnimationLoop = null;
|
||||
|
||||
this.onBeginContact = null;
|
||||
this.onEndContact = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Events.prototype = {
|
||||
|
||||
destroy: function () {
|
||||
|
||||
this.parent = null;
|
||||
this.onAddedToGroup.dispose();
|
||||
this.onRemovedFromGroup.dispose();
|
||||
this.onKilled.dispose();
|
||||
this.onRevived.dispose();
|
||||
this.onOutOfBounds.dispose();
|
||||
|
||||
if (this.onInputOver)
|
||||
{
|
||||
this.onInputOver.dispose();
|
||||
this.onInputOut.dispose();
|
||||
this.onInputDown.dispose();
|
||||
this.onInputUp.dispose();
|
||||
this.onDragStart.dispose();
|
||||
this.onDragStop.dispose();
|
||||
}
|
||||
|
||||
if (this.onAnimationStart)
|
||||
{
|
||||
this.onAnimationStart.dispose();
|
||||
this.onAnimationComplete.dispose();
|
||||
this.onAnimationLoop.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Events.prototype.constructor = Phaser.Events;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,652 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: core/Filter.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: core/Filter.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a base Filter template to use for any Phaser filter development.
|
||||
*
|
||||
* @class Phaser.Filter
|
||||
* @classdesc Phaser - Filter
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {Object} uniforms - Uniform mappings object
|
||||
* @param {Array} fragmentSrc - The fragment shader code.
|
||||
*/
|
||||
Phaser.Filter = function (game, uniforms, fragmentSrc) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {number} type - The const type of this object, either Phaser.WEBGL_FILTER or Phaser.CANVAS_FILTER.
|
||||
* @default
|
||||
*/
|
||||
this.type = Phaser.WEBGL_FILTER;
|
||||
|
||||
/**
|
||||
* An array of passes - some filters contain a few steps this array simply stores the steps in a linear fashion.
|
||||
* For example the blur filter has two passes blurX and blurY.
|
||||
* @property {array} passes - An array of filter objects.
|
||||
* @private
|
||||
*/
|
||||
this.passes = [this];
|
||||
|
||||
/**
|
||||
* @property {boolean} dirty - Internal PIXI var.
|
||||
* @default
|
||||
*/
|
||||
this.dirty = true;
|
||||
|
||||
/**
|
||||
* @property {number} padding - Internal PIXI var.
|
||||
* @default
|
||||
*/
|
||||
this.padding = 0;
|
||||
|
||||
/**
|
||||
* @property {object} uniforms - Default uniform mappings.
|
||||
*/
|
||||
this.uniforms = {
|
||||
|
||||
time: { type: '1f', value: 0 },
|
||||
resolution: { type: '2f', value: { x: 256, y: 256 }},
|
||||
mouse: { type: '2f', value: { x: 0.0, y: 0.0 }}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @property {array} fragmentSrc - The fragment shader code.
|
||||
*/
|
||||
this.fragmentSrc = fragmentSrc || [];
|
||||
|
||||
};
|
||||
|
||||
Phaser.Filter.prototype = {
|
||||
|
||||
/**
|
||||
* Should be over-ridden.
|
||||
* @method Phaser.Filter#init
|
||||
*/
|
||||
init: function () {
|
||||
// This should be over-ridden. Will receive a variable number of arguments.
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the resolution uniforms on the filter.
|
||||
* @method Phaser.Filter#setResolution
|
||||
* @param {number} width - The width of the display.
|
||||
* @param {number} height - The height of the display.
|
||||
*/
|
||||
setResolution: function (width, height) {
|
||||
|
||||
this.uniforms.resolution.value.x = width;
|
||||
this.uniforms.resolution.value.y = height;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the filter.
|
||||
* @method Phaser.Filter#update
|
||||
* @param {Phaser.Pointer} [pointer] - A Pointer object to use for the filter. The coordinates are mapped to the mouse uniform.
|
||||
*/
|
||||
update: function (pointer) {
|
||||
|
||||
if (typeof pointer !== 'undefined')
|
||||
{
|
||||
if (pointer.x > 0)
|
||||
{
|
||||
this.uniforms.mouse.x = pointer.x.toFixed(2);
|
||||
}
|
||||
|
||||
if (pointer.y > 0)
|
||||
{
|
||||
this.uniforms.mouse.y = pointer.y.toFixed(2);
|
||||
}
|
||||
}
|
||||
|
||||
this.uniforms.time.value = this.game.time.totalElapsedSeconds();
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear down this Filter and null out references
|
||||
* @method Phaser.Filter#destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Filter.prototype.constructor = Phaser.Filter;
|
||||
|
||||
/**
|
||||
* @name Phaser.Filter#width
|
||||
* @property {number} width - The width (resolution uniform)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Filter.prototype, 'width', {
|
||||
|
||||
get: function() {
|
||||
return this.uniforms.resolution.value.x;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.resolution.value.x = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Filter#height
|
||||
* @property {number} height - The height (resolution uniform)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Filter.prototype, 'height', {
|
||||
|
||||
get: function() {
|
||||
return this.uniforms.resolution.value.y;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.resolution.value.y = value;
|
||||
}
|
||||
|
||||
});
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,655 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: animation/Frame.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: animation/Frame.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Frame is a single frame of an animation and is part of a FrameData collection.
|
||||
*
|
||||
* @class Phaser.Frame
|
||||
* @constructor
|
||||
* @param {number} index - The index of this Frame within the FrameData set it is being added to.
|
||||
* @param {number} x - X position of the frame within the texture image.
|
||||
* @param {number} y - Y position of the frame within the texture image.
|
||||
* @param {number} width - Width of the frame within the texture image.
|
||||
* @param {number} height - Height of the frame within the texture image.
|
||||
* @param {string} name - The name of the frame. In Texture Atlas data this is usually set to the filename.
|
||||
* @param {string} uuid - Internal UUID key.
|
||||
*/
|
||||
Phaser.Frame = function (index, x, y, width, height, name, uuid) {
|
||||
|
||||
/**
|
||||
* @property {number} index - The index of this Frame within the FrameData set it is being added to.
|
||||
*/
|
||||
this.index = index;
|
||||
|
||||
/**
|
||||
* @property {number} x - X position within the image to cut from.
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* @property {number} y - Y position within the image to cut from.
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* @property {number} width - Width of the frame.
|
||||
*/
|
||||
this.width = width;
|
||||
|
||||
/**
|
||||
* @property {number} height - Height of the frame.
|
||||
*/
|
||||
this.height = height;
|
||||
|
||||
/**
|
||||
* @property {string} name - Useful for Texture Atlas files (is set to the filename value).
|
||||
*/
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* @property {string} uuid - A link to the PIXI.TextureCache entry.
|
||||
*/
|
||||
this.uuid = uuid;
|
||||
|
||||
/**
|
||||
* @property {number} centerX - Center X position within the image to cut from.
|
||||
*/
|
||||
this.centerX = Math.floor(width / 2);
|
||||
|
||||
/**
|
||||
* @property {number} centerY - Center Y position within the image to cut from.
|
||||
*/
|
||||
this.centerY = Math.floor(height / 2);
|
||||
|
||||
/**
|
||||
* @property {number} distance - The distance from the top left to the bottom-right of this Frame.
|
||||
*/
|
||||
this.distance = Phaser.Math.distance(0, 0, width, height);
|
||||
|
||||
/**
|
||||
* @property {boolean} rotated - Rotated? (not yet implemented)
|
||||
* @default
|
||||
*/
|
||||
this.rotated = false;
|
||||
|
||||
/**
|
||||
* @property {string} rotationDirection - Either 'cw' or 'ccw', rotation is always 90 degrees.
|
||||
* @default 'cw'
|
||||
*/
|
||||
this.rotationDirection = 'cw';
|
||||
|
||||
/**
|
||||
* @property {boolean} trimmed - Was it trimmed when packed?
|
||||
* @default
|
||||
*/
|
||||
this.trimmed = false;
|
||||
|
||||
/**
|
||||
* @property {number} sourceSizeW - Width of the original sprite.
|
||||
*/
|
||||
this.sourceSizeW = width;
|
||||
|
||||
/**
|
||||
* @property {number} sourceSizeH - Height of the original sprite.
|
||||
*/
|
||||
this.sourceSizeH = height;
|
||||
|
||||
/**
|
||||
* @property {number} spriteSourceSizeX - X position of the trimmed sprite inside original sprite.
|
||||
* @default
|
||||
*/
|
||||
this.spriteSourceSizeX = 0;
|
||||
|
||||
/**
|
||||
* @property {number} spriteSourceSizeY - Y position of the trimmed sprite inside original sprite.
|
||||
* @default
|
||||
*/
|
||||
this.spriteSourceSizeY = 0;
|
||||
|
||||
/**
|
||||
* @property {number} spriteSourceSizeW - Width of the trimmed sprite.
|
||||
* @default
|
||||
*/
|
||||
this.spriteSourceSizeW = 0;
|
||||
|
||||
/**
|
||||
* @property {number} spriteSourceSizeH - Height of the trimmed sprite.
|
||||
* @default
|
||||
*/
|
||||
this.spriteSourceSizeH = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Frame.prototype = {
|
||||
|
||||
/**
|
||||
* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
|
||||
*
|
||||
* @method Phaser.Frame#setTrim
|
||||
* @param {boolean} trimmed - If this frame was trimmed or not.
|
||||
* @param {number} actualWidth - The width of the frame before being trimmed.
|
||||
* @param {number} actualHeight - The height of the frame before being trimmed.
|
||||
* @param {number} destX - The destination X position of the trimmed frame for display.
|
||||
* @param {number} destY - The destination Y position of the trimmed frame for display.
|
||||
* @param {number} destWidth - The destination width of the trimmed frame for display.
|
||||
* @param {number} destHeight - The destination height of the trimmed frame for display.
|
||||
*/
|
||||
setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
|
||||
|
||||
this.trimmed = trimmed;
|
||||
|
||||
if (trimmed)
|
||||
{
|
||||
this.width = actualWidth;
|
||||
this.height = actualHeight;
|
||||
this.sourceSizeW = actualWidth;
|
||||
this.sourceSizeH = actualHeight;
|
||||
this.centerX = Math.floor(actualWidth / 2);
|
||||
this.centerY = Math.floor(actualHeight / 2);
|
||||
this.spriteSourceSizeX = destX;
|
||||
this.spriteSourceSizeY = destY;
|
||||
this.spriteSourceSizeW = destWidth;
|
||||
this.spriteSourceSizeH = destHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Frame.prototype.constructor = Phaser.Frame;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,732 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: animation/FrameData.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: animation/FrameData.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser.
|
||||
*
|
||||
* @class Phaser.FrameData
|
||||
* @constructor
|
||||
*/
|
||||
Phaser.FrameData = function () {
|
||||
|
||||
/**
|
||||
* @property {Array} _frames - Local array of frames.
|
||||
* @private
|
||||
*/
|
||||
this._frames = [];
|
||||
|
||||
|
||||
/**
|
||||
* @property {Array} _frameNames - Local array of frame names for name to index conversions.
|
||||
* @private
|
||||
*/
|
||||
this._frameNames = [];
|
||||
|
||||
};
|
||||
|
||||
Phaser.FrameData.prototype = {
|
||||
|
||||
/**
|
||||
* Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly.
|
||||
*
|
||||
* @method Phaser.FrameData#addFrame
|
||||
* @param {Phaser.Frame} frame - The frame to add to this FrameData set.
|
||||
* @return {Phaser.Frame} The frame that was just added.
|
||||
*/
|
||||
addFrame: function (frame) {
|
||||
|
||||
frame.index = this._frames.length;
|
||||
|
||||
this._frames.push(frame);
|
||||
|
||||
if (frame.name !== '')
|
||||
{
|
||||
this._frameNames[frame.name] = frame.index;
|
||||
}
|
||||
|
||||
return frame;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a Frame by its numerical index.
|
||||
*
|
||||
* @method Phaser.FrameData#getFrame
|
||||
* @param {number} index - The index of the frame you want to get.
|
||||
* @return {Phaser.Frame} The frame, if found.
|
||||
*/
|
||||
getFrame: function (index) {
|
||||
|
||||
if (this._frames.length > index)
|
||||
{
|
||||
return this._frames[index];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a Frame by its frame name.
|
||||
*
|
||||
* @method Phaser.FrameData#getFrameByName
|
||||
* @param {string} name - The name of the frame you want to get.
|
||||
* @return {Phaser.Frame} The frame, if found.
|
||||
*/
|
||||
getFrameByName: function (name) {
|
||||
|
||||
if (typeof this._frameNames[name] === 'number')
|
||||
{
|
||||
return this._frames[this._frameNames[name]];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if there is a Frame with the given name.
|
||||
*
|
||||
* @method Phaser.FrameData#checkFrameName
|
||||
* @param {string} name - The name of the frame you want to check.
|
||||
* @return {boolean} True if the frame is found, otherwise false.
|
||||
*/
|
||||
checkFrameName: function (name) {
|
||||
|
||||
if (this._frameNames[name] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a range of frames based on the given start and end frame indexes and returns them in an Array.
|
||||
*
|
||||
* @method Phaser.FrameData#getFrameRange
|
||||
* @param {number} start - The starting frame index.
|
||||
* @param {number} end - The ending frame index.
|
||||
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
|
||||
* @return {Array} An array of Frames between the start and end index values, or an empty array if none were found.
|
||||
*/
|
||||
getFrameRange: function (start, end, output) {
|
||||
|
||||
if (typeof output === "undefined") { output = []; }
|
||||
|
||||
for (var i = start; i <= end; i++)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all of the Frames in this FrameData set where the frame index is found in the input array.
|
||||
* The frames are returned in the output array, or if none is provided in a new Array object.
|
||||
*
|
||||
* @method Phaser.FrameData#getFrames
|
||||
* @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
|
||||
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
|
||||
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
|
||||
* @return {Array} An array of all Frames in this FrameData set matching the given names or IDs.
|
||||
*/
|
||||
getFrames: function (frames, useNumericIndex, output) {
|
||||
|
||||
if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
|
||||
if (typeof output === "undefined") { output = []; }
|
||||
|
||||
if (typeof frames === "undefined" || frames.length === 0)
|
||||
{
|
||||
// No input array, so we loop through all frames
|
||||
for (var i = 0; i < this._frames.length; i++)
|
||||
{
|
||||
// We only need the indexes
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input array given, loop through that instead
|
||||
for (var i = 0, len = frames.length; i < len; i++)
|
||||
{
|
||||
// Does the input array contain names or indexes?
|
||||
if (useNumericIndex)
|
||||
{
|
||||
// The actual frame
|
||||
output.push(this.getFrame(frames[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
// The actual frame
|
||||
output.push(this.getFrameByName(frames[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all of the Frame indexes in this FrameData set.
|
||||
* The frames indexes are returned in the output array, or if none is provided in a new Array object.
|
||||
*
|
||||
* @method Phaser.FrameData#getFrameIndexes
|
||||
* @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
|
||||
* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
|
||||
* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
|
||||
* @return {Array} An array of all Frame indexes matching the given names or IDs.
|
||||
*/
|
||||
getFrameIndexes: function (frames, useNumericIndex, output) {
|
||||
|
||||
if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
|
||||
if (typeof output === "undefined") { output = []; }
|
||||
|
||||
if (typeof frames === "undefined" || frames.length === 0)
|
||||
{
|
||||
// No frames array, so we loop through all frames
|
||||
for (var i = 0, len = this._frames.length; i < len; i++)
|
||||
{
|
||||
output.push(this._frames[i].index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input array given, loop through that instead
|
||||
for (var i = 0, len = frames.length; i < len; i++)
|
||||
{
|
||||
// Does the frames array contain names or indexes?
|
||||
if (useNumericIndex)
|
||||
{
|
||||
output.push(frames[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.getFrameByName(frames[i]))
|
||||
{
|
||||
output.push(this.getFrameByName(frames[i]).index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.FrameData.prototype.constructor = Phaser.FrameData;
|
||||
|
||||
/**
|
||||
* @name Phaser.FrameData#total
|
||||
* @property {number} total - The total number of frames in this FrameData set.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.FrameData.prototype, "total", {
|
||||
|
||||
get: function () {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
||||
});
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,816 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: gameobjects/GameObjectFactory.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: gameobjects/GameObjectFactory.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Game Object Factory is a quick way to create all of the different sorts of core objects that Phaser uses.
|
||||
*
|
||||
* @class Phaser.GameObjectFactory
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.GameObjectFactory = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.World} world - A reference to the game world.
|
||||
*/
|
||||
this.world = this.game.world;
|
||||
|
||||
};
|
||||
|
||||
Phaser.GameObjectFactory.prototype = {
|
||||
|
||||
/**
|
||||
* Adds an existing object to the game world.
|
||||
* @method Phaser.GameObjectFactory#existing
|
||||
* @param {*} object - An instance of Phaser.Sprite, Phaser.Button or any other display object..
|
||||
* @return {*} The child that was added to the Group.
|
||||
*/
|
||||
existing: function (object) {
|
||||
|
||||
return this.world.add(object);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a new Sprite with specific position and sprite sheet key.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#sprite
|
||||
* @param {number} x - X position of the new sprite.
|
||||
* @param {number} y - Y position of the new sprite.
|
||||
* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
|
||||
* @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
* @returns {Phaser.Sprite} the newly created sprite object.
|
||||
*/
|
||||
sprite: function (x, y, key, frame, group) {
|
||||
|
||||
if (typeof group === 'undefined') { group = this.world; }
|
||||
|
||||
return group.create(x, y, key, frame);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* DEPRECATED - will be removed in Phaser 1.2
|
||||
* Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#child
|
||||
* @param {Phaser.Group} group - The Group to add this child to.
|
||||
* @param {number} x - X position of the new sprite.
|
||||
* @param {number} y - Y position of the new sprite.
|
||||
* @param {string|RenderTexture} [key] - The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture.
|
||||
* @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
|
||||
* @returns {Phaser.Sprite} the newly created sprite object.
|
||||
*/
|
||||
child: function (group, x, y, key, frame) {
|
||||
|
||||
return group.create(x, y, key, frame);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#tween
|
||||
* @param {object} obj - Object the tween will be run on.
|
||||
* @return {Phaser.Tween} Description.
|
||||
*/
|
||||
tween: function (obj) {
|
||||
|
||||
return this.game.tweens.create(obj);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#group
|
||||
* @param {any} parent - The parent Group or DisplayObjectContainer that will hold this group, if any.
|
||||
* @param {string} [name='group'] - A name for this Group. Not used internally but useful for debugging.
|
||||
* @return {Phaser.Group} The newly created group.
|
||||
*/
|
||||
group: function (parent, name) {
|
||||
|
||||
return new Phaser.Group(this.game, parent, name);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Sound object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#audio
|
||||
* @param {string} key - The Game.cache key of the sound that this object will use.
|
||||
* @param {number} [volume=1] - The volume at which the sound will be played.
|
||||
* @param {boolean} [loop=false] - Whether or not the sound will loop.
|
||||
* @param {boolean} [connect=true] - Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio.
|
||||
* @return {Phaser.Sound} The newly created text object.
|
||||
*/
|
||||
audio: function (key, volume, loop, connect) {
|
||||
|
||||
return this.game.sound.add(key, volume, loop, connect);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Sound object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#sound
|
||||
* @param {string} key - The Game.cache key of the sound that this object will use.
|
||||
* @param {number} [volume=1] - The volume at which the sound will be played.
|
||||
* @param {boolean} [loop=false] - Whether or not the sound will loop.
|
||||
* @param {boolean} [connect=true] - Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio.
|
||||
* @return {Phaser.Sound} The newly created text object.
|
||||
*/
|
||||
sound: function (key, volume, loop, connect) {
|
||||
|
||||
return this.game.sound.add(key, volume, loop, connect);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new TileSprite object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#tileSprite
|
||||
* @param {number} x - X position of the new tileSprite.
|
||||
* @param {number} y - Y position of the new tileSprite.
|
||||
* @param {number} width - the width of the tilesprite.
|
||||
* @param {number} height - the height of the tilesprite.
|
||||
* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
* @return {Phaser.TileSprite} The newly created tileSprite object.
|
||||
*/
|
||||
tileSprite: function (x, y, width, height, key, group) {
|
||||
|
||||
if (typeof group === 'undefined') { group = this.world; }
|
||||
|
||||
return group.add(new Phaser.TileSprite(this.game, x, y, width, height, key));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Text object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#text
|
||||
* @param {number} x - X position of the new text object.
|
||||
* @param {number} y - Y position of the new text object.
|
||||
* @param {string} text - The actual text that will be written.
|
||||
* @param {object} style - The style object containing style attributes like font, font size , etc.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
* @return {Phaser.Text} The newly created text object.
|
||||
*/
|
||||
text: function (x, y, text, style, group) {
|
||||
|
||||
if (typeof group === 'undefined') { group = this.world; }
|
||||
|
||||
return group.add(new Phaser.Text(this.game, x, y, text, style));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Button object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#button
|
||||
* @param {number} [x] X position of the new button object.
|
||||
* @param {number} [y] Y position of the new button object.
|
||||
* @param {string} [key] The image key as defined in the Game.Cache to use as the texture for this button.
|
||||
* @param {function} [callback] The function to call when this button is pressed
|
||||
* @param {object} [callbackContext] The context in which the callback will be called (usually 'this')
|
||||
* @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {string|number} [upFrame] This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
* @return {Phaser.Button} The newly created button object.
|
||||
*/
|
||||
button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group) {
|
||||
|
||||
if (typeof group === 'undefined') { group = this.world; }
|
||||
|
||||
return group.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Graphics object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#graphics
|
||||
* @param {number} x - X position of the new graphics object.
|
||||
* @param {number} y - Y position of the new graphics object.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
* @return {Phaser.Graphics} The newly created graphics object.
|
||||
*/
|
||||
graphics: function (x, y, group) {
|
||||
|
||||
if (typeof group === 'undefined') { group = this.world; }
|
||||
|
||||
return group.add(new Phaser.Graphics(this.game, x, y));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#emitter
|
||||
* @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from.
|
||||
* @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from.
|
||||
* @param {number} [maxParticles=50] - The total number of particles in this emitter.
|
||||
* @return {Phaser.Emitter} The newly created emitter object.
|
||||
*/
|
||||
emitter: function (x, y, maxParticles) {
|
||||
|
||||
return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* * Create a new BitmapText object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#bitmapText
|
||||
* @param {number} x - X position of the new bitmapText object.
|
||||
* @param {number} y - Y position of the new bitmapText object.
|
||||
* @param {string} text - The actual text that will be written.
|
||||
* @param {object} style - The style object containing style attributes like font, font size , etc.
|
||||
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
|
||||
* @return {Phaser.BitmapText} The newly created bitmapText object.
|
||||
*/
|
||||
bitmapText: function (x, y, text, style, group) {
|
||||
|
||||
if (typeof group === 'undefined') { group = this.world; }
|
||||
|
||||
return this.world.add(new Phaser.BitmapText(this.game, x, y, text, style));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new Tilemap object.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#tilemap
|
||||
* @param {string} key - Asset key for the JSON or CSV map data in the cache.
|
||||
* @param {object|string} tilesets - An object mapping Cache.tileset keys with the tileset names in the JSON file. If a string is provided that will be used.
|
||||
* @return {Phaser.Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
tilemap: function (key, tilesets) {
|
||||
|
||||
return new Phaser.Tilemap(this.game, key, tilesets);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A dynamic initially blank canvas to which images can be drawn.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#renderTexture
|
||||
* @param {string} key - Asset key for the render texture.
|
||||
* @param {number} width - the width of the render texture.
|
||||
* @param {number} height - the height of the render texture.
|
||||
* @return {Phaser.RenderTexture} The newly created renderTexture object.
|
||||
*/
|
||||
renderTexture: function (key, width, height) {
|
||||
|
||||
var texture = new Phaser.RenderTexture(this.game, key, width, height);
|
||||
|
||||
this.game.cache.addRenderTexture(key, texture);
|
||||
|
||||
return texture;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Experimental: A BitmapData object which can be manipulated and drawn to like a traditional Canvas object and used to texture Sprites.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#bitmapData
|
||||
* @param {number} [width=256] - The width of the BitmapData in pixels.
|
||||
* @param {number} [height=256] - The height of the BitmapData in pixels.
|
||||
* @return {Phaser.BitmapData} The newly created BitmapData object.
|
||||
*/
|
||||
bitmapData: function (width, height) {
|
||||
|
||||
return new Phaser.BitmapData(this.game, width, height);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A WebGL shader/filter that can be applied to Sprites.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#filter
|
||||
* @param {string} filter - The name of the filter you wish to create, for example HueRotate or SineWave.
|
||||
* @param {any} - Whatever parameters are needed to be passed to the filter init function.
|
||||
* @return {Phaser.Filter} The newly created Phaser.Filter object.
|
||||
*/
|
||||
filter: function (filter) {
|
||||
|
||||
var args = Array.prototype.splice.call(arguments, 1);
|
||||
|
||||
var filter = new Phaser.Filter[filter](this.game);
|
||||
|
||||
filter.init.apply(filter, args);
|
||||
|
||||
return filter;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.GameObjectFactory.prototype.constructor = Phaser.GameObjectFactory;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,668 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: input/GamepadButton.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: input/GamepadButton.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author @karlmacklin <tacklemcclean@gmail.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Phaser.GamepadButton
|
||||
* @classdesc If you need more fine-grained control over the handling of specific buttons you can create and use Phaser.GamepadButton objects.
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {number} buttoncode - The button code this GamepadButton is responsible for.
|
||||
*/
|
||||
Phaser.GamepadButton = function (game, buttoncode) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} isDown - The "down" state of the button.
|
||||
* @default
|
||||
*/
|
||||
this.isDown = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} isUp - The "up" state of the button.
|
||||
* @default
|
||||
*/
|
||||
this.isUp = false;
|
||||
|
||||
/**
|
||||
* @property {number} timeDown - The timestamp when the button was last pressed down.
|
||||
* @default
|
||||
*/
|
||||
this.timeDown = 0;
|
||||
|
||||
/**
|
||||
* If the button is down this value holds the duration of that button press and is constantly updated.
|
||||
* If the button is up it holds the duration of the previous down session.
|
||||
* @property {number} duration - The number of milliseconds this button has been held down for.
|
||||
* @default
|
||||
*/
|
||||
this.duration = 0;
|
||||
|
||||
/**
|
||||
* @property {number} timeUp - The timestamp when the button was last released.
|
||||
* @default
|
||||
*/
|
||||
this.timeUp = 0;
|
||||
|
||||
/**
|
||||
* @property {number} repeats - If a button is held down this holds down the number of times the button has 'repeated'.
|
||||
* @default
|
||||
*/
|
||||
this.repeats = 0;
|
||||
|
||||
/**
|
||||
* @property {number} value - Button value. Mainly useful for checking analog buttons (like shoulder triggers)
|
||||
* @default
|
||||
*/
|
||||
this.value = 0;
|
||||
|
||||
/**
|
||||
* @property {number} buttonCode - The buttoncode of this button.
|
||||
*/
|
||||
this.buttonCode = buttoncode;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onDown - This Signal is dispatched every time this GamepadButton is pressed down. It is only dispatched once (until the button is released again).
|
||||
*/
|
||||
this.onDown = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onUp - This Signal is dispatched every time this GamepadButton is pressed down. It is only dispatched once (until the button is released again).
|
||||
*/
|
||||
this.onUp = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onFloat - This Signal is dispatched every time this GamepadButton changes floating value (between (but not exactly) 0 and 1)
|
||||
*/
|
||||
this.onFloat = new Phaser.Signal();
|
||||
|
||||
};
|
||||
|
||||
Phaser.GamepadButton.prototype = {
|
||||
|
||||
/**
|
||||
* Called automatically by Phaser.SinglePad.
|
||||
* @method Phaser.GamepadButton#processButtonDown
|
||||
* @param {Object} value - Button value
|
||||
* @protected
|
||||
*/
|
||||
processButtonDown: function (value) {
|
||||
|
||||
if (this.isDown)
|
||||
{
|
||||
this.duration = this.game.time.now - this.timeDown;
|
||||
this.repeats++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isDown = true;
|
||||
this.isUp = false;
|
||||
this.timeDown = this.game.time.now;
|
||||
this.duration = 0;
|
||||
this.repeats = 0;
|
||||
this.value = value;
|
||||
|
||||
this.onDown.dispatch(this, value);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Called automatically by Phaser.SinglePad.
|
||||
* @method Phaser.GamepadButton#processButtonUp
|
||||
* @param {Object} value - Button value
|
||||
* @protected
|
||||
*/
|
||||
processButtonUp: function (value) {
|
||||
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = this.game.time.now;
|
||||
this.value = value;
|
||||
|
||||
this.onUp.dispatch(this, value);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Called automatically by Phaser.Gamepad.
|
||||
* @method Phaser.GamepadButton#processButtonFloat
|
||||
* @param {Object} value - Button value
|
||||
* @protected
|
||||
*/
|
||||
processButtonFloat: function (value) {
|
||||
|
||||
this.value = value;
|
||||
this.onFloat.dispatch(this, value);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the "just pressed" state of this button. Just pressed is considered true if the button was pressed down within the duration given (default 250ms).
|
||||
* @method Phaser.GamepadButton#justPressed
|
||||
* @param {number} [duration=250] - The duration below which the button is considered as being just pressed.
|
||||
* @return {boolean} True if the button is just pressed otherwise false.
|
||||
*/
|
||||
justPressed: function (duration) {
|
||||
|
||||
if (typeof duration === "undefined") { duration = 250; }
|
||||
|
||||
return (this.isDown && this.duration < duration);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the "just released" state of this button. Just released is considered as being true if the button was released within the duration given (default 250ms).
|
||||
* @method Phaser.GamepadButton#justPressed
|
||||
* @param {number} [duration=250] - The duration below which the button is considered as being just released.
|
||||
* @return {boolean} True if the button is just pressed otherwise false.
|
||||
*/
|
||||
justReleased: function (duration) {
|
||||
|
||||
if (typeof duration === "undefined") { duration = 250; }
|
||||
|
||||
return (this.isDown === false && (this.game.time.now - this.timeUp < duration));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.GamepadButton.prototype.constructor = Phaser.GamepadButton;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,597 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: gameobjects/Graphics.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: gameobjects/Graphics.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new `Graphics` object.
|
||||
*
|
||||
* @class Phaser.Graphics
|
||||
* @constructor
|
||||
*
|
||||
* @param {Phaser.Game} game Current game instance.
|
||||
* @param {number} x - X position of the new graphics object.
|
||||
* @param {number} y - Y position of the new graphics object.
|
||||
*/
|
||||
Phaser.Graphics = function (game, x, y) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
PIXI.Graphics.call(this);
|
||||
|
||||
/**
|
||||
* @property {number} type - The Phaser Object Type.
|
||||
*/
|
||||
this.type = Phaser.GRAPHICS;
|
||||
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype);
|
||||
Phaser.Graphics.prototype.constructor = Phaser.Graphics;
|
||||
|
||||
/**
|
||||
* Destroy this Graphics instance.
|
||||
*
|
||||
* @method Phaser.Graphics.prototype.destroy
|
||||
*/
|
||||
Phaser.Graphics.prototype.destroy = function() {
|
||||
|
||||
this.clear();
|
||||
|
||||
if (this.group)
|
||||
{
|
||||
this.group.remove(this);
|
||||
}
|
||||
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled
|
||||
*/
|
||||
Phaser.Graphics.prototype.drawPolygon = function (poly) {
|
||||
|
||||
this.moveTo(poly.points[0].x, poly.points[0].y);
|
||||
|
||||
for (var i = 1; i < poly.points.length; i += 1)
|
||||
{
|
||||
this.lineTo(poly.points[i].x, poly.points[i].y);
|
||||
}
|
||||
|
||||
this.lineTo(poly.points[0].x, poly.points[0].y);
|
||||
|
||||
}
|
||||
|
||||
Object.defineProperty(Phaser.Graphics.prototype, 'angle', {
|
||||
|
||||
get: function() {
|
||||
return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Graphics.prototype, 'x', {
|
||||
|
||||
get: function() {
|
||||
return this.position.x;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.x = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Graphics.prototype, 'y', {
|
||||
|
||||
get: function() {
|
||||
return this.position.y;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.y = value;
|
||||
}
|
||||
|
||||
});
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,540 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: IntroDocs.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#hex2rgb">hex2rgb</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#HEXtoRGB">HEXtoRGB</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#x">x</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#y">y</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: IntroDocs.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @overview
|
||||
*
|
||||
* 
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v1.1.4 - Released February 5th 2014.
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
* A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and
|
||||
* constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm).
|
||||
*
|
||||
* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com/ @Doormat23.
|
||||
*
|
||||
* View the [Official Website](http://phaser.io)<br />
|
||||
* Follow on [Twitter](https://twitter.com/photonstorm)<br />
|
||||
* Join the [Forum](http://www.html5gamedevs.com/forum/14-phaser/)<br />
|
||||
* Try out 210+ [Phaser Examples](http://examples.phaser.io)<br />
|
||||
* Read the [documentation online](http://docs.phaser.io)
|
||||
*
|
||||
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from which both Phaser
|
||||
* and my love of game development originate.
|
||||
*
|
||||
* "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
|
||||
*/
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Wed Feb 05 2014 06:18:03 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,666 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: input/Key.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: input/Key.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Phaser.Key
|
||||
* @classdesc If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects.
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - Current game instance.
|
||||
* @param {number} keycode - The key code this Key is responsible for.
|
||||
*/
|
||||
Phaser.Key = function (game, keycode) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} isDown - The "down" state of the key.
|
||||
* @default
|
||||
*/
|
||||
this.isDown = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} isUp - The "up" state of the key.
|
||||
* @default
|
||||
*/
|
||||
this.isUp = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key.
|
||||
* @default
|
||||
*/
|
||||
this.altKey = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key.
|
||||
* @default
|
||||
*/
|
||||
this.ctrlKey = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key.
|
||||
* @default
|
||||
*/
|
||||
this.shiftKey = false;
|
||||
|
||||
/**
|
||||
* @property {number} timeDown - The timestamp when the key was last pressed down.
|
||||
* @default
|
||||
*/
|
||||
this.timeDown = 0;
|
||||
|
||||
/**
|
||||
* If the key is down this value holds the duration of that key press and is constantly updated.
|
||||
* If the key is up it holds the duration of the previous down session.
|
||||
* @property {number} duration - The number of milliseconds this key has been held down for.
|
||||
* @default
|
||||
*/
|
||||
this.duration = 0;
|
||||
|
||||
/**
|
||||
* @property {number} timeUp - The timestamp when the key was last released.
|
||||
* @default
|
||||
*/
|
||||
this.timeUp = 0;
|
||||
|
||||
/**
|
||||
* @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'.
|
||||
* @default
|
||||
*/
|
||||
this.repeats = 0;
|
||||
|
||||
/**
|
||||
* @property {number} keyCode - The keycode of this key.
|
||||
*/
|
||||
this.keyCode = keycode;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).
|
||||
*/
|
||||
this.onDown = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).
|
||||
*/
|
||||
this.onUp = new Phaser.Signal();
|
||||
|
||||
};
|
||||
|
||||
Phaser.Key.prototype = {
|
||||
|
||||
/**
|
||||
* Called automatically by Phaser.Keyboard.
|
||||
* @method Phaser.Key#processKeyDown
|
||||
* @param {KeyboardEvent} event.
|
||||
* @protected
|
||||
*/
|
||||
processKeyDown: function (event) {
|
||||
|
||||
this.altKey = event.altKey;
|
||||
this.ctrlKey = event.ctrlKey;
|
||||
this.shiftKey = event.shiftKey;
|
||||
|
||||
if (this.isDown)
|
||||
{
|
||||
// Key was already held down, this must be a repeat rate based event
|
||||
this.duration = event.timeStamp - this.timeDown;
|
||||
this.repeats++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isDown = true;
|
||||
this.isUp = false;
|
||||
this.timeDown = event.timeStamp;
|
||||
this.duration = 0;
|
||||
this.repeats = 0;
|
||||
|
||||
this.onDown.dispatch(this);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Called automatically by Phaser.Keyboard.
|
||||
* @method Phaser.Key#processKeyUp
|
||||
* @param {KeyboardEvent} event.
|
||||
* @protected
|
||||
*/
|
||||
processKeyUp: function (event) {
|
||||
|
||||
this.isDown = false;
|
||||
this.isUp = true;
|
||||
this.timeUp = event.timeStamp;
|
||||
|
||||
this.onUp.dispatch(this);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)
|
||||
* @method Phaser.Key#justPressed
|
||||
* @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
|
||||
* @return {boolean} True if the key is just pressed otherwise false.
|
||||
*/
|
||||
justPressed: function (duration) {
|
||||
|
||||
if (typeof duration === "undefined") { duration = 250; }
|
||||
|
||||
return (this.isDown && this.duration < duration);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)
|
||||
* @method Phaser.Key#justReleased
|
||||
* @param {number} [duration=250] - The duration below which the key is considered as being just released.
|
||||
* @return {boolean} True if the key is just released otherwise false.
|
||||
*/
|
||||
justReleased: function (duration) {
|
||||
|
||||
if (typeof duration === "undefined") { duration = 250; }
|
||||
|
||||
return (this.isDown === false && (this.game.time.now - this.timeUp < duration));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Key.prototype.constructor = Phaser.Key;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,990 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: input/Keyboard.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: input/Keyboard.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Keyboard class handles looking after keyboard input for your game. It will recognise and respond to key presses and dispatch the required events.
|
||||
*
|
||||
* @class Phaser.Keyboard
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.Keyboard = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {object} _keys - The object the key values are stored in.
|
||||
* @private
|
||||
*/
|
||||
this._keys = {};
|
||||
|
||||
/**
|
||||
* @property {object} _hotkeys - The object the hot keys are stored in.
|
||||
* @private
|
||||
*/
|
||||
this._hotkeys = {};
|
||||
|
||||
/**
|
||||
* @property {object} _capture - The object the key capture values are stored in.
|
||||
* @private
|
||||
*/
|
||||
this._capture = {};
|
||||
|
||||
/**
|
||||
* You can disable all Keyboard Input by setting disabled to true. While true all new input related events will be ignored.
|
||||
* @property {boolean} disabled - The disabled state of the Keyboard.
|
||||
* @default
|
||||
*/
|
||||
this.disabled = false;
|
||||
|
||||
/**
|
||||
* @property {function} _onKeyDown
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onKeyDown = null;
|
||||
|
||||
/**
|
||||
* @property {function} _onKeyUp
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onKeyUp = null;
|
||||
|
||||
/**
|
||||
* @property {Object} callbackContext - The context under which the callbacks are run.
|
||||
*/
|
||||
this.callbackContext = this;
|
||||
|
||||
/**
|
||||
* @property {function} onDownCallback - This callback is invoked every time a key is pressed down.
|
||||
*/
|
||||
this.onDownCallback = null;
|
||||
|
||||
/**
|
||||
* @property {function} onUpCallback - This callback is invoked every time a key is released.
|
||||
*/
|
||||
this.onUpCallback = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Keyboard.prototype = {
|
||||
|
||||
/**
|
||||
* Add callbacks to the Keyboard handler so that each time a key is pressed down or releases the callbacks are activated.
|
||||
* @method Phaser.Keyboard#addCallbacks
|
||||
* @param {Object} context - The context under which the callbacks are run.
|
||||
* @param {function} onDown - This callback is invoked every time a key is pressed down.
|
||||
* @param {function} [onUp=null] - This callback is invoked every time a key is released.
|
||||
*/
|
||||
addCallbacks: function (context, onDown, onUp) {
|
||||
|
||||
this.callbackContext = context;
|
||||
this.onDownCallback = onDown;
|
||||
|
||||
if (typeof onUp !== 'undefined')
|
||||
{
|
||||
this.onUpCallback = onUp;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method.
|
||||
* The Key object can then be polled, have events attached to it, etc.
|
||||
*
|
||||
* @method Phaser.Keyboard#addKey
|
||||
* @param {number} keycode - The keycode of the key, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACEBAR
|
||||
* @return {Phaser.Key} The Key object which you can store locally and reference directly.
|
||||
*/
|
||||
addKey: function (keycode) {
|
||||
|
||||
this._hotkeys[keycode] = new Phaser.Key(this.game, keycode);
|
||||
|
||||
this.addKeyCapture(keycode);
|
||||
|
||||
return this._hotkeys[keycode];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes a Key object from the Keyboard manager.
|
||||
*
|
||||
* @method Phaser.Keyboard#removeKey
|
||||
* @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACEBAR
|
||||
*/
|
||||
removeKey: function (keycode) {
|
||||
|
||||
delete (this._hotkeys[keycode]);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right.
|
||||
*
|
||||
* @method Phaser.Keyboard#createCursorKeys
|
||||
* @return {object} An object containing properties: up, down, left and right. Which can be polled like any other Phaser.Key object.
|
||||
*/
|
||||
createCursorKeys: function () {
|
||||
|
||||
return {
|
||||
up: this.addKey(Phaser.Keyboard.UP),
|
||||
down: this.addKey(Phaser.Keyboard.DOWN),
|
||||
left: this.addKey(Phaser.Keyboard.LEFT),
|
||||
right: this.addKey(Phaser.Keyboard.RIGHT)
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body.
|
||||
* This is called automatically by Phaser.Input and should not normally be invoked directly.
|
||||
*
|
||||
* @method Phaser.Keyboard#start
|
||||
*/
|
||||
start: function () {
|
||||
|
||||
var _this = this;
|
||||
|
||||
this._onKeyDown = function (event) {
|
||||
return _this.processKeyDown(event);
|
||||
};
|
||||
|
||||
this._onKeyUp = function (event) {
|
||||
return _this.processKeyUp(event);
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', this._onKeyDown, false);
|
||||
window.addEventListener('keyup', this._onKeyUp, false);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the document.body.
|
||||
*
|
||||
* @method Phaser.Keyboard#stop
|
||||
*/
|
||||
stop: function () {
|
||||
|
||||
window.removeEventListener('keydown', this._onKeyDown);
|
||||
window.removeEventListener('keyup', this._onKeyUp);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* By default when a key is pressed Phaser will not stop the event from propagating up to the browser.
|
||||
* There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll.
|
||||
* You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser.
|
||||
* Pass in either a single keycode or an array/hash of keycodes.
|
||||
* @method Phaser.Keyboard#addKeyCapture
|
||||
* @param {Any} keycode
|
||||
*/
|
||||
addKeyCapture: function (keycode) {
|
||||
|
||||
if (typeof keycode === 'object')
|
||||
{
|
||||
for (var key in keycode)
|
||||
{
|
||||
this._capture[keycode[key]] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._capture[keycode] = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes an existing key capture.
|
||||
* @method Phaser.Keyboard#removeKeyCapture
|
||||
* @param {number} keycode
|
||||
*/
|
||||
removeKeyCapture: function (keycode) {
|
||||
|
||||
delete this._capture[keycode];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear all set key captures.
|
||||
* @method Phaser.Keyboard#clearCaptures
|
||||
*/
|
||||
clearCaptures: function () {
|
||||
|
||||
this._capture = {};
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Process the keydown event.
|
||||
* @method Phaser.Keyboard#processKeyDown
|
||||
* @param {KeyboardEvent} event
|
||||
* @protected
|
||||
*/
|
||||
processKeyDown: function (event) {
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._capture[event.keyCode])
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (this.onDownCallback)
|
||||
{
|
||||
this.onDownCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._keys[event.keyCode] && this._keys[event.keyCode].isDown)
|
||||
{
|
||||
// Key already down and still down, so update
|
||||
this._keys[event.keyCode].duration = this.game.time.now - this._keys[event.keyCode].timeDown;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this._keys[event.keyCode])
|
||||
{
|
||||
// Not used this key before, so register it
|
||||
this._keys[event.keyCode] = {
|
||||
isDown: true,
|
||||
timeDown: this.game.time.now,
|
||||
timeUp: 0,
|
||||
duration: 0
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// Key used before but freshly down
|
||||
this._keys[event.keyCode].isDown = true;
|
||||
this._keys[event.keyCode].timeDown = this.game.time.now;
|
||||
this._keys[event.keyCode].duration = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._hotkeys[event.keyCode])
|
||||
{
|
||||
this._hotkeys[event.keyCode].processKeyDown(event);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Process the keyup event.
|
||||
* @method Phaser.Keyboard#processKeyUp
|
||||
* @param {KeyboardEvent} event
|
||||
* @protected
|
||||
*/
|
||||
processKeyUp: function (event) {
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._capture[event.keyCode])
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (this.onUpCallback)
|
||||
{
|
||||
this.onUpCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._hotkeys[event.keyCode])
|
||||
{
|
||||
this._hotkeys[event.keyCode].processKeyUp(event);
|
||||
}
|
||||
|
||||
if (this._keys[event.keyCode])
|
||||
{
|
||||
this._keys[event.keyCode].isDown = false;
|
||||
this._keys[event.keyCode].timeUp = this.game.time.now;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not used this key before, so register it
|
||||
this._keys[event.keyCode] = {
|
||||
isDown: false,
|
||||
timeDown: this.game.time.now,
|
||||
timeUp: this.game.time.now,
|
||||
duration: 0
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset the "isDown" state of all keys.
|
||||
* @method Phaser.Keyboard#reset
|
||||
*/
|
||||
reset: function () {
|
||||
|
||||
for (var key in this._keys)
|
||||
{
|
||||
this._keys[key].isDown = false;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the "just pressed" state of the key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)
|
||||
* @method Phaser.Keyboard#justPressed
|
||||
* @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACEBAR
|
||||
* @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
|
||||
* @return {boolean} True if the key is just pressed otherwise false.
|
||||
*/
|
||||
justPressed: function (keycode, duration) {
|
||||
|
||||
if (typeof duration === "undefined") { duration = 250; }
|
||||
|
||||
if (this._keys[keycode] && this._keys[keycode].isDown && this._keys[keycode].duration < duration)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)
|
||||
* @method Phaser.Keyboard#justReleased
|
||||
* @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACEBAR
|
||||
* @param {number} [duration=250] - The duration below which the key is considered as being just released.
|
||||
* @return {boolean} True if the key is just released otherwise false.
|
||||
*/
|
||||
justReleased: function (keycode, duration) {
|
||||
|
||||
if (typeof duration === "undefined") { duration = 250; }
|
||||
|
||||
if (this._keys[keycode] && this._keys[keycode].isDown === false && (this.game.time.now - this._keys[keycode].timeUp < duration))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser.
|
||||
* @method Phaser.Keyboard#isDown
|
||||
* @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACEBAR
|
||||
* @return {boolean} True if the key is currently down.
|
||||
*/
|
||||
isDown: function (keycode) {
|
||||
|
||||
if (this._keys[keycode])
|
||||
{
|
||||
return this._keys[keycode].isDown;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Keyboard.prototype.constructor = Phaser.Keyboard;
|
||||
|
||||
Phaser.Keyboard.A = "A".charCodeAt(0);
|
||||
Phaser.Keyboard.B = "B".charCodeAt(0);
|
||||
Phaser.Keyboard.C = "C".charCodeAt(0);
|
||||
Phaser.Keyboard.D = "D".charCodeAt(0);
|
||||
Phaser.Keyboard.E = "E".charCodeAt(0);
|
||||
Phaser.Keyboard.F = "F".charCodeAt(0);
|
||||
Phaser.Keyboard.G = "G".charCodeAt(0);
|
||||
Phaser.Keyboard.H = "H".charCodeAt(0);
|
||||
Phaser.Keyboard.I = "I".charCodeAt(0);
|
||||
Phaser.Keyboard.J = "J".charCodeAt(0);
|
||||
Phaser.Keyboard.K = "K".charCodeAt(0);
|
||||
Phaser.Keyboard.L = "L".charCodeAt(0);
|
||||
Phaser.Keyboard.M = "M".charCodeAt(0);
|
||||
Phaser.Keyboard.N = "N".charCodeAt(0);
|
||||
Phaser.Keyboard.O = "O".charCodeAt(0);
|
||||
Phaser.Keyboard.P = "P".charCodeAt(0);
|
||||
Phaser.Keyboard.Q = "Q".charCodeAt(0);
|
||||
Phaser.Keyboard.R = "R".charCodeAt(0);
|
||||
Phaser.Keyboard.S = "S".charCodeAt(0);
|
||||
Phaser.Keyboard.T = "T".charCodeAt(0);
|
||||
Phaser.Keyboard.U = "U".charCodeAt(0);
|
||||
Phaser.Keyboard.V = "V".charCodeAt(0);
|
||||
Phaser.Keyboard.W = "W".charCodeAt(0);
|
||||
Phaser.Keyboard.X = "X".charCodeAt(0);
|
||||
Phaser.Keyboard.Y = "Y".charCodeAt(0);
|
||||
Phaser.Keyboard.Z = "Z".charCodeAt(0);
|
||||
Phaser.Keyboard.ZERO = "0".charCodeAt(0);
|
||||
Phaser.Keyboard.ONE = "1".charCodeAt(0);
|
||||
Phaser.Keyboard.TWO = "2".charCodeAt(0);
|
||||
Phaser.Keyboard.THREE = "3".charCodeAt(0);
|
||||
Phaser.Keyboard.FOUR = "4".charCodeAt(0);
|
||||
Phaser.Keyboard.FIVE = "5".charCodeAt(0);
|
||||
Phaser.Keyboard.SIX = "6".charCodeAt(0);
|
||||
Phaser.Keyboard.SEVEN = "7".charCodeAt(0);
|
||||
Phaser.Keyboard.EIGHT = "8".charCodeAt(0);
|
||||
Phaser.Keyboard.NINE = "9".charCodeAt(0);
|
||||
Phaser.Keyboard.NUMPAD_0 = 96;
|
||||
Phaser.Keyboard.NUMPAD_1 = 97;
|
||||
Phaser.Keyboard.NUMPAD_2 = 98;
|
||||
Phaser.Keyboard.NUMPAD_3 = 99;
|
||||
Phaser.Keyboard.NUMPAD_4 = 100;
|
||||
Phaser.Keyboard.NUMPAD_5 = 101;
|
||||
Phaser.Keyboard.NUMPAD_6 = 102;
|
||||
Phaser.Keyboard.NUMPAD_7 = 103;
|
||||
Phaser.Keyboard.NUMPAD_8 = 104;
|
||||
Phaser.Keyboard.NUMPAD_9 = 105;
|
||||
Phaser.Keyboard.NUMPAD_MULTIPLY = 106;
|
||||
Phaser.Keyboard.NUMPAD_ADD = 107;
|
||||
Phaser.Keyboard.NUMPAD_ENTER = 108;
|
||||
Phaser.Keyboard.NUMPAD_SUBTRACT = 109;
|
||||
Phaser.Keyboard.NUMPAD_DECIMAL = 110;
|
||||
Phaser.Keyboard.NUMPAD_DIVIDE = 111;
|
||||
Phaser.Keyboard.F1 = 112;
|
||||
Phaser.Keyboard.F2 = 113;
|
||||
Phaser.Keyboard.F3 = 114;
|
||||
Phaser.Keyboard.F4 = 115;
|
||||
Phaser.Keyboard.F5 = 116;
|
||||
Phaser.Keyboard.F6 = 117;
|
||||
Phaser.Keyboard.F7 = 118;
|
||||
Phaser.Keyboard.F8 = 119;
|
||||
Phaser.Keyboard.F9 = 120;
|
||||
Phaser.Keyboard.F10 = 121;
|
||||
Phaser.Keyboard.F11 = 122;
|
||||
Phaser.Keyboard.F12 = 123;
|
||||
Phaser.Keyboard.F13 = 124;
|
||||
Phaser.Keyboard.F14 = 125;
|
||||
Phaser.Keyboard.F15 = 126;
|
||||
Phaser.Keyboard.COLON = 186;
|
||||
Phaser.Keyboard.EQUALS = 187;
|
||||
Phaser.Keyboard.UNDERSCORE = 189;
|
||||
Phaser.Keyboard.QUESTION_MARK = 191;
|
||||
Phaser.Keyboard.TILDE = 192;
|
||||
Phaser.Keyboard.OPEN_BRACKET = 219;
|
||||
Phaser.Keyboard.BACKWARD_SLASH = 220;
|
||||
Phaser.Keyboard.CLOSED_BRACKET = 221;
|
||||
Phaser.Keyboard.QUOTES = 222;
|
||||
Phaser.Keyboard.BACKSPACE = 8;
|
||||
Phaser.Keyboard.TAB = 9;
|
||||
Phaser.Keyboard.CLEAR = 12;
|
||||
Phaser.Keyboard.ENTER = 13;
|
||||
Phaser.Keyboard.SHIFT = 16;
|
||||
Phaser.Keyboard.CONTROL = 17;
|
||||
Phaser.Keyboard.ALT = 18;
|
||||
Phaser.Keyboard.CAPS_LOCK = 20;
|
||||
Phaser.Keyboard.ESC = 27;
|
||||
Phaser.Keyboard.SPACEBAR = 32;
|
||||
Phaser.Keyboard.PAGE_UP = 33;
|
||||
Phaser.Keyboard.PAGE_DOWN = 34;
|
||||
Phaser.Keyboard.END = 35;
|
||||
Phaser.Keyboard.HOME = 36;
|
||||
Phaser.Keyboard.LEFT = 37;
|
||||
Phaser.Keyboard.UP = 38;
|
||||
Phaser.Keyboard.RIGHT = 39;
|
||||
Phaser.Keyboard.DOWN = 40;
|
||||
Phaser.Keyboard.INSERT = 45;
|
||||
Phaser.Keyboard.DELETE = 46;
|
||||
Phaser.Keyboard.HELP = 47;
|
||||
Phaser.Keyboard.NUM_LOCK = 144;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,757 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: geom/Line.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: geom/Line.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new Line object with a start and an end point.
|
||||
* @class Line
|
||||
* @classdesc Phaser - Line
|
||||
* @constructor
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
* @param {number} [y1=0] - The y coordinate of the start of the line.
|
||||
* @param {number} [x2=0] - The x coordinate of the end of the line.
|
||||
* @param {number} [y2=0] - The y coordinate of the end of the line.
|
||||
* @return {Phaser.Line} This line object
|
||||
*/
|
||||
Phaser.Line = function (x1, y1, x2, y2) {
|
||||
|
||||
x1 = x1 || 0;
|
||||
y1 = y1 || 0;
|
||||
x2 = x2 || 0;
|
||||
y2 = y2 || 0;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} start - The start point of the line.
|
||||
*/
|
||||
this.start = new Phaser.Point(x1, y1);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} end - The end point of the line.
|
||||
*/
|
||||
this.end = new Phaser.Point(x2, y2);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Line.prototype = {
|
||||
|
||||
/**
|
||||
* Sets the components of the Line to the specified values.
|
||||
* @method Phaser.Line#setTo
|
||||
* @param {number} [x1=0] - The x coordinate of the start of the line.
|
||||
* @param {number} [y1=0] - The y coordinate of the start of the line.
|
||||
* @param {number} [x2=0] - The x coordinate of the end of the line.
|
||||
* @param {number} [y2=0] - The y coordinate of the end of the line.
|
||||
* @return {Phaser.Line} This line object
|
||||
*/
|
||||
setTo: function (x1, y1, x2, y2) {
|
||||
|
||||
this.start.setTo(x1, y1);
|
||||
this.end.setTo(x2, y2);
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the line to match the x/y coordinates of the two given sprites.
|
||||
* Can optionally be calculated from their center coordinates.
|
||||
* @method Phaser.Line#fromSprite
|
||||
* @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
* @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
|
||||
* @param {boolean} [useCenter=true] - If true it will use startSprite.center.x, if false startSprite.x.
|
||||
* @return {Phaser.Line} This line object
|
||||
*/
|
||||
fromSprite: function (startSprite, endSprite, useCenter) {
|
||||
|
||||
if (typeof useCenter === 'undefined') { useCenter = true; }
|
||||
|
||||
if (useCenter)
|
||||
{
|
||||
return this.setTo(startSprite.center.x, startSprite.center.y, endSprite.center.x, endSprite.center.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.setTo(startSprite.x, startSprite.y, endSprite.x, endSprite.y);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks for intersection between this line and another Line.
|
||||
* If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection.
|
||||
* Returns the intersection segment of AB and EF as a Point, or null if there is no intersection.
|
||||
*
|
||||
* @method Phaser.Line#intersects
|
||||
* @param {Phaser.Line} line - The line to check against this one.
|
||||
* @param {boolean} [asSegment=true] - If true it will check for segment intersection, otherwise full line intersection.
|
||||
* @param {Phaser.Point} [result] - A Point object to store the result in, if not given a new one will be created.
|
||||
* @return {Phaser.Point} The intersection segment of the two lines as a Point, or null if there is no intersection.
|
||||
*/
|
||||
intersects: function (line, asSegment, result) {
|
||||
|
||||
return Phaser.Line.intersectsPoints(this.start, this.end, line.start, line.end, asSegment, result);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.
|
||||
* @method Phaser.Line#pointOnLine
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
* @return {boolean} True if the point is on the line, false if not.
|
||||
*/
|
||||
pointOnLine: function (x, y) {
|
||||
|
||||
return ((x - this.start.x) * (this.end.y - this.end.y) === (this.end.x - this.start.x) * (y - this.end.y));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.
|
||||
* @method Phaser.Line#pointOnSegment
|
||||
* @param {number} x - The line to check against this one.
|
||||
* @param {number} y - The line to check against this one.
|
||||
* @return {boolean} True if the point is on the line and segment, false if not.
|
||||
*/
|
||||
pointOnSegment: function (x, y) {
|
||||
|
||||
var xMin = Math.min(this.start.x, this.end.x);
|
||||
var xMax = Math.max(this.start.x, this.end.x);
|
||||
var yMin = Math.min(this.start.y, this.end.y);
|
||||
var yMax = Math.max(this.start.y, this.end.y);
|
||||
|
||||
return (this.pointOnLine(x, y) && (x >= xMin && x <= xMax) && (y >= yMin && y <= yMax));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Line#length
|
||||
* @property {number} length - Gets the length of the line segment.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Line.prototype, "length", {
|
||||
|
||||
get: function () {
|
||||
return Math.sqrt((this.end.x - this.start.x) * (this.end.x - this.start.x) + (this.end.y - this.start.y) * (this.end.y - this.start.y));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Line#angle
|
||||
* @property {number} angle - Gets the angle of the line.
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Line.prototype, "angle", {
|
||||
|
||||
get: function () {
|
||||
return Math.atan2(this.end.x - this.start.x, this.end.y - this.start.y);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Line#slope
|
||||
* @property {number} slope - Gets the slope of the line (y/x).
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Line.prototype, "slope", {
|
||||
|
||||
get: function () {
|
||||
return (this.end.y - this.start.y) / (this.end.x - this.start.x);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Line#perpSlope
|
||||
* @property {number} perpSlope - Gets the perpendicular slope of the line (x/y).
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Line.prototype, "perpSlope", {
|
||||
|
||||
get: function () {
|
||||
return -((this.end.x - this.start.x) / (this.end.y - this.start.y));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks for intersection between two lines as defined by the given start and end points.
|
||||
* If asSegment is true it will check for line segment intersection. If asSegment is false it will check for line intersection.
|
||||
* Returns the intersection segment of AB and EF as a Point, or null if there is no intersection.
|
||||
* Adapted from code by Keith Hair
|
||||
*
|
||||
* @method Phaser.Line.intersectsPoints
|
||||
* @param {Phaser.Point} a - The start of the first Line to be checked.
|
||||
* @param {Phaser.Point} b - The end of the first line to be checked.
|
||||
* @param {Phaser.Point} e - The start of the second Line to be checked.
|
||||
* @param {Phaser.Point} f - The end of the second line to be checked.
|
||||
* @param {boolean} [asSegment=true] - If true it will check for segment intersection, otherwise full line intersection.
|
||||
* @param {Phaser.Point} [result] - A Point object to store the result in, if not given a new one will be created.
|
||||
* @return {Phaser.Point} The intersection segment of the two lines as a Point, or null if there is no intersection.
|
||||
*/
|
||||
Phaser.Line.intersectsPoints = function (a, b, e, f, asSegment, result) {
|
||||
|
||||
if (typeof asSegment === 'undefined') { asSegment = true; }
|
||||
if (typeof result === 'undefined') { result = new Phaser.Point(); }
|
||||
|
||||
var a1 = b.y - a.y;
|
||||
var a2 = f.y - e.y;
|
||||
var b1 = a.x - b.x;
|
||||
var b2 = e.x - f.x;
|
||||
var c1 = (b.x * a.y) - (a.x * b.y);
|
||||
var c2 = (f.x * e.y) - (e.x * f.y);
|
||||
var denom = (a1 * b2) - (a2 * b1);
|
||||
|
||||
if (denom === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
result.x = ((b1 * c2) - (b2 * c1)) / denom;
|
||||
result.y = ((a2 * c1) - (a1 * c2)) / denom;
|
||||
|
||||
if (asSegment)
|
||||
{
|
||||
if (Math.pow((result.x - b.x) + (result.y - b.y), 2) > Math.pow((a.x - b.x) + (a.y - b.y), 2))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Math.pow((result.x - a.x) + (result.y - a.y), 2) > Math.pow((a.x - b.x) + (a.y - b.y), 2))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Math.pow((result.x - f.x) + (result.y - f.y), 2) > Math.pow((e.x - f.x) + (e.y - f.y), 2))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Math.pow((result.x - e.x) + (result.y - e.y), 2) > Math.pow((e.x - f.x) + (e.y - f.y), 2))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for intersection between two lines.
|
||||
* If asSegment is true it will check for segment intersection.
|
||||
* If asSegment is false it will check for line intersection.
|
||||
* Returns the intersection segment of AB and EF as a Point, or null if there is no intersection.
|
||||
* Adapted from code by Keith Hair
|
||||
*
|
||||
* @method Phaser.Line.intersects
|
||||
* @param {Phaser.Line} a - The first Line to be checked.
|
||||
* @param {Phaser.Line} b - The second Line to be checked.
|
||||
* @param {boolean} [asSegment=true] - If true it will check for segment intersection, otherwise full line intersection.
|
||||
* @param {Phaser.Point} [result] - A Point object to store the result in, if not given a new one will be created.
|
||||
* @return {Phaser.Point} The intersection segment of the two lines as a Point, or null if there is no intersection.
|
||||
*/
|
||||
Phaser.Line.intersects = function (a, b, asSegment, result) {
|
||||
|
||||
return Phaser.Line.intersectsPoints(a.start, a.end, b.start, b.end, asSegment, result);
|
||||
|
||||
};
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,649 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: core/LinkedList.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: core/LinkedList.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* A basic linked list data structure.
|
||||
*
|
||||
* @class Phaser.LinkedList
|
||||
* @constructor
|
||||
*/
|
||||
Phaser.LinkedList = function () {
|
||||
|
||||
/**
|
||||
* @property {object} next - Next element in the list.
|
||||
* @default
|
||||
*/
|
||||
this.next = null;
|
||||
|
||||
/**
|
||||
* @property {object} prev - Previous element in the list.
|
||||
* @default
|
||||
*/
|
||||
this.prev = null;
|
||||
|
||||
/**
|
||||
* @property {object} first - First element in the list.
|
||||
* @default
|
||||
*/
|
||||
this.first = null;
|
||||
|
||||
/**
|
||||
* @property {object} last - Last element in the list.
|
||||
* @default
|
||||
*/
|
||||
this.last = null;
|
||||
|
||||
/**
|
||||
* @property {object} game - Number of elements in the list.
|
||||
* @default
|
||||
*/
|
||||
this.total = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.LinkedList.prototype = {
|
||||
|
||||
/**
|
||||
* Adds a new element to this linked list.
|
||||
*
|
||||
* @method Phaser.LinkedList#add
|
||||
* @param {object} child - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through.
|
||||
* @return {object} The child that was added.
|
||||
*/
|
||||
add: function (child) {
|
||||
|
||||
// If the list is empty
|
||||
if (this.total === 0 && this.first == null && this.last == null)
|
||||
{
|
||||
this.first = child;
|
||||
this.last = child;
|
||||
this.next = child;
|
||||
child.prev = this;
|
||||
this.total++;
|
||||
return child;
|
||||
}
|
||||
|
||||
// Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list)
|
||||
this.last.next = child;
|
||||
|
||||
child.prev = this.last;
|
||||
|
||||
this.last = child;
|
||||
|
||||
this.total++;
|
||||
|
||||
return child;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the given element from this linked list if it exists.
|
||||
*
|
||||
* @method Phaser.LinkedList#remove
|
||||
* @param {object} child - The child to be removed from the list.
|
||||
*/
|
||||
remove: function (child) {
|
||||
|
||||
if (child == this.first)
|
||||
{
|
||||
// It was 'first', make 'first' point to first.next
|
||||
this.first = this.first.next;
|
||||
}
|
||||
else if (child == this.last)
|
||||
{
|
||||
// It was 'last', make 'last' point to last.prev
|
||||
this.last = this.last.prev;
|
||||
}
|
||||
|
||||
if (child.prev)
|
||||
{
|
||||
// make child.prev.next point to childs.next instead of child
|
||||
child.prev.next = child.next;
|
||||
}
|
||||
|
||||
if (child.next)
|
||||
{
|
||||
// make child.next.prev point to child.prev instead of child
|
||||
child.next.prev = child.prev;
|
||||
}
|
||||
|
||||
child.next = child.prev = null;
|
||||
|
||||
if (this.first == null )
|
||||
{
|
||||
this.last = null;
|
||||
}
|
||||
|
||||
this.total--;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls a function on all members of this list, using the member as the context for the callback.
|
||||
* The function must exist on the member.
|
||||
*
|
||||
* @method Phaser.LinkedList#callAll
|
||||
* @param {function} callback - The function to call.
|
||||
*/
|
||||
callAll: function (callback) {
|
||||
|
||||
if (!this.first || !this.last)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var entity = this.first;
|
||||
|
||||
do
|
||||
{
|
||||
if (entity && entity[callback])
|
||||
{
|
||||
entity[callback].call(entity);
|
||||
}
|
||||
|
||||
entity = entity.next;
|
||||
|
||||
}
|
||||
while(entity != this.last.next)
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.LinkedList.prototype.constructor = Phaser.LinkedList;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,575 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: loader/LoaderParser.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: loader/LoaderParser.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache.
|
||||
*
|
||||
* @class Phaser.LoaderParser
|
||||
*/
|
||||
Phaser.LoaderParser = {
|
||||
|
||||
/**
|
||||
* Parse frame data from an XML file.
|
||||
* @method Phaser.LoaderParser.bitmapFont
|
||||
* @param {object} xml - XML data you want to parse.
|
||||
* @return {FrameData} Generated FrameData object.
|
||||
*/
|
||||
bitmapFont: function (game, xml, cacheKey) {
|
||||
|
||||
// Malformed?
|
||||
if (!xml.getElementsByTagName('font'))
|
||||
{
|
||||
console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing <font> tag");
|
||||
return;
|
||||
}
|
||||
|
||||
var texture = PIXI.TextureCache[cacheKey];
|
||||
|
||||
var data = {};
|
||||
var info = xml.getElementsByTagName("info")[0];
|
||||
var common = xml.getElementsByTagName("common")[0];
|
||||
data.font = info.attributes.getNamedItem("face").nodeValue;
|
||||
data.size = parseInt(info.attributes.getNamedItem("size").nodeValue, 10);
|
||||
data.lineHeight = parseInt(common.attributes.getNamedItem("lineHeight").nodeValue, 10);
|
||||
data.chars = {};
|
||||
|
||||
//parse letters
|
||||
var letters = xml.getElementsByTagName("char");
|
||||
|
||||
for (var i = 0; i < letters.length; i++)
|
||||
{
|
||||
var charCode = parseInt(letters[i].attributes.getNamedItem("id").nodeValue, 10);
|
||||
|
||||
var textureRect = {
|
||||
x: parseInt(letters[i].attributes.getNamedItem("x").nodeValue, 10),
|
||||
y: parseInt(letters[i].attributes.getNamedItem("y").nodeValue, 10),
|
||||
width: parseInt(letters[i].attributes.getNamedItem("width").nodeValue, 10),
|
||||
height: parseInt(letters[i].attributes.getNamedItem("height").nodeValue, 10)
|
||||
};
|
||||
|
||||
// Note: This means you can only have 1 BitmapFont loaded at once!
|
||||
// Need to replace this with our own handler soon.
|
||||
PIXI.TextureCache[charCode] = new PIXI.Texture(texture, textureRect);
|
||||
|
||||
data.chars[charCode] = {
|
||||
xOffset: parseInt(letters[i].attributes.getNamedItem("xoffset").nodeValue, 10),
|
||||
yOffset: parseInt(letters[i].attributes.getNamedItem("yoffset").nodeValue, 10),
|
||||
xAdvance: parseInt(letters[i].attributes.getNamedItem("xadvance").nodeValue, 10),
|
||||
kerning: {},
|
||||
texture:new PIXI.Texture(texture, textureRect)
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
//parse kernings
|
||||
var kernings = xml.getElementsByTagName("kerning");
|
||||
|
||||
for (i = 0; i < kernings.length; i++)
|
||||
{
|
||||
var first = parseInt(kernings[i].attributes.getNamedItem("first").nodeValue, 10);
|
||||
var second = parseInt(kernings[i].attributes.getNamedItem("second").nodeValue, 10);
|
||||
var amount = parseInt(kernings[i].attributes.getNamedItem("amount").nodeValue, 10);
|
||||
|
||||
data.chars[second].kerning[first] = amount;
|
||||
}
|
||||
|
||||
PIXI.BitmapText.fonts[data.font] = data;
|
||||
|
||||
}
|
||||
|
||||
};</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,663 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: input/MSPointer.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: input/MSPointer.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Phaser - MSPointer constructor.
|
||||
*
|
||||
* @class Phaser.MSPointer
|
||||
* @classdesc The MSPointer class handles touch interactions with the game and the resulting Pointer objects.
|
||||
* It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript.
|
||||
* http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.MSPointer = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Object} callbackContext - The context under which callbacks are called (defaults to game).
|
||||
*/
|
||||
this.callbackContext = this.game;
|
||||
|
||||
/**
|
||||
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
|
||||
* @property {boolean} disabled
|
||||
*/
|
||||
this.disabled = false;
|
||||
|
||||
/**
|
||||
* @property {function} _onMSPointerDown - Internal function to handle MSPointer events.
|
||||
* @private
|
||||
*/
|
||||
this._onMSPointerDown = null;
|
||||
|
||||
/**
|
||||
* @property {function} _onMSPointerMove - Internal function to handle MSPointer events.
|
||||
* @private
|
||||
*/
|
||||
this._onMSPointerMove = null;
|
||||
|
||||
/**
|
||||
* @property {function} _onMSPointerUp - Internal function to handle MSPointer events.
|
||||
* @private
|
||||
*/
|
||||
this._onMSPointerUp = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.MSPointer.prototype = {
|
||||
|
||||
/**
|
||||
* Starts the event listeners running.
|
||||
* @method Phaser.MSPointer#start
|
||||
*/
|
||||
start: function () {
|
||||
|
||||
var _this = this;
|
||||
|
||||
if (this.game.device.mspointer === true)
|
||||
{
|
||||
this._onMSPointerDown = function (event) {
|
||||
return _this.onPointerDown(event);
|
||||
};
|
||||
|
||||
this._onMSPointerMove = function (event) {
|
||||
return _this.onPointerMove(event);
|
||||
};
|
||||
|
||||
this._onMSPointerUp = function (event) {
|
||||
return _this.onPointerUp(event);
|
||||
};
|
||||
|
||||
this.game.renderer.view.addEventListener('MSPointerDown', this._onMSPointerDown, false);
|
||||
this.game.renderer.view.addEventListener('MSPointerMove', this._onMSPointerMove, false);
|
||||
this.game.renderer.view.addEventListener('MSPointerUp', this._onMSPointerUp, false);
|
||||
|
||||
// IE11+ uses non-prefix events
|
||||
this.game.renderer.view.addEventListener('pointerDown', this._onMSPointerDown, false);
|
||||
this.game.renderer.view.addEventListener('pointerMove', this._onMSPointerMove, false);
|
||||
this.game.renderer.view.addEventListener('pointerUp', this._onMSPointerUp, false);
|
||||
|
||||
this.game.renderer.view.style['-ms-content-zooming'] = 'none';
|
||||
this.game.renderer.view.style['-ms-touch-action'] = 'none';
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The function that handles the PointerDown event.
|
||||
* @method Phaser.MSPointer#onPointerDown
|
||||
* @param {PointerEvent} event
|
||||
*/
|
||||
onPointerDown: function (event) {
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.identifier = event.pointerId;
|
||||
|
||||
this.game.input.startPointer(event);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The function that handles the PointerMove event.
|
||||
* @method Phaser.MSPointer#onPointerMove
|
||||
* @param {PointerEvent } event
|
||||
*/
|
||||
onPointerMove: function (event) {
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.identifier = event.pointerId;
|
||||
|
||||
this.game.input.updatePointer(event);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The function that handles the PointerUp event.
|
||||
* @method Phaser.MSPointer#onPointerUp
|
||||
* @param {PointerEvent} event
|
||||
*/
|
||||
onPointerUp: function (event) {
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.identifier = event.pointerId;
|
||||
|
||||
this.game.input.stopPointer(event);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop the event listeners.
|
||||
* @method Phaser.MSPointer#stop
|
||||
*/
|
||||
stop: function () {
|
||||
|
||||
this.game.stage.canvas.removeEventListener('MSPointerDown', this._onMSPointerDown);
|
||||
this.game.stage.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove);
|
||||
this.game.stage.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp);
|
||||
|
||||
this.game.stage.canvas.removeEventListener('pointerDown', this._onMSPointerDown);
|
||||
this.game.stage.canvas.removeEventListener('pointerMove', this._onMSPointerMove);
|
||||
this.game.stage.canvas.removeEventListener('pointerUp', this._onMSPointerUp);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.MSPointer.prototype.constructor = Phaser.MSPointer;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,824 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: input/Mouse.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: input/Mouse.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Phaser.Mouse is responsible for handling all aspects of mouse interaction with the browser. It captures and processes mouse events.
|
||||
*
|
||||
* @class Phaser.Mouse
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.Mouse = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Object} callbackContext - The context under which callbacks are called.
|
||||
*/
|
||||
this.callbackContext = this.game;
|
||||
|
||||
/**
|
||||
* @property {function} mouseDownCallback - A callback that can be fired when the mouse is pressed down.
|
||||
*/
|
||||
this.mouseDownCallback = null;
|
||||
|
||||
/**
|
||||
* @property {function} mouseMoveCallback - A callback that can be fired when the mouse is moved while pressed down.
|
||||
*/
|
||||
this.mouseMoveCallback = null;
|
||||
|
||||
/**
|
||||
* @property {function} mouseUpCallback - A callback that can be fired when the mouse is released from a pressed down state.
|
||||
*/
|
||||
this.mouseUpCallback = null;
|
||||
|
||||
/**
|
||||
* @property {boolean} capture - If true the DOM mouse events will have event.preventDefault applied to them, if false they will propogate fully.
|
||||
*/
|
||||
this.capture = false;
|
||||
|
||||
/**
|
||||
* @property {number} button- The type of click, either: Phaser.Mouse.NO_BUTTON, Phaser.Mouse.LEFT_BUTTON, Phaser.Mouse.MIDDLE_BUTTON or Phaser.Mouse.RIGHT_BUTTON.
|
||||
* @default
|
||||
*/
|
||||
this.button = -1;
|
||||
|
||||
/**
|
||||
* @property {boolean} disabled - You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
|
||||
* @default
|
||||
*/
|
||||
this.disabled = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} locked - If the mouse has been Pointer Locked successfully this will be set to true.
|
||||
* @default
|
||||
*/
|
||||
this.locked = false;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} pointerLock - This event is dispatched when the browser enters or leaves pointer lock state.
|
||||
* @default
|
||||
*/
|
||||
this.pointerLock = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {MouseEvent} event - The browser mouse DOM event. Will be set to null if no mouse event has ever been received.
|
||||
* @default
|
||||
*/
|
||||
this.event = null;
|
||||
|
||||
/**
|
||||
* @property {function} _onMouseDown - Internal event handler reference.
|
||||
* @private
|
||||
*/
|
||||
this._onMouseDown = null;
|
||||
|
||||
/**
|
||||
* @property {function} _onMouseMove - Internal event handler reference.
|
||||
* @private
|
||||
*/
|
||||
this._onMouseMove = null;
|
||||
|
||||
/**
|
||||
* @property {function} _onMouseUp - Internal event handler reference.
|
||||
* @private
|
||||
*/
|
||||
this._onMouseUp = null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Mouse.NO_BUTTON = -1;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Mouse.LEFT_BUTTON = 0;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Mouse.MIDDLE_BUTTON = 1;
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @type {number}
|
||||
*/
|
||||
Phaser.Mouse.RIGHT_BUTTON = 2;
|
||||
|
||||
Phaser.Mouse.prototype = {
|
||||
|
||||
/**
|
||||
* Starts the event listeners running.
|
||||
* @method Phaser.Mouse#start
|
||||
*/
|
||||
start: function () {
|
||||
|
||||
var _this = this;
|
||||
|
||||
if (this.game.device.android && this.game.device.chrome === false)
|
||||
{
|
||||
// Android stock browser fires mouse events even if you preventDefault on the touchStart, so ...
|
||||
return;
|
||||
}
|
||||
|
||||
this._onMouseDown = function (event) {
|
||||
return _this.onMouseDown(event);
|
||||
};
|
||||
|
||||
this._onMouseMove = function (event) {
|
||||
return _this.onMouseMove(event);
|
||||
};
|
||||
|
||||
this._onMouseUp = function (event) {
|
||||
return _this.onMouseUp(event);
|
||||
};
|
||||
|
||||
document.addEventListener('mousedown', this._onMouseDown, true);
|
||||
document.addEventListener('mousemove', this._onMouseMove, true);
|
||||
document.addEventListener('mouseup', this._onMouseUp, true);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The internal method that handles the mouse down event from the browser.
|
||||
* @method Phaser.Mouse#onMouseDown
|
||||
* @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event.
|
||||
*/
|
||||
onMouseDown: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
if (this.capture)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
this.button = event.which;
|
||||
|
||||
if (this.mouseDownCallback)
|
||||
{
|
||||
this.mouseDownCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event['identifier'] = 0;
|
||||
|
||||
this.game.input.mousePointer.start(event);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The internal method that handles the mouse move event from the browser.
|
||||
* @method Phaser.Mouse#onMouseMove
|
||||
* @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event.
|
||||
*/
|
||||
onMouseMove: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
if (this.capture)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (this.mouseMoveCallback)
|
||||
{
|
||||
this.mouseMoveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event['identifier'] = 0;
|
||||
|
||||
this.game.input.mousePointer.move(event);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* The internal method that handles the mouse up event from the browser.
|
||||
* @method Phaser.Mouse#onMouseUp
|
||||
* @param {MouseEvent} event - The native event from the browser. This gets stored in Mouse.event.
|
||||
*/
|
||||
onMouseUp: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
if (this.capture)
|
||||
{
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
this.button = Phaser.Mouse.NO_BUTTON;
|
||||
|
||||
if (this.mouseUpCallback)
|
||||
{
|
||||
this.mouseUpCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this.game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event['identifier'] = 0;
|
||||
|
||||
this.game.input.mousePointer.stop(event);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* If the browser supports it you can request that the pointer be locked to the browser window.
|
||||
* This is classically known as 'FPS controls', where the pointer can't leave the browser until the user presses an exit key.
|
||||
* If the browser successfully enters a locked state the event Phaser.Mouse.pointerLock will be dispatched and the first parameter will be 'true'.
|
||||
* @method Phaser.Mouse#requestPointerLock
|
||||
*/
|
||||
requestPointerLock: function () {
|
||||
|
||||
if (this.game.device.pointerLock)
|
||||
{
|
||||
var element = this.game.stage.canvas;
|
||||
|
||||
element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock;
|
||||
|
||||
element.requestPointerLock();
|
||||
|
||||
var _this = this;
|
||||
|
||||
this._pointerLockChange = function (event) {
|
||||
return _this.pointerLockChange(event);
|
||||
};
|
||||
|
||||
document.addEventListener('pointerlockchange', this._pointerLockChange, true);
|
||||
document.addEventListener('mozpointerlockchange', this._pointerLockChange, true);
|
||||
document.addEventListener('webkitpointerlockchange', this._pointerLockChange, true);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal pointerLockChange handler.
|
||||
* @method Phaser.Mouse#pointerLockChange
|
||||
* @param {pointerlockchange} event - The native event from the browser. This gets stored in Mouse.event.
|
||||
*/
|
||||
pointerLockChange: function (event) {
|
||||
|
||||
var element = this.game.stage.canvas;
|
||||
|
||||
if (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element)
|
||||
{
|
||||
// Pointer was successfully locked
|
||||
this.locked = true;
|
||||
this.pointerLock.dispatch(true, event);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pointer was unlocked
|
||||
this.locked = false;
|
||||
this.pointerLock.dispatch(false, event);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Internal release pointer lock handler.
|
||||
* @method Phaser.Mouse#releasePointerLock
|
||||
*/
|
||||
releasePointerLock: function () {
|
||||
|
||||
document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock;
|
||||
|
||||
document.exitPointerLock();
|
||||
|
||||
document.removeEventListener('pointerlockchange', this._pointerLockChange, true);
|
||||
document.removeEventListener('mozpointerlockchange', this._pointerLockChange, true);
|
||||
document.removeEventListener('webkitpointerlockchange', this._pointerLockChange, true);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop the event listeners.
|
||||
* @method Phaser.Mouse#stop
|
||||
*/
|
||||
stop: function () {
|
||||
|
||||
document.removeEventListener('mousedown', this._onMouseDown, true);
|
||||
document.removeEventListener('mousemove', this._onMouseMove, true);
|
||||
document.removeEventListener('mouseup', this._onMouseUp, true);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Mouse.prototype.constructor = Phaser.Mouse;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,659 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: net/Net.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: net/Net.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Phaser.Net handles browser URL related tasks such as checking host names, domain names and query string manipulation.
|
||||
*
|
||||
* @class Phaser.Net
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.Net = function (game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Net.prototype = {
|
||||
|
||||
/**
|
||||
* Returns the hostname given by the browser.
|
||||
*
|
||||
* @method Phaser.Net#getHostName
|
||||
* @return {string}
|
||||
*/
|
||||
getHostName: function () {
|
||||
|
||||
if (window.location && window.location.hostname) {
|
||||
return window.location.hostname;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Compares the given domain name against the hostname of the browser containing the game.
|
||||
* If the domain name is found it returns true.
|
||||
* You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc.
|
||||
* Do not include 'http://' at the start.
|
||||
*
|
||||
* @method Phaser.Net#checkDomainName
|
||||
* @param {string} domain
|
||||
* @return {boolean} true if the given domain fragment can be found in the window.location.hostname
|
||||
*/
|
||||
checkDomainName: function (domain) {
|
||||
return window.location.hostname.indexOf(domain) !== -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates a value on the Query String and returns it in full.
|
||||
* If the value doesn't already exist it is set.
|
||||
* If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string.
|
||||
* Optionally you can redirect to the new url, or just return it as a string.
|
||||
*
|
||||
* @method Phaser.Net#updateQueryString
|
||||
* @param {string} key - The querystring key to update.
|
||||
* @param {string} value - The new value to be set. If it already exists it will be replaced.
|
||||
* @param {boolean} redirect - If true the browser will issue a redirect to the url with the new querystring.
|
||||
* @param {string} url - The URL to modify. If none is given it uses window.location.href.
|
||||
* @return {string} If redirect is false then the modified url and query string is returned.
|
||||
*/
|
||||
updateQueryString: function (key, value, redirect, url) {
|
||||
|
||||
if (typeof redirect === "undefined") { redirect = false; }
|
||||
if (typeof url === "undefined" || url === '') { url = window.location.href; }
|
||||
|
||||
var output = '';
|
||||
var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi");
|
||||
|
||||
if (re.test(url))
|
||||
{
|
||||
if (typeof value !== 'undefined' && value !== null)
|
||||
{
|
||||
output = url.replace(re, '$1' + key + "=" + value + '$2$3');
|
||||
}
|
||||
else
|
||||
{
|
||||
output = url.replace(re, '$1$3').replace(/(&|\?)$/, '');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof value !== 'undefined' && value !== null)
|
||||
{
|
||||
var separator = url.indexOf('?') !== -1 ? '&' : '?';
|
||||
var hash = url.split('#');
|
||||
url = hash[0] + separator + key + '=' + value;
|
||||
|
||||
if (hash[1]) {
|
||||
url += '#' + hash[1];
|
||||
}
|
||||
|
||||
output = url;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
output = url;
|
||||
}
|
||||
}
|
||||
|
||||
if (redirect)
|
||||
{
|
||||
window.location.href = output;
|
||||
}
|
||||
else
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the Query String as an object.
|
||||
* If you specify a parameter it will return just the value of that parameter, should it exist.
|
||||
*
|
||||
* @method Phaser.Net#getQueryString
|
||||
* @param {string} [parameter=''] - If specified this will return just the value for that key.
|
||||
* @return {string|object} An object containing the key value pairs found in the query string or just the value if a parameter was given.
|
||||
*/
|
||||
getQueryString: function (parameter) {
|
||||
|
||||
if (typeof parameter === "undefined") { parameter = ''; }
|
||||
|
||||
var output = {};
|
||||
var keyValues = location.search.substring(1).split('&');
|
||||
|
||||
for (var i in keyValues)
|
||||
{
|
||||
var key = keyValues[i].split('=');
|
||||
|
||||
if (key.length > 1)
|
||||
{
|
||||
if (parameter && parameter == this.decodeURI(key[0]))
|
||||
{
|
||||
return this.decodeURI(key[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
output[this.decodeURI(key[0])] = this.decodeURI(key[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the Query String as an object.
|
||||
* If you specify a parameter it will return just the value of that parameter, should it exist.
|
||||
*
|
||||
* @method Phaser.Net#decodeURI
|
||||
* @param {string} value - The URI component to be decoded.
|
||||
* @return {string} The decoded value.
|
||||
*/
|
||||
decodeURI: function (value) {
|
||||
return decodeURIComponent(value.replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Net.prototype.constructor = Phaser.Net;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,574 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Phaser Source: particles/Particles.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand" href="index.html">Phaser</a>
|
||||
<ul class="nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.html">Phaser</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Animation.html">Animation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationManager.html">AnimationManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.AnimationParser.html">AnimationParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapData.html">BitmapData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.BitmapText.html">BitmapText</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Button.html">Button</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Cache.html">Cache</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Camera.html">Camera</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Canvas.html">Canvas</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Circle.html">Circle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Color.html">Color</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Back.html">Back</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Bounce.html">Bounce</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Circular.html">Circular</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Cubic.html">Cubic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Elastic.html">Elastic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Exponential.html">Exponential</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Linear.html">Linear</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quartic.html">Quartic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Quintic.html">Quintic</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Events.html">Events</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Filter.html">Filter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Frame.html">Frame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.FrameData.html">FrameData</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Game.html">Game</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Group.html">Group</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Input.html">Input</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.InputHandler.html">InputHandler</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Key.html">Key</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Loader.html">Loader</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LoaderParser.html">LoaderParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Math.html">Math</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Mouse.html">Mouse</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.MSPointer.html">MSPointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Net.html">Net</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.html">Particles</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.html">Physics</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.html">Arcade</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Plugin.html">Plugin</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.PluginManager.html">PluginManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Point.html">Point</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Pointer.html">Pointer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Polygon.html">Polygon</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.QuadTree.html">QuadTree</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Rectangle.html">Rectangle</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RenderTexture.html">RenderTexture</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SoundManager.html">SoundManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sprite.html">Sprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Stage.html">Stage</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StageScaleMode.html">StageScaleMode</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.State.html">State</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.StateManager.html">StateManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Text.html">Text</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tile.html">Tile</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tilemap.html">Tilemap</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TilemapParser.html">TilemapParser</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tileset.html">Tileset</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TileSprite.html">TileSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Time.html">Time</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Tween.html">Tween</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TweenManager.html">TweenManager</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.html">Utils</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Utils.Debug.html">Debug</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.World.html">World</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="SignalBinding.html">SignalBinding</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#SAT">SAT</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
|
||||
<h1 class="page-title">Source: particles/Particles.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Phaser.Particles is the Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it.
|
||||
*
|
||||
* @class Phaser.Particles
|
||||
* @classdesc Phaser Particles
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.Particles = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {object} emitters - Internal emitters store.
|
||||
*/
|
||||
this.emitters = {};
|
||||
|
||||
/**
|
||||
* @property {number} ID -
|
||||
* @default
|
||||
*/
|
||||
this.ID = 0;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Particles.prototype = {
|
||||
|
||||
/**
|
||||
* Adds a new Particle Emitter to the Particle Manager.
|
||||
* @method Phaser.Particles#add
|
||||
* @param {Phaser.Emitter} emitter - The emitter to be added to the particle manager.
|
||||
* @return {Phaser.Emitter} The emitter that was added.
|
||||
*/
|
||||
add: function (emitter) {
|
||||
|
||||
this.emitters[emitter.name] = emitter;
|
||||
|
||||
return emitter;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes an existing Particle Emitter from the Particle Manager.
|
||||
* @method Phaser.Particles#remove
|
||||
* @param {Phaser.Emitter} emitter - The emitter to remove.
|
||||
*/
|
||||
remove: function (emitter) {
|
||||
|
||||
delete this.emitters[emitter.name];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Called by the core game loop. Updates all Emitters who have their exists value set to true.
|
||||
* @method Phaser.Particles#update
|
||||
* @protected
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
for (var key in this.emitters)
|
||||
{
|
||||
if (this.emitters[key].exists)
|
||||
{
|
||||
this.emitters[key].update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Particles.prototype.constructor = Phaser.Particles;
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Mon Feb 24 2014 01:12:21 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<br clear="both">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="scripts/sunlight.js"></script>
|
||||
<script src="scripts/sunlight.javascript.js"></script>
|
||||
<script src="scripts/sunlight-plugin.doclinks.js"></script>
|
||||
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
|
||||
<script src="scripts/sunlight-plugin.menu.js"></script>
|
||||
<script src="scripts/jquery.min.js"></script>
|
||||
<script src="scripts/jquery.scrollTo.js"></script>
|
||||
<script src="scripts/jquery.localScroll.js"></script>
|
||||
<script src="scripts/bootstrap-dropdown.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
|
||||
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "#toc" ).toc( {
|
||||
selectors : "h1,h2,h3,h4",
|
||||
showAndHide : false,
|
||||
scrollTo : 60
|
||||
} );
|
||||
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||