diff --git a/README.md b/README.md index 5723cf80..40f737e1 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ New features: * 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) + New Examples: diff --git a/examples/assets/maps/CommandoMap1-1BG.png b/examples/assets/maps/CommandoMap1-1BG.png index 963eaa46..a22ee5e7 100644 Binary files a/examples/assets/maps/CommandoMap1-1BG.png and b/examples/assets/maps/CommandoMap1-1BG.png differ diff --git a/examples/assets/maps/CommandoMap1-1BG_bank.png b/examples/assets/maps/CommandoMap1-1BG_bank.png new file mode 100644 index 00000000..bd2ebe65 Binary files /dev/null and b/examples/assets/maps/CommandoMap1-1BG_bank.png differ diff --git a/examples/assets/maps/CommandoMap1-1BG_map.tmx b/examples/assets/maps/CommandoMap1-1BG_map.tmx new file mode 100644 index 00000000..a69e1cd0 --- /dev/null +++ b/examples/assets/maps/CommandoMap1-1BG_map.tmx @@ -0,0 +1,2890 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/assets/maps/commando.json b/examples/assets/maps/commando.json new file mode 100644 index 00000000..07500aef --- /dev/null +++ b/examples/assets/maps/commando.json @@ -0,0 +1,39 @@ +{ "height":180, + "layers":[ + { + "data":[1, 1, 1, 1, 1, 2, 3, 4, 4, 5, 6, 1, 1, 1, 1, 1, 7, 7, 7, 7, 7, 8, 9, 4, 4, 10, 11, 7, 7, 7, 7, 7, 12, 12, 12, 12, 12, 13, 14, 4, 4, 15, 16, 12, 12, 12, 12, 12, 17, 17, 18, 17, 18, 4, 19, 4, 4, 20, 21, 18, 17, 17, 18, 17, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 17, 17, 18, 17, 18, 22, 23, 23, 24, 17, 17, 18, 17, 22, 23, 23, 24, 18, 17, 18, 17, 17, 17, 17, 17, 17, 18, 17, 18, 17, 17, 17, 25, 26, 26, 26, 26, 27, 18, 18, 17, 18, 18, 18, 17, 17, 17, 18, 28, 29, 29, 29, 29, 30, 18, 17, 18, 17, 17, 18, 17, 17, 17, 18, 28, 31, 31, 31, 31, 30, 17, 17, 17, 17, 18, 17, 18, 17, 18, 18, 28, 29, 29, 29, 29, 30, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 28, 31, 31, 31, 31, 30, 17, 18, 17, 18, 18, 17, 17, 17, 17, 18, 28, 29, 29, 29, 29, 30, 18, 18, 17, 17, 18, 17, 17, 18, 17, 17, 28, 31, 31, 31, 31, 30, 17, 17, 18, 17, 17, 17, 18, 17, 17, 17, 28, 29, 29, 32, 32, 33, 18, 17, 17, 18, 17, 17, 17, 18, 18, 17, 34, 32, 32, 35, 35, 35, 35, 35, 36, 17, 17, 18, 37, 18, 17, 17, 17, 17, 17, 38, 38, 38, 38, 38, 39, 17, 17, 17, 18, 17, 18, 17, 17, 17, 17, 38, 38, 38, 38, 38, 39, 18, 17, 18, 17, 18, 37, 17, 17, 17, 17, 38, 38, 38, 38, 38, 39, 17, 17, 22, 23, 23, 24, 17, 37, 18, 37, 40, 40, 40, 40, 40, 41, 17, 17, 17, 17, 17, 17, 42, 43, 17, 18, 37, 18, 18, 37, 17, 18, 17, 17, 18, 17, 18, 18, 44, 45, 18, 17, 18, 17, 37, 17, 17, 17, 37, 18, 42, 43, 17, 17, 17, 18, 37, 18, 17, 17, 17, 18, 18, 17, 18, 46, 44, 45, 17, 17, 18, 17, 18, 17, 17, 17, 17, 18, 42, 43, 18, 37, 18, 17, 17, 18, 18, 37, 18, 17, 17, 18, 17, 17, 44, 45, 17, 18, 17, 18, 18, 37, 46, 25, 26, 26, 18, 17, 18, 18, 37, 18, 17, 17, 18, 17, 18, 18, 37, 28, 29, 29, 42, 43, 17, 37, 46, 37, 18, 18, 17, 17, 17, 37, 18, 28, 31, 31, 44, 45, 17, 18, 47, 47, 47, 18, 17, 17, 18, 17, 17, 28, 29, 29, 37, 17, 18, 17, 48, 48, 48, 17, 17, 18, 17, 17, 17, 28, 31, 31, 17, 18, 37, 18, 49, 49, 49, 17, 17, 17, 18, 18, 17, 34, 32, 32, 17, 18, 18, 46, 18, 18, 17, 17, 18, 37, 18, 17, 18, 17, 18, 47, 18, 17, 37, 18, 37, 17, 17, 17, 17, 18, 17, 18, 18, 37, 47, 48, 23, 23, 23, 23, 24, 37, 18, 17, 18, 17, 18, 37, 18, 47, 48, 48, 17, 37, 18, 17, 18, 17, 17, 17, 17, 18, 17, 18, 47, 48, 48, 48, 18, 46, 37, 17, 17, 17, 17, 17, 17, 17, 17, 17, 49, 48, 48, 48, 37, 18, 18, 37, 17, 18, 17, 17, 18, 17, 18, 18, 17, 48, 48, 48, 18, 17, 37, 17, 17, 17, 22, 23, 23, 24, 17, 17, 17, 49, 48, 48, 17, 17, 17, 18, 18, 17, 18, 46, 18, 17, 17, 17, 18, 17, 48, 48, 17, 17, 17, 18, 17, 37, 18, 37, 18, 17, 17, 18, 18, 37, 48, 48, 17, 18, 17, 17, 18, 18, 17, 18, 18, 18, 37, 17, 46, 18, 49, 48, 22, 23, 23, 24, 37, 18, 17, 17, 18, 17, 18, 18, 37, 37, 18, 48, 17, 18, 17, 37, 46, 37, 18, 18, 17, 17, 17, 37, 18, 17, 18, 49, 17, 17, 17, 18, 18, 37, 17, 18, 17, 22, 23, 23, 23, 24, 17, 18, 37, 17, 18, 17, 37, 18, 17, 17, 17, 18, 17, 17, 17, 17, 18, 17, 17, 18, 37, 18, 17, 17, 18, 17, 17, 17, 18, 18, 17, 18, 17, 17, 17, 50, 51, 46, 18, 18, 17, 17, 18, 37, 18, 17, 18, 25, 29, 29, 50, 52, 53, 51, 37, 17, 17, 17, 17, 18, 17, 18, 18, 28, 29, 29, 54, 55, 56, 55, 22, 23, 23, 24, 18, 17, 18, 37, 18, 28, 29, 29, 17, 57, 18, 57, 18, 17, 17, 17, 17, 18, 17, 18, 17, 28, 29, 29, 18, 46, 37, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 28, 31, 31, 37, 18, 18, 37, 17, 18, 17, 17, 18, 17, 18, 18, 17, 34, 32, 32, 18, 17, 37, 17, 17, 17, 37, 18, 37, 18, 17, 17, 17, 18, 37, 18, 17, 17, 17, 18, 18, 17, 18, 46, 37, 18, 17, 17, 17, 18, 37, 18, 17, 42, 43, 18, 17, 37, 18, 42, 43, 17, 17, 18, 18, 42, 43, 17, 17, 44, 45, 17, 18, 18, 17, 44, 45, 18, 18, 37, 46, 44, 45, 18, 18, 17, 18, 18, 37, 18, 17, 17, 18, 17, 18, 18, 37, 37, 18, 17, 17, 18, 17, 37, 46, 37, 18, 18, 17, 17, 17, 37, 18, 17, 18, 37, 17, 17, 17, 17, 18, 37, 17, 18, 17, 17, 18, 17, 17, 18, 17, 18, 17, 17, 17, 17, 37, 18, 17, 17, 17, 18, 42, 43, 17, 17, 18, 17, 17, 17, 17, 17, 17, 17, 18, 17, 17, 17, 44, 45, 17, 18, 17, 17, 17, 18, 18, 46, 18, 18, 17, 17, 18, 37, 18, 17, 18, 17, 18, 17, 18, 17, 37, 18, 37, 17, 17, 17, 17, 18, 17, 18, 18, 37, 18, 18, 17, 18, 17, 17, 17, 37, 18, 17, 18, 17, 18, 42, 43, 18, 46, 37, 22, 23, 23, 24, 18, 17, 17, 17, 17, 18, 17, 44, 45, 37, 18, 37, 18, 46, 37, 17, 17, 17, 17, 42, 43, 17, 17, 17, 18, 17, 17, 18, 37, 18, 18, 37, 17, 18, 17, 44, 45, 17, 18, 18, 17, 17, 18, 17, 18, 17, 42, 43, 17, 17, 37, 18, 37, 18, 17, 17, 17, 18, 37, 18, 17, 17, 44, 45, 18, 17, 18, 46, 18, 17, 17, 17, 18, 17, 18, 17, 17, 17, 17, 18, 17, 37, 18, 37, 18, 17, 17, 18, 22, 23, 23, 24, 17, 18, 17, 17, 18, 18, 17, 18, 17, 18, 18, 37, 46, 18, 17, 47, 18, 17, 18, 18, 37, 18, 17, 17, 18, 17, 18, 18, 37, 37, 47, 48, 17, 18, 17, 42, 43, 37, 18, 18, 17, 17, 42, 43, 18, 17, 48, 48, 17, 17, 17, 44, 45, 37, 17, 18, 17, 17, 44, 45, 17, 18, 48, 48, 37, 17, 18, 17, 37, 18, 17, 17, 17, 18, 17, 17, 17, 17, 48, 48, 17, 18, 37, 18, 17, 17, 18, 17, 17, 17, 18, 18, 17, 18, 49, 49, 42, 43, 18, 46, 18, 18, 17, 17, 18, 37, 58, 35, 35, 35, 35, 35, 44, 45, 37, 18, 37, 17, 17, 17, 17, 18, 59, 38, 38, 38, 38, 38, 17, 18, 17, 17, 17, 37, 18, 17, 18, 17, 59, 38, 38, 38, 38, 38, 17, 37, 58, 35, 35, 36, 17, 17, 17, 18, 59, 38, 38, 38, 38, 38, 18, 46, 59, 38, 38, 39, 17, 17, 17, 17, 59, 38, 38, 38, 38, 38, 37, 18, 60, 40, 40, 41, 17, 17, 18, 17, 60, 40, 40, 40, 40, 40, 18, 17, 37, 17, 17, 17, 37, 18, 37, 18, 17, 17, 17, 18, 37, 18, 17, 17, 17, 18, 18, 17, 18, 46, 18, 17, 17, 17, 18, 17, 18, 17, 17, 17, 17, 18, 17, 37, 18, 37, 18, 17, 17, 18, 18, 37, 18, 17, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 65, 65, 65, 65, 65, 66, 67, 67, 68, 65, 65, 65, 65, 65, 65, 69, 69, 69, 69, 69, 69, 70, 71, 71, 72, 69, 69, 69, 69, 69, 69, 47, 47, 47, 46, 18, 18, 17, 17, 18, 37, 18, 17, 18, 17, 18, 17, 48, 48, 48, 47, 37, 17, 17, 17, 17, 18, 17, 18, 18, 73, 18, 18, 48, 48, 48, 48, 17, 50, 51, 17, 18, 17, 18, 37, 22, 23, 23, 24, 48, 48, 48, 49, 18, 54, 55, 17, 17, 18, 17, 18, 17, 37, 18, 37, 48, 48, 49, 17, 17, 17, 57, 17, 17, 17, 17, 17, 18, 17, 17, 18, 48, 49, 18, 37, 17, 18, 17, 17, 18, 17, 18, 18, 17, 17, 18, 17, 48, 50, 51, 17, 17, 17, 37, 18, 37, 50, 51, 17, 17, 18, 37, 18, 48, 54, 55, 18, 18, 17, 18, 46, 37, 54, 55, 17, 17, 18, 37, 18, 48, 47, 57, 18, 37, 37, 18, 37, 18, 17, 57, 18, 18, 37, 18, 47, 48, 48, 17, 17, 47, 47, 47, 18, 17, 18, 18, 37, 46, 18, 17, 48, 48, 48, 18, 18, 49, 48, 48, 17, 18, 17, 18, 18, 37, 37, 47, 48, 48, 48, 17, 37, 46, 49, 49, 18, 17, 17, 17, 37, 18, 17, 48, 48, 48, 48, 17, 18, 18, 37, 17, 18, 17, 18, 37, 17, 17, 18, 48, 48, 48, 48, 18, 17, 37, 18, 17, 17, 17, 18, 17, 17, 17, 47, 48, 48, 49, 49, 37, 18, 17, 17, 18, 17, 37, 18, 18, 18, 47, 48, 48, 48, 18, 17, 37, 18, 37, 50, 51, 17, 17, 18, 17, 18, 48, 48, 48, 48, 74, 74, 75, 17, 50, 52, 53, 51, 18, 17, 18, 37, 48, 48, 48, 48, 76, 76, 76, 77, 54, 55, 56, 55, 17, 18, 17, 18, 49, 48, 48, 48, 78, 78, 78, 79, 17, 57, 17, 57, 17, 17, 17, 17, 18, 49, 49, 49, 80, 80, 80, 81, 17, 18, 17, 18, 18, 18, 18, 18, 17, 82, 74, 74, 83, 83, 83, 84, 17, 17, 37, 46, 37, 18, 17, 17, 85, 76, 76, 76, 17, 17, 17, 18, 18, 17, 18, 17, 17, 18, 17, 17, 86, 78, 78, 78, 17, 18, 18, 46, 18, 18, 17, 17, 18, 37, 18, 17, 87, 88, 88, 88, 17, 17, 17, 18, 17, 37, 18, 37, 18, 17, 17, 18, 89, 90, 90, 90, 17, 18, 17, 17, 18, 18, 17, 18, 17, 18, 18, 37, 46, 47, 47, 47, 18, 17, 18, 18, 37, 18, 17, 18, 17, 17, 18, 18, 37, 48, 48, 48, 17, 18, 17, 37, 18, 82, 74, 74, 75, 17, 17, 37, 18, 48, 48, 48, 47, 17, 17, 18, 85, 76, 76, 76, 76, 77, 17, 37, 17, 48, 48, 48, 48, 47, 18, 17, 86, 78, 78, 78, 78, 79, 18, 17, 17, 48, 48, 48, 48, 48, 37, 18, 87, 88, 88, 80, 80, 81, 17, 17, 17, 49, 49, 49, 48, 48, 37, 18, 89, 90, 90, 83, 83, 84, 18, 18, 18, 82, 74, 74, 48, 48, 17, 17, 18, 17, 37, 17, 18, 17, 18, 37, 85, 76, 76, 76, 48, 48, 18, 17, 17, 18, 17, 37, 17, 18, 17, 18, 86, 78, 78, 78, 49, 49, 37, 17, 17, 17, 37, 17, 17, 17, 17, 17, 87, 88, 88, 88, 74, 74, 74, 74, 74, 74, 75, 17, 18, 17, 18, 18, 89, 90, 90, 90, 76, 76, 76, 76, 76, 76, 76, 77, 37, 18, 17, 17, 17, 47, 47, 47, 78, 78, 78, 78, 78, 78, 78, 79, 18, 17, 17, 17, 18, 48, 48, 48, 80, 80, 80, 80, 80, 80, 80, 81, 18, 17, 17, 18, 18, 48, 48, 48, 83, 83, 83, 83, 83, 83, 83, 84, 17, 18, 18, 37, 46, 48, 48, 48, 47, 47, 47, 47, 37, 18, 17, 17, 18, 17, 18, 18, 37, 48, 48, 48, 48, 48, 48, 48, 18, 18, 17, 17, 18, 37, 18, 17, 18, 48, 48, 48, 48, 48, 48, 48, 46, 37, 18, 18, 17, 17, 17, 37, 18, 48, 48, 48, 48, 48, 48, 48, 18, 37, 17, 18, 17, 17, 18, 17, 47, 48, 48, 48, 48, 48, 48, 48, 37, 18, 17, 17, 17, 18, 17, 17, 48, 48, 48, 48, 48, 48, 49, 49, 17, 17, 18, 17, 17, 17, 18, 18, 48, 48, 48, 48, 48, 48, 17, 18, 17, 17, 17, 17, 17, 18, 17, 17, 49, 48, 48, 48, 48, 48, 18, 17, 18, 17, 47, 47, 47, 47, 17, 17, 17, 48, 48, 48, 48, 48, 17, 17, 17, 18, 48, 48, 48, 48, 17, 18, 17, 49, 48, 48, 48, 48, 18, 17, 17, 17, 49, 49, 49, 49, 17, 17, 17, 18, 49, 48, 48, 49, 18, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 50, 51, 48, 49, 18, 17, 18, 17, 18, 18, 18, 17, 17, 17, 17, 17, 54, 55, 48, 74, 74, 75, 17, 17, 17, 18, 17, 18, 17, 17, 17, 17, 17, 57, 48, 76, 76, 76, 77, 17, 17, 17, 18, 18, 17, 17, 17, 17, 17, 47, 48, 78, 78, 78, 79, 17, 18, 17, 18, 17, 50, 51, 17, 17, 18, 48, 48, 80, 80, 80, 81, 17, 17, 17, 17, 17, 54, 55, 18, 18, 17, 48, 48, 83, 83, 83, 84, 18, 17, 17, 17, 17, 17, 57, 17, 18, 18, 48, 48, 17, 17, 17, 18, 18, 50, 51, 17, 17, 17, 17, 18, 17, 17, 48, 48, 17, 17, 17, 17, 17, 54, 55, 17, 17, 17, 17, 17, 17, 17, 49, 48, 18, 17, 17, 17, 18, 17, 57, 17, 17, 17, 17, 17, 17, 17, 17, 48, 17, 17, 18, 17, 17, 17, 17, 17, 22, 23, 23, 24, 17, 17, 17, 49, 17, 50, 51, 46, 18, 18, 17, 17, 18, 37, 18, 17, 18, 17, 18, 17, 50, 52, 53, 51, 37, 17, 47, 47, 17, 18, 17, 18, 18, 37, 18, 18, 54, 55, 56, 55, 17, 49, 48, 49, 18, 17, 18, 37, 18, 18, 46, 37, 17, 57, 18, 57, 18, 17, 49, 17, 17, 18, 17, 18, 17, 37, 18, 37, 35, 35, 35, 36, 17, 17, 17, 17, 17, 17, 17, 17, 18, 17, 17, 18, 38, 38, 38, 39, 17, 18, 17, 17, 18, 17, 18, 18, 17, 82, 74, 74, 38, 38, 38, 39, 17, 17, 37, 18, 37, 18, 17, 17, 85, 76, 76, 76, 40, 40, 40, 41, 18, 17, 18, 46, 37, 18, 17, 17, 86, 78, 78, 78, 17, 17, 17, 18, 17, 50, 51, 37, 18, 17, 17, 18, 87, 88, 88, 88, 17, 18, 17, 17, 18, 54, 55, 18, 17, 18, 18, 37, 89, 90, 90, 90, 18, 17, 18, 18, 37, 18, 57, 17, 18, 17, 18, 18, 37, 37, 18, 17, 47, 18, 17, 37, 46, 37, 18, 18, 17, 50, 51, 37, 18, 17, 18, 37, 48, 47, 17, 18, 18, 37, 17, 18, 50, 52, 53, 51, 17, 18, 17, 18, 48, 48, 18, 17, 37, 18, 17, 17, 54, 55, 56, 55, 17, 17, 18, 17, 49, 49, 37, 18, 17, 17, 18, 17, 17, 57, 18, 57, 17, 18, 17, 17, 25, 91, 27, 17, 17, 50, 51, 17, 18, 17, 18, 37, 18, 18, 47, 47, 28, 31, 30, 17, 18, 54, 55, 17, 17, 18, 17, 18, 17, 47, 48, 48, 34, 32, 33, 17, 17, 17, 57, 17, 17, 17, 17, 17, 49, 49, 48, 49, 37, 18, 18, 37, 17, 18, 17, 17, 18, 17, 18, 18, 17, 17, 49, 17, 18, 17, 37, 17, 17, 17, 37, 18, 37, 18, 17, 17, 25, 91, 91, 27, 17, 17, 17, 18, 18, 17, 18, 46, 37, 18, 17, 17, 28, 31, 31, 30, 17, 17, 17, 18, 17, 37, 18, 37, 18, 17, 17, 18, 34, 32, 32, 33, 17, 18, 17, 17, 18, 18, 17, 18, 17, 18, 18, 37, 46, 18, 17, 18, 17, 50, 51, 46, 18, 18, 17, 17, 18, 37, 18, 17, 18, 17, 18, 17, 18, 54, 55, 18, 37, 17, 17, 17, 17, 18, 17, 18, 18, 37, 18, 18, 18, 17, 57, 18, 37, 18, 17, 17, 18, 50, 51, 18, 37, 37, 18, 17, 17, 18, 17, 37, 46, 37, 18, 18, 50, 52, 53, 51, 18, 17, 18, 37, 17, 17, 17, 18, 18, 37, 17, 18, 54, 55, 56, 55, 17, 18, 17, 18, 37, 17, 18, 17, 37, 18, 17, 17, 17, 57, 17, 57, 17, 17, 18, 17, 17, 18, 37, 18, 17, 17, 18, 17, 17, 17, 18, 18, 17, 18, 17, 17], + "height":180, + "name":"ShoeBox Tile Grab", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":16, + "x":0, + "y":0 + }], + "orientation":"orthogonal", + "properties": + { + + }, + "tileheight":32, + "tilesets":[ + { + "firstgid":1, + "image":"CommandoMap1-1BG_bank.png", + "imageheight":608, + "imagewidth":160, + "margin":0, + "name":"CommandoMap1-1BG_bank.png", + "properties": + { + + }, + "spacing":0, + "tileheight":32, + "tilewidth":32 + }], + "tilewidth":32, + "version":1, + "width":16 +} \ No newline at end of file diff --git a/examples/assets/maps/commando.png b/examples/assets/maps/commando.png new file mode 100644 index 00000000..bd2ebe65 Binary files /dev/null and b/examples/assets/maps/commando.png differ diff --git a/examples/assets/maps/newtest.json b/examples/assets/maps/newtest.json index 824ff849..271f24dd 100644 --- a/examples/assets/maps/newtest.json +++ b/examples/assets/maps/newtest.json @@ -1,7 +1,7 @@ { "height":18, "layers":[ { - "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1,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 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "height":18, "name":"Tile Layer 1", "opacity":1, diff --git a/examples/assets/maps/newtest.tmx b/examples/assets/maps/newtest.tmx index 472bfe21..83027e9c 100644 --- a/examples/assets/maps/newtest.tmx +++ b/examples/assets/maps/newtest.tmx @@ -16,7 +16,7 @@ - AQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAA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AAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAA diff --git a/examples/wip/commando.js b/examples/wip/commando.js new file mode 100644 index 00000000..fd275b9e --- /dev/null +++ b/examples/wip/commando.js @@ -0,0 +1,140 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('map', 'assets/maps/commando.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/commando.png', 32, 32); + game.load.image('phaser', 'assets/sprites/arrow.png'); + +} + +var cursors; +var map; +var layer; +var sprite; + +function create() { + + map = game.add.tilemap('map'); + + // map.setCollisionByIndexRange(80, 97); // mario + // map.setCollisionByIndexRange(14, 18); // mario + // map.setCollisionByIndex(1); // newtest + + layer = game.add.tilemapLayer(0, 0, 800, 600, 'tiles', map, 0); + // layer.debug = true; + + layer.resizeWorld(); + + sprite = game.add.sprite(260, 100, 'phaser'); + sprite.anchor.setTo(0.5, 0.5); + + sprite.body.setSize(16, 16, 8, 8); + + // We'll set a lower max angular velocity here to keep it from going totally nuts + sprite.body.maxAngular = 500; + + // Apply a drag otherwise the sprite will just spin and never slow down + sprite.body.angularDrag = 50; + + game.camera.follow(sprite); + + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + +/* + if (cursors.left.isDown) + { + game.camera.x -= 1; + } + else if (cursors.right.isDown) + { + game.camera.x += 1; + } + + if (cursors.up.isDown) + { + layer.scrollY -= 4; + } + else if (cursors.down.isDown) + { + layer.scrollY += 4; + } +*/ + game.physics.collide(sprite, layer); + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + sprite.body.angularVelocity = 0; + + // sprite.body.acceleration.x = 0; + // sprite.body.angularAcceleration = 0; + + if (cursors.left.isDown) + { + // sprite.body.acceleration.x = -200; + sprite.body.angularVelocity = -300; + // sprite.body.angularAcceleration -= 200; + } + else if (cursors.right.isDown) + { + // sprite.body.acceleration.x = 200; + sprite.body.angularVelocity = 300; + // sprite.body.angularAcceleration += 200; + } + + if (cursors.up.isDown) + { + game.physics.velocityFromAngle(sprite.angle, 300, sprite.body.velocity); + } + else + { + // game.physics.velocityFromAngle(sprite.angle, sprite.body.velocity, sprite.body.velocity); + } + + /* + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + + sprite.angle = sprite.angle + 1; + + if (cursors.up.isDown) + { + sprite.body.velocity.y = -900; + } + else if (cursors.down.isDown) + { + sprite.body.velocity.y = 900; + } + + if (cursors.left.isDown) + { + sprite.body.velocity.x = -900; + // sprite.scale.x = -1; + } + else if (cursors.right.isDown) + { + sprite.body.velocity.x = 900; + // sprite.scale.x = 1; + } + */ + + +} + +function render() { + + // game.debug.renderSpriteBody(sprite); + // game.debug.renderSpriteBounds(sprite); + + // game.debug.renderText(sprite.x, 32, 32); + // game.debug.renderText(sprite.y, 32, 48); + + // game.debug.renderText(layer.scrollX, 32, 32); + // game.debug.renderText(layer.scrollY, 32, 48); + +} \ No newline at end of file diff --git a/examples/wip/tilemap.js b/examples/wip/tilemap.js index 4df1e197..fa6a0844 100644 --- a/examples/wip/tilemap.js +++ b/examples/wip/tilemap.js @@ -3,11 +3,11 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: function preload() { - // game.load.tilemap('map', 'assets/maps/mario1.json', null, Phaser.Tilemap.TILED_JSON); - // game.load.tileset('marioTiles', 'assets/maps/mario1.png', 16, 16); + game.load.tilemap('map', 'assets/maps/mario1.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/mario1.png', 16, 16); - game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON); - game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32); + // game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON); + // game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32); // game.load.image('phaser', 'assets/sprites/phaser-ship.png'); // game.load.image('phaser', 'assets/sprites/mushroom2.png'); // game.load.image('phaser', 'assets/sprites/wabbit.png'); @@ -28,11 +28,19 @@ function create() { map = game.add.tilemap('map'); - // map.setCollisionByIndexRange(80, 97); // mario - map.setCollisionByIndex(1); + map.setCollisionByIndexRange(80, 97); // mario + map.setCollisionByIndexRange(14, 18); // mario + + + + // map.setCollisionByIndex(1); // newtest + + // Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) { - layer = game.add.tilemapLayer(0, 0, 800, 600, null, map, 0); + // Need to get the x,y values working (adjust cameraOffset values) + layer = game.add.tilemapLayer(0, 0, 800, 600, 'tiles', map, 0); + layer.debug = true; // layer2 = game.add.tilemapLayer(0, 0, 400, 600, null, map, 0); // layer.cameraOffset.x = 400; @@ -75,8 +83,8 @@ function create() { function getIt() { - console.log('cam', game.camera.bounds); - console.log('w', game.world.bounds); + // console.log('cam', game.camera.bounds); + // console.log('w', game.world.bounds); // console.log(layer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true, true)); } diff --git a/src/gameobjects/GameObjectFactory.js b/src/gameobjects/GameObjectFactory.js index f3cf7925..23b46980 100644 --- a/src/gameobjects/GameObjectFactory.js +++ b/src/gameobjects/GameObjectFactory.js @@ -262,13 +262,16 @@ Phaser.GameObjectFactory.prototype = { }, /** - * Creates a new Tilemap Layer object. + * Creates a new Tilemap Layer object. By default TilemapLayers are fixed to the camera. * * @method Phaser.GameObjectFactory#tilemapLayer * @param {number} x - X position of the new tilemapLayer. * @param {number} y - Y position of the new tilemapLayer. * @param {number} width - the width of the tilemapLayer. * @param {number} height - the height of the tilemapLayer. + * @param {Phaser.Tileset|string} tileset - The tile set used for rendering. + * @param {Phaser.Tilemap} tilemap - The tilemap to which this layer belongs. + * @param {number|string} [layer=0] - The layer within the tilemap this TilemapLayer represents. * @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group. * @return {Phaser.TilemapLayer} The newly created tilemaplayer object. */ diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index f85a7006..a6239a3f 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -98,7 +98,7 @@ Phaser.Text = function (game, x, y, text, style) { this.fixedToCamera = false; /** - * @property {Phaser.Point} cameraOffset - If this Sprite is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered. + * @property {Phaser.Point} cameraOffset - If this object is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered. */ this.cameraOffset = new Phaser.Point(); diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index 7c21b646..b5f7827f 100644 --- a/src/physics/arcade/ArcadePhysics.js +++ b/src/physics/arcade/ArcadePhysics.js @@ -855,8 +855,8 @@ Phaser.Physics.Arcade.prototype = { body2.x += this._overlap; body2.velocity.x = this._velocity1 - this._velocity2 * body2.bounce.x; } - body1.updateHulls(); - body2.updateHulls(); + // body1.updateHulls(); + // body2.updateHulls(); return true; } @@ -977,8 +977,8 @@ Phaser.Physics.Arcade.prototype = { body2.x += body1.x - body1.preX; } } - body1.updateHulls(); - body2.updateHulls(); + // body1.updateHulls(); + // body2.updateHulls(); return true; } @@ -1024,7 +1024,7 @@ Phaser.Physics.Arcade.prototype = { if (localOverlapX >= body.deltaX()) { - console.log('m left overlapX', localOverlapX, body.deltaX()); + // console.log('m left overlapX', localOverlapX, body.deltaX()); // use touching instead of blocked? body.blocked.left = true; body.touching.left = true; @@ -1039,7 +1039,7 @@ Phaser.Physics.Arcade.prototype = { // Distance check if (localOverlapX <= body.deltaX()) { - console.log('m right overlapX', localOverlapX, body.deltaX()); + // console.log('m right overlapX', localOverlapX, body.deltaX()); body.blocked.right = true; body.touching.right = true; body.touching.none = false; @@ -1054,7 +1054,7 @@ Phaser.Physics.Arcade.prototype = { // Distance check if (localOverlapY >= body.deltaY()) { - console.log('m up overlapY', localOverlapY, body.deltaY()); + // console.log('m up overlapY', localOverlapY, body.deltaY()); body.blocked.up = true; body.touching.up = true; body.touching.none = false; @@ -1067,7 +1067,7 @@ Phaser.Physics.Arcade.prototype = { if (localOverlapY <= body.deltaY()) { - console.log('m down overlapY', localOverlapY, body.deltaY()); + // console.log('m down overlapY', localOverlapY, body.deltaY()); body.blocked.down = true; body.touching.down = true; body.touching.none = false; @@ -1163,7 +1163,7 @@ Phaser.Physics.Arcade.prototype = { if (body.overlapX >= body.deltaX()) { - console.log('left overlapX', body.overlapX, body.deltaX()); + // console.log('left overlapX', body.overlapX, body.deltaX()); // use touching instead of blocked? body.blocked.left = true; body.touching.left = true; @@ -1178,7 +1178,7 @@ Phaser.Physics.Arcade.prototype = { // Distance check if (body.overlapX <= body.deltaX()) { - console.log('right overlapX', body.overlapX, body.deltaX()); + // console.log('right overlapX', body.overlapX, body.deltaX()); body.blocked.right = true; body.touching.right = true; body.touching.none = false; @@ -1193,7 +1193,7 @@ Phaser.Physics.Arcade.prototype = { // Distance check if (body.overlapY >= body.deltaY()) { - console.log('up overlapY', body.overlapY, body.deltaY()); + // console.log('up overlapY', body.overlapY, body.deltaY()); body.blocked.up = true; body.touching.up = true; body.touching.none = false; @@ -1206,7 +1206,7 @@ Phaser.Physics.Arcade.prototype = { if (body.overlapY <= body.deltaY()) { - console.log('down overlapY', body.overlapY, body.deltaY()); + // console.log('down overlapY', body.overlapY, body.deltaY()); body.blocked.down = true; body.touching.down = true; body.touching.none = false; diff --git a/src/system/Device.js b/src/system/Device.js index 12743f9e..f733b543 100644 --- a/src/system/Device.js +++ b/src/system/Device.js @@ -224,6 +224,12 @@ Phaser.Device = function () { */ this.webApp = false; + /** + * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) + * @default + */ + this.silk = false; + // Audio /** @@ -328,21 +334,33 @@ Phaser.Device.prototype = { var ua = navigator.userAgent; - if (/Android/.test(ua)) { + if (/Android/.test(ua)) + { this.android = true; - } else if (/CrOS/.test(ua)) { + } + else if (/CrOS/.test(ua)) + { this.chromeOS = true; - } else if (/iP[ao]d|iPhone/i.test(ua)) { + } + else if (/iP[ao]d|iPhone/i.test(ua)) + { this.iOS = true; - } else if (/Linux/.test(ua)) { + } + else if (/Linux/.test(ua)) + { this.linux = true; - } else if (/Mac OS/.test(ua)) { + } + else if (/Mac OS/.test(ua)) + { this.macOS = true; - } else if (/Windows/.test(ua)) { + } + else if (/Windows/.test(ua)) + { this.windows = true; } - if (this.windows || this.macOS || this.linux) { + if (this.windows || this.macOS || (this.linux && this.silk === false)) + { this.desktop = true; } @@ -378,11 +396,13 @@ Phaser.Device.prototype = { this.worker = !!window['Worker']; - if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 1)) { + if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 1)) + { this.touch = true; } - if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) { + if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled) + { this.mspointer = true; } @@ -399,37 +419,62 @@ Phaser.Device.prototype = { var ua = navigator.userAgent; - if (/Arora/.test(ua)) { + if (/Arora/.test(ua)) + { this.arora = true; - } else if (/Chrome/.test(ua)) { + } + else if (/Chrome/.test(ua)) + { this.chrome = true; - } else if (/Epiphany/.test(ua)) { + } + else if (/Epiphany/.test(ua)) + { this.epiphany = true; - } else if (/Firefox/.test(ua)) { + } + else if (/Firefox/.test(ua)) + { this.firefox = true; - } else if (/Mobile Safari/.test(ua)) { + } + else if (/Mobile Safari/.test(ua)) + { this.mobileSafari = true; - } else if (/MSIE (\d+\.\d+);/.test(ua)) { + } + else if (/MSIE (\d+\.\d+);/.test(ua)) + { this.ie = true; this.ieVersion = parseInt(RegExp.$1, 10); - } else if (/Midori/.test(ua)) { + } + else if (/Midori/.test(ua)) + { this.midori = true; - } else if (/Opera/.test(ua)) { + } + else if (/Opera/.test(ua)) + { this.opera = true; - } else if (/Safari/.test(ua)) { + } + else if (/Safari/.test(ua)) + { this.safari = true; - } else if (/Trident\/(\d+\.\d+);/.test(ua)) { + } + else if (/Silk/.test(ua)) + { + this.silk = true; + } + else if (/Trident\/(\d+\.\d+);/.test(ua)) + { this.ie = true; this.trident = true; this.tridentVersion = parseInt(RegExp.$1, 10); } // WebApp mode in iOS - if (navigator['standalone']) { + if (navigator['standalone']) + { this.webApp = true; } - if (navigator['isCocoonJS']) { + if (navigator['isCocoonJS']) + { this.cocoonJS = true; } @@ -534,8 +579,10 @@ Phaser.Device.prototype = { // Add it to the body to get the computed style. document.body.insertBefore(el, null); - for (var t in transforms) { - if (el.style[t] !== undefined) { + for (var t in transforms) + { + if (el.style[t] !== undefined) + { el.style[t] = "translate3d(1px,1px,1px)"; has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); } diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index 1078fe14..080e43bc 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -122,14 +122,38 @@ Phaser.Tilemap.prototype = { }, - createTilemapLayer: function (x, y, renderWidth, renderHeight, tileset, layer) { + /** + * Sets collision values on a range of tiles in the set. + * + * @method Phaser.Tileset#createTilemapLayer + * @param {number} x - X position of the new tilemapLayer. + * @param {number} y - Y position of the new tilemapLayer. + * @param {number} width - the width of the tilemapLayer. + * @param {number} height - the height of the tilemapLayer. + * @param {Phaser.Tileset|string} tileset - The tile set used for rendering. + * @param {number|string} [layer=0] - The layer within the tilemap this TilemapLayer represents. + * @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group. + */ + createTilemapLayer: function (x, y, renderWidth, renderHeight, tileset, layer, group) { - return this.game.world.add(new Phaser.TilemapLayer(this.game, x, y, renderWidth, renderHeight, tileset, this, layer)); + if (typeof group === 'undefined') { group = this.game.world; } + + return group.add(new Phaser.TilemapLayer(this.game, x, y, renderWidth, renderHeight, tileset, this, layer)); }, + /** + * Sets collision values on a range of tiles in the set. + * + * @method Phaser.Tileset#setCollisionByIndexRange + * @param {number} start - The first index of the tile on the layer. + * @param {number} stop - The last index of the tile on the layer. + * @param {number} layer - The layer to operate on. + */ setCollisionByIndexRange: function (start, stop, layer) { + if (typeof layer === "undefined") { layer = this.currentLayer; } + if (start > stop) { return; @@ -137,21 +161,26 @@ Phaser.Tilemap.prototype = { for (var i = start; i <= stop; i++) { - this.setCollisionByIndex(i, layer); + this.setCollisionByIndex(i, layer, false); } + // Now re-calculate interesting faces + this.calculateFaces(layer); + }, /** * Sets collision values on a tile in the set. * - * @method Phaser.Tileset#setCollision + * @method Phaser.Tileset#setCollisionByIndex * @param {number} index - The index of the tile on the layer. * @param {number} layer - The layer to operate on. + * @param {boolean} [recalculate=true] - Recalculates the tile faces after the update. */ - setCollisionByIndex: function (index, layer) { + setCollisionByIndex: function (index, layer, recalculate) { if (typeof layer === "undefined") { layer = this.currentLayer; } + if (typeof recalculate === "undefined") { recalculate = true; } for (var y = 0; y < this.layers[layer].height ; y++) { @@ -170,14 +199,20 @@ Phaser.Tilemap.prototype = { } } - // Sets all tiles matching the given index to collide on the given faces - // Recalculates the collision map - - // Now re-calculate interesting faces - this.calculateFaces(layer); + if (recalculate) + { + // Now re-calculate interesting faces + this.calculateFaces(layer); + } }, + /** + * Internal function. + * + * @method Phaser.Tileset#calculateFaces + * @param {number} layer - The layer to operate on. + */ calculateFaces: function (layer) { var above = null; @@ -185,9 +220,9 @@ Phaser.Tilemap.prototype = { var left = null; var right = null; - // console.log(this.layers[layer].width, 'x', this.layers[layer].height); + // console.log(this.layers[layer].width, 'x', this.layers[layer].height); - for (var y = 0; y < this.layers[layer].height ; y++) + for (var y = 0; y < this.layers[layer].height; y++) { for (var x = 0; x < this.layers[layer].width; x++) { @@ -229,6 +264,14 @@ Phaser.Tilemap.prototype = { }, + /** + * Internal function. + * + * @method Phaser.Tileset#getTileAbove + * @param {number} layer - The layer to operate on. + * @param {number} x - X. + * @param {number} y - Y. + */ getTileAbove: function (layer, x, y) { if (y > 0) @@ -240,6 +283,14 @@ Phaser.Tilemap.prototype = { }, + /** + * Internal function. + * + * @method Phaser.Tileset#getTileBelow + * @param {number} layer - The layer to operate on. + * @param {number} x - X. + * @param {number} y - Y. + */ getTileBelow: function (layer, x, y) { if (y < this.layers[layer].height - 1) @@ -251,6 +302,14 @@ Phaser.Tilemap.prototype = { }, + /** + * Internal function. + * + * @method Phaser.Tileset#getTileLeft + * @param {number} layer - The layer to operate on. + * @param {number} x - X. + * @param {number} y - Y. + */ getTileLeft: function (layer, x, y) { if (x > 0) @@ -262,6 +321,14 @@ Phaser.Tilemap.prototype = { }, + /** + * Internal function. + * + * @method Phaser.Tileset#getTileRight + * @param {number} layer - The layer to operate on. + * @param {number} x - X. + * @param {number} y - Y. + */ getTileRight: function (layer, x, y) { if (x < this.layers[layer].width - 1) @@ -273,35 +340,6 @@ Phaser.Tilemap.prototype = { }, - /** - * Internal function that calculates the tile indexes for the map data. - * - * @method Phaser.Tilemap#calculateIndexes - */ - calculateIndexes: function () { - - /* - for (var layer = 0; layer < this.layers.length; layer++) - { - this.layers[layer].indexes = []; - - for (var y = 0; y < this.layers[layer].height ; y++) - { - for (var x = 0; x < this.layers[layer].width; x++) - { - var idx = this.layers[layer].data[y][x]; - - if (this.layers[layer].indexes.indexOf(idx) === -1) - { - this.layers[layer].indexes.push(idx); - } - } - } - } - */ - - }, - /** * Sets the current layer to the given index. * diff --git a/src/tilemap/TilemapLayer.js b/src/tilemap/TilemapLayer.js index 28da86e7..041f9cc2 100644 --- a/src/tilemap/TilemapLayer.js +++ b/src/tilemap/TilemapLayer.js @@ -12,8 +12,8 @@ * @param {Phaser.Game} game - Game reference to the currently running game. * @param {number} x - The x coordinate of this layer. * @param {number} y - The y coordinate of this layer. -* @param {number} renderWidth - Width of the layer. -* @param {number} renderHeight - Height of the layer. +* @param {number} renderWidth - Width of the renderable area of the layer. +* @param {number} renderHeight - Height of the renderable area of the layer. * @param {Phaser.Tileset|string} tileset - The tile set used for rendering. * @param {Phaser.Tilemap} tilemap - The tilemap to which this layer belongs. * @param {number|string} [layer=0] - The layer within the tilemap this TilemapLayer represents. @@ -26,7 +26,7 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, this.game = game; /** - * @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws. + * @property {HTMLCanvasElement} canvas - The canvas to which this TilemapLayer draws. */ this.canvas = Phaser.Canvas.create(renderWidth, renderHeight); @@ -59,12 +59,17 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, this.type = Phaser.TILEMAPLAYER; /** - * A layer that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera. - * @property {boolean} fixedToCamera - Fixes this layer to the Camera. + * An object that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera. + * @property {boolean} fixedToCamera - Fixes this object to the Camera. * @default */ this.fixedToCamera = true; + /** + * @property {Phaser.Point} cameraOffset - If this object is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered. + */ + this.cameraOffset = new Phaser.Point(x, y); + /** * @property {Phaser.Tileset} tileset - The tile set used for rendering. */ @@ -90,6 +95,12 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, */ this.tileSpacing = 0; + /** + * @property {boolean} debug - If set to true the collideable tile edges path will be rendered. + * @default + */ + this.debug = false; + /** * @property {number} widthInPixels - Do NOT recommend changing after the map is loaded! * @readonly @@ -505,17 +516,108 @@ Phaser.TilemapLayer.prototype.getTileXY = function (x, y, point) { } /** -* Get the tiles within the given area. +* Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles. * @method Phaser.TilemapLayer#getTiles * @memberof Phaser.TilemapLayer -* @param {number} x - X position of the top left of the area to copy (given in tiles, not pixels) -* @param {number} y - Y position of the top left of the area to copy (given in tiles, not pixels) -* @param {number} width - The width of the area to copy (given in tiles, not pixels) -* @param {number} height - The height of the area to copy (given in tiles, not pixels) +* @param {number} x - X position of the top left corner. +* @param {number} y - Y position of the top left corner. +* @param {number} width - Width of the area to get. +* @param {number} height - Height of the area to get. * @param {boolean} [collides=false] - If true only return tiles that collide on one or more faces. * @return {array} Array with tiles informations (each contains x, y, and the tile). */ -Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides, debug) { +Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides) { + + if (this.tilemap === null) + { + return; + } + + // Should we only get tiles that have at least one of their collision flags set? (true = yes, false = no just get them all) + if (typeof collides === 'undefined') { collides = false; } + + // adjust the x,y coordinates for scrollFactor + x = this._fixX(x); + y = this._fixY(y); + + if (width > this.widthInPixels) + { + width = this.widthInPixels; + } + + if (height > this.heightInPixels) + { + height = this.heightInPixels; + } + + var tileWidth = this.tileWidth * this.scale.x; + var tileHeight = this.tileHeight * this.scale.y; + + // Convert the pixel values into tile coordinates + this._tx = this.game.math.snapToFloor(x, tileWidth) / tileWidth; + this._ty = this.game.math.snapToFloor(y, tileHeight) / tileHeight; + this._tw = (this.game.math.snapToCeil(width, tileWidth) + tileWidth) / tileWidth; + this._th = (this.game.math.snapToCeil(height, tileHeight) + tileHeight) / tileHeight; + + // This should apply the layer x/y here + this._results.length = 0; + + // var _index = 0; + var _tile = null; + // var sx = 0; + // var sy = 0; + + for (var wy = this._ty; wy < this._ty + this._th; wy++) + { + for (var wx = this._tx; wx < this._tx + this._tw; wx++) + { + if (this.layer.data[wy] && this.layer.data[wy][wx]) + { + _tile = this.layer.data[wy][wx]; + + if (_tile) + { + // sx = this.tileWidth * this.scale.x; + // sy = this.tileHeight * this.scale.y; + + if (collides === false || (collides && _tile.collides)) + { + // convert tile coordinates back to camera space for return + var _wx = this._unfixX(wx * tileWidth) / this.tileWidth; + var _wy = this._unfixY(wy * tileHeight) / this.tileHeight; + + this._results.push({ + x: _wx * tileWidth, + y: _wy * tileHeight, + right: (_wx * tileWidth) + tileWidth, + bottom: (_wy * tileHeight) + tileHeight, + tile: _tile + }); + } + + } + + } + } + } + + return this._results; + +} + +/** +* Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles. +* This function also draws to the context all of the debug areas. +* @method Phaser.TilemapLayer#debugGetTiles +* @memberof Phaser.TilemapLayer +* @param {number} x - X position of the top left corner. +* @param {number} y - Y position of the top left corner. +* @param {number} width - Width of the area to get. +* @param {number} height - Height of the area to get. +* @param {boolean} [collides=false] - If true only return tiles that collide on one or more faces. +* @return {array} Array with tiles informations (each contains x, y, and the tile). +*/ +Phaser.TilemapLayer.prototype.debugGetTiles = function (x, y, width, height, collides) { if (this.tilemap === null) { @@ -616,7 +718,6 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides this.context.fillRect(_tile.x * this.tileWidth, _tile.y * this.tileHeight, this.tileWidth, this.tileHeight); } - // this.context.strokeRect(_tile.x * this.tileWidth, _tile.y * this.tileHeight, this.tileWidth, this.tileHeight); // convert tile coordinates back to camera space for return @@ -674,7 +775,7 @@ Phaser.TilemapLayer.prototype.updateMax = function () { this.dirty = true; - console.log('updateMax', this._maxX, this._maxY, 'px', this.widthInPixels, this.heightInPixels, 'rwh', this.width, this.height); + // console.log('updateMax', this._maxX, this._maxY, 'px', this.widthInPixels, this.heightInPixels, 'rwh', this.width, this.height); } @@ -711,8 +812,12 @@ Phaser.TilemapLayer.prototype.render = function () { this._ty = this._dy; this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.context.fillStyle = 'rgba(0,255,0,0.3)'; - this.context.strokeStyle = 'rgba(0,255,0,0.9)'; + + if (this.debug) + { + this.context.fillStyle = 'rgba(0,255,0,0.3)'; + this.context.strokeStyle = 'rgba(0,255,0,0.9)'; + } for (var y = this._startY, lenY = this._startY + this._maxY; y < lenY; y++) { @@ -722,59 +827,58 @@ Phaser.TilemapLayer.prototype.render = function () { { var tile = this._column[x]; - // var tile = this.tileset.tiles[this._column[x] - 1]; - - // if (tile && this.tileset) - // { - // this.context.drawImage( - // this.tileset.image, - // tile.x, - // tile.y, - // this.tileWidth, - // this.tileHeight, - // Math.floor(this._tx), - // Math.floor(this._ty), - // this.tileWidth, - // this.tileHeight - // ); - // } - - if (tile && (tile.faceTop || tile.faceBottom || tile.faceLeft || tile.faceRight)) + if (tile && this.tileset) { - this._tx = Math.floor(this._tx); + this.context.drawImage( + this.tileset.image, + this.tileset.getTileX(tile.index), + this.tileset.getTileY(tile.index), + this.tileWidth, + this.tileHeight, + Math.floor(this._tx), + Math.floor(this._ty), + this.tileWidth, + this.tileHeight + ); + } - this.context.fillRect(this._tx, this._ty, this.tileWidth, this.tileHeight); - - this.context.beginPath(); - - if (tile.faceTop) + if (this.debug) + { + if (tile && (tile.faceTop || tile.faceBottom || tile.faceLeft || tile.faceRight)) { - this.context.moveTo(this._tx, this._ty); - this.context.lineTo(this._tx + this.tileWidth, this._ty); + this._tx = Math.floor(this._tx); + + // this.context.fillRect(this._tx, this._ty, this.tileWidth, this.tileHeight); + + this.context.beginPath(); + + if (tile.faceTop) + { + this.context.moveTo(this._tx, this._ty); + this.context.lineTo(this._tx + this.tileWidth, this._ty); + } + + if (tile.faceBottom) + { + this.context.moveTo(this._tx, this._ty + this.tileHeight); + this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight); + } + + if (tile.faceLeft) + { + this.context.moveTo(this._tx, this._ty); + this.context.lineTo(this._tx, this._ty + this.tileHeight); + } + + if (tile.faceRight) + { + this.context.moveTo(this._tx + this.tileWidth, this._ty); + this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight); + } + + this.context.stroke(); + // this.context.strokeRect(this._tx, this._ty, this.tileWidth, this.tileHeight); } - - if (tile.faceBottom) - { - this.context.moveTo(this._tx, this._ty + this.tileHeight); - this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight); - } - - if (tile.faceLeft) - { - this.context.moveTo(this._tx, this._ty); - this.context.lineTo(this._tx, this._ty + this.tileHeight); - } - - if (tile.faceRight) - { - this.context.moveTo(this._tx + this.tileWidth, this._ty); - this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight); - } - - // this.context.closePath(); - this.context.stroke(); - - // this.context.strokeRect(this._tx, this._ty, this.tileWidth, this.tileHeight); } this._tx += this.tileWidth; diff --git a/src/tilemap/TilemapParser.js b/src/tilemap/TilemapParser.js index 4e19aefd..c989b3d2 100644 --- a/src/tilemap/TilemapParser.js +++ b/src/tilemap/TilemapParser.js @@ -63,26 +63,11 @@ Phaser.TilemapParser = { return null; } - // Let's create some tiles - var x = tileMargin; - var y = tileMargin; + //Phaser.Tileset = function (image, key, total, tileWidth, tileHeight, firstgid, tileMargin, tileSpacing) { + return new Phaser.Tileset(img, key, total, tileWidth, tileHeight, 1, tileMargin, tileSpacing); - var tileset = new Phaser.Tileset(img, key, tileWidth, tileHeight, tileMargin, tileSpacing); - - for (var i = 0; i < total; i++) - { - tileset.addTile(new Phaser.Tile(tileset, i, x, y, tileWidth, tileHeight)); - - x += tileWidth + tileSpacing; - - if (x === width) - { - x = tileMargin; - y += tileHeight + tileSpacing; - } - } - - return tileset; + // tileset.build(); + // return tileset; }, diff --git a/src/tilemap/Tileset.js b/src/tilemap/Tileset.js index 1f25a15d..fa59c1b9 100644 --- a/src/tilemap/Tileset.js +++ b/src/tilemap/Tileset.js @@ -11,13 +11,16 @@ * @constructor * @param {Image} image - The Image object from the Cache. * @param {string} key - The key of the tileset in the cache. +* @param {number} total - The total number of tiles in the tilesheet. * @param {number} tileWidth - The width of the tile in pixels. * @param {number} tileHeight - The height of the tile in pixels. -* @param {number} [tileMargin] - The margin around the tiles in the sheet. -* @param {number} [tileSpacing] - The spacing between the tiles in the sheet. +* @param {number} [firstgid=0] - The first index number (as specified by Tiled, otherwise set to zero) +* @param {number} [tileMargin=0] - The margin around the tiles in the sheet. +* @param {number} [tileSpacing=0] - The spacing between the tiles in the sheet. */ -Phaser.Tileset = function (image, key, tileWidth, tileHeight, tileMargin, tileSpacing) { +Phaser.Tileset = function (image, key, total, tileWidth, tileHeight, firstgid, tileMargin, tileSpacing) { + if (typeof firstgid === "undefined") { firstgid = 0; } if (typeof tileMargin === "undefined") { tileMargin = 0; } if (typeof tileSpacing === "undefined") { tileSpacing = 0; } @@ -31,6 +34,16 @@ Phaser.Tileset = function (image, key, tileWidth, tileHeight, tileMargin, tileSp */ this.image = image; + /** + * @property {number} total - The total number of tiles in the tilesheet. + */ + this.total = total; + + /** + * @property {number} firstgid - The total number of tiles in the tilesheet. + */ + this.firstgid = firstgid; + /** * @property {number} tileWidth - The width of a tile in pixels. */ @@ -44,33 +57,49 @@ Phaser.Tileset = function (image, key, tileWidth, tileHeight, tileMargin, tileSp /** * @property {number} tileMargin - The margin around the tiles in the sheet. */ - this.margin = tileMargin; + this.tileMargin = tileMargin; /** * @property {number} tileSpacing - The margin around the tiles in the sheet. */ - this.spacing = tileSpacing; + this.tileSpacing = tileSpacing; /** - * @property {array} tiles - An array of the tile collision data. + * @property {array} tiles - An array of the tile data. */ this.tiles = []; + this.build(); + } Phaser.Tileset.prototype = { /** - * Adds a Tile into this set. + * Builds the tile data * - * @method Phaser.Tileset#addTile - * @param {Phaser.Tile} tile - The tile to add to this set. + * @method Phaser.Tileset#build */ - addTile: function (tile) { + build: function () { - this.tiles.push(tile); + var x = this.tileMargin; + var y = this.tileMargin; - return tile; + for (var i = this.firstgid; i < this.firstgid + this.total; i++) + { + // Can add extra properties here as needed + this.tiles[i] = [x, y]; + + x += this.tileWidth + this.tileSpacing; + + if (x === this.image.width) + { + x = this.tileMargin; + y += this.tileHeight + this.tileSpacing; + } + } + + // console.table(this.tiles); }, @@ -79,16 +108,37 @@ Phaser.Tileset.prototype = { * * @method Phaser.Tileset#getTile * @param {number} index - The index of the tile within the set. - * @return {Phaser.Tile} The tile. + * @return {object} The tile object. */ getTile: function (index) { - if (this.tiles[index]) - { - return this.tiles[index]; - } + return this.tiles[index]; - return null; + }, + + /** + * Gets a Tile from this set. + * + * @method Phaser.Tileset#getTileX + * @param {number} index - The index of the tile within the set. + * @return {object} The tile object. + */ + getTileX: function (index) { + + return this.tiles[index][0]; + + }, + + /** + * Gets a Tile from this set. + * + * @method Phaser.Tileset#getTileY + * @param {number} index - The index of the tile within the set. + * @return {object} The tile object. + */ + getTileY: function (index) { + + return this.tiles[index][1]; }, @@ -112,7 +162,6 @@ Phaser.Tileset.prototype = { * @method Phaser.Tileset#canCollide * @param {number} index - The index of the tile within the set. * @return {boolean} True or false depending on the tile collision or null if no tile was found at the given index. - */ canCollide: function (index) { if (this.tiles[index]) @@ -123,6 +172,7 @@ Phaser.Tileset.prototype = { return null; }, + */ /** * Checks if the tile at the given index exists. @@ -147,7 +197,6 @@ Phaser.Tileset.prototype = { * @param {boolean} right - Should the tile collide on the right? * @param {boolean} up - Should the tile collide on the top? * @param {boolean} down - Should the tile collide on the bottom? - */ setCollisionRange: function (start, stop, left, right, up, down) { if (this.tiles[start] && this.tiles[stop] && start < stop) @@ -159,6 +208,7 @@ Phaser.Tileset.prototype = { } }, + */ /** * Sets collision values on a tile in the set. @@ -169,7 +219,6 @@ Phaser.Tileset.prototype = { * @param {boolean} right - Should the tile collide on the right? * @param {boolean} up - Should the tile collide on the top? * @param {boolean} down - Should the tile collide on the bottom? - */ setCollision: function (index, left, right, up, down) { if (this.tiles[index]) @@ -178,6 +227,7 @@ Phaser.Tileset.prototype = { } } + */ } @@ -186,7 +236,7 @@ Phaser.Tileset.prototype = { * @property {number} total - The total number of tiles in this Tileset. * @readonly */ -Object.defineProperty(Phaser.Tileset.prototype, "total", { +Object.defineProperty(Phaser.Tileset.prototype, "XXXtotal", { get: function () { return this.tiles.length;