├── src ├── index.js ├── constants.js ├── utils.js ├── physics.js ├── browser.js └── tiled │ ├── Tile.js │ ├── Tileset.js │ ├── Objectlayer.js │ └── TilemapParser.js ├── testmaps ├── maps │ ├── gfx │ │ └── png │ │ │ ├── blue_x10.png │ │ │ ├── ughTiles.png │ │ │ ├── 32_3_tiles.png │ │ │ ├── greyBlack.png │ │ │ ├── miniGreen.png │ │ │ ├── formosa │ │ │ ├── tiles.png │ │ │ ├── moon_overlay.png │ │ │ └── 16x16-overworld.png │ │ │ ├── greenBlue_x0_y32.png │ │ │ ├── singleTallBall.png │ │ │ ├── darkworld-tileset.png │ │ │ ├── ortho │ │ │ ├── yellowCircle.png │ │ │ ├── miniGreenOrtho.png │ │ │ └── miniBlueOrthoTall.png │ │ │ ├── isometric_grass_and_water.png │ │ │ ├── 32x16 │ │ │ ├── red_xoffset_0__yoffset_0.png │ │ │ ├── green_xoffset_16__yoffset_0.png │ │ │ ├── salmon_xoffset_13__yoffset0.png │ │ │ └── white_grey_xoffset_0__yoffset_0.png │ │ │ ├── 64x32 │ │ │ ├── blue_xoffset_0__yoffset_0.png │ │ │ ├── aqua_xoffset_0__yoffset_17.png │ │ │ ├── green_xoffset_0__yoffset_16.png │ │ │ ├── pink_xoffset_0__yoffset_20.png │ │ │ └── salmon_xoffset_0__yoffset_15.png │ │ │ └── 32x16_XY_offset │ │ │ ├── aqua_xoffset_5__yoffset_1.png │ │ │ ├── red_xoffset_5__yoffset_45.png │ │ │ ├── blue_xoffset_17__yoffset_5.png │ │ │ ├── yellow_xoffset_0__yoffset_0.png │ │ │ └── black_xoffset_32__yoffset_32.png │ ├── ortho │ │ ├── basicRotate.tmx │ │ ├── Ortho_1_32__32.tmx │ │ ├── formosa_zlib.tmx │ │ ├── formosa_gzip.tmx │ │ └── Ortho_1_32__32_objects.tmx │ └── iso │ │ ├── Isometric_32x16_nooffset.tmx │ │ ├── Isometric_cubes.tmx │ │ ├── Isometric_cubes_large.tmx │ │ ├── Isometric_land.tmx │ │ ├── Isometric_32x16_with_offset_x.tmx │ │ ├── Isometric_64_32_with_offset_y_evensize.tmx │ │ ├── Isometric_cubes_with_objects_large.tmx │ │ ├── Isometric_64_32_with_offset_y.tmx │ │ ├── Isometric_32x16_with_offset_x_y_odd.tmx │ │ ├── Isometric_32x16_with_offset_x_y_even.tmx │ │ └── Isometric_cubes_with_objects.tmx ├── README.md ├── css │ └── style.css ├── index.html └── js │ ├── resources.js │ ├── main.js │ └── vendor │ ├── jquery.query-object.js │ └── require-2.1.15.min.js ├── .gitignore ├── .editorconfig ├── LICENSE ├── package.json ├── gulpfile.js ├── CONTRIBUTING.md ├── .jscsrc ├── .eslintrc.json ├── typescript └── phaser-tiled.d.ts └── README.md /src/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | utils: require('./utils') 3 | }; 4 | -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/blue_x10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/blue_x10.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/ughTiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/ughTiles.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32_3_tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32_3_tiles.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/greyBlack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/greyBlack.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/miniGreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/miniGreen.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/formosa/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/formosa/tiles.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/greenBlue_x0_y32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/greenBlue_x0_y32.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/singleTallBall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/singleTallBall.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/darkworld-tileset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/darkworld-tileset.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/ortho/yellowCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/ortho/yellowCircle.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/formosa/moon_overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/formosa/moon_overlay.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/ortho/miniGreenOrtho.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/ortho/miniGreenOrtho.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/formosa/16x16-overworld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/formosa/16x16-overworld.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/ortho/miniBlueOrthoTall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/ortho/miniBlueOrthoTall.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/isometric_grass_and_water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/isometric_grass_and_water.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16/red_xoffset_0__yoffset_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16/red_xoffset_0__yoffset_0.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/64x32/blue_xoffset_0__yoffset_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/64x32/blue_xoffset_0__yoffset_0.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16/green_xoffset_16__yoffset_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16/green_xoffset_16__yoffset_0.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16/salmon_xoffset_13__yoffset0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16/salmon_xoffset_13__yoffset0.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/64x32/aqua_xoffset_0__yoffset_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/64x32/aqua_xoffset_0__yoffset_17.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/64x32/green_xoffset_0__yoffset_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/64x32/green_xoffset_0__yoffset_16.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/64x32/pink_xoffset_0__yoffset_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/64x32/pink_xoffset_0__yoffset_20.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/64x32/salmon_xoffset_0__yoffset_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/64x32/salmon_xoffset_0__yoffset_15.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16/white_grey_xoffset_0__yoffset_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16/white_grey_xoffset_0__yoffset_0.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16_XY_offset/aqua_xoffset_5__yoffset_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16_XY_offset/aqua_xoffset_5__yoffset_1.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16_XY_offset/red_xoffset_5__yoffset_45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16_XY_offset/red_xoffset_5__yoffset_45.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16_XY_offset/blue_xoffset_17__yoffset_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16_XY_offset/blue_xoffset_17__yoffset_5.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16_XY_offset/yellow_xoffset_0__yoffset_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16_XY_offset/yellow_xoffset_0__yoffset_0.png -------------------------------------------------------------------------------- /testmaps/maps/gfx/png/32x16_XY_offset/black_xoffset_32__yoffset_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/englercj/phaser-tiled/master/testmaps/maps/gfx/png/32x16_XY_offset/black_xoffset_32__yoffset_32.png -------------------------------------------------------------------------------- /testmaps/README.md: -------------------------------------------------------------------------------- 1 | # MapTests 2 | 3 | A bunch of [Tiled Editor][0] maps to test [phaser-tiled][1] features. 4 | 5 | [0]: http://mapeditor.org/ 6 | [1]: https://github.com/englercj/phaser-tiled 7 | 8 | ## Running 9 | 10 | First clone this repository, then run `npm install` in the cloned directory. 11 | 12 | You can run the packaged server by running `npm dev`. 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # sublime text 2 files 2 | *.sublime* 3 | *.*~*.TMP 4 | 5 | # temp files 6 | .DS_Store 7 | Thumbs.db 8 | Desktop.ini 9 | npm-debug.log 10 | 11 | # vim swap files 12 | *.sw* 13 | 14 | # emacs temp files 15 | *~ 16 | \#*# 17 | 18 | # project ignores 19 | !.gitkeep 20 | *__temp 21 | node_modules 22 | testmaps/maps/tilemap-assets.json 23 | testmaps/node_modules 24 | build -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs. 2 | # More information at http://EditorConfig.org 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | indent_style = space 10 | indent_size = 4 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [{package.json,bower.json,.travis.yml}] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /testmaps/css/style.css: -------------------------------------------------------------------------------- 1 | html,body { 2 | height: 100%; 3 | margin: 0; 4 | padding: 0; 5 | } 6 | 7 | #viewporter, 8 | #game { 9 | height: 100%; 10 | margin: 0; 11 | padding: 0; 12 | cursor: move; 13 | } 14 | 15 | #switch, 16 | #dirty, 17 | #fullscreen { 18 | position: absolute; 19 | } 20 | 21 | #switch { 22 | top: 5px; 23 | right: 5px; 24 | } 25 | 26 | #fullscreen { 27 | top: 30px; 28 | right: 5px; 29 | } 30 | -------------------------------------------------------------------------------- /testmaps/maps/ortho/basicRotate.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | eJzbzMDAsJlITAjA1J1gYEhA5iPrB8otQOZvhqpFM2cBA5o+aqoDuuEAlH8AGUPd50Cqf6kRdjAAALhbLLE= 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /testmaps/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Map Tests 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_32x16_nooffset.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | eJxjZGBgYCQBMyFhYsTR1ZBiD7FypPKJEUfHpIQRuRgAXoAAdg== 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_cubes.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | eJxjZGBgYAJiRirS1DRrpJtJbfeN+n3UTFxy2AClcUSOmbRw50g2czQfDX4zR+NoNDyp6XcAImcDeg== 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_cubes_large.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | eJztxTERAAAIAKHX/qE1CAPHVPvGtm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3bdgeZrTqZ 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | /** 3 | * @property CSV 4 | * @type {Number} 5 | * @static 6 | * @final 7 | */ 8 | CSV: 0, 9 | 10 | /** 11 | * @property CSV 12 | * @type {Number} 13 | * @static 14 | * @final 15 | */ 16 | TILED_JSON: 1, 17 | 18 | /** 19 | * @property CSV 20 | * @type {Number} 21 | * @static 22 | * @final 23 | */ 24 | TILED_XML: 2, 25 | 26 | /** 27 | * @property CSV 28 | * @type {Number} 29 | * @static 30 | * @final 31 | */ 32 | NORTH: 0, 33 | 34 | /** 35 | * @property CSV 36 | * @type {Number} 37 | * @static 38 | * @final 39 | */ 40 | EAST: 1, 41 | 42 | /** 43 | * @property CSV 44 | * @type {Number} 45 | * @static 46 | * @final 47 | */ 48 | SOUTH: 2, 49 | 50 | /** 51 | * @property CSV 52 | * @type {Number} 53 | * @static 54 | * @final 55 | */ 56 | WEST: 3 57 | }; 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Chad Engler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_land.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | eJx9ldtuwzAMQ6U6W9d1L2s7tP//pXOACCVOqDwIiR1bF5JSXhHxmvY0z3qv9XnaabOctsh6bOtl+zbkXf094Vtj3HC/ns53xa9vnX/N/yo1MMYi/lhTnScejKH+1Z/mq9hpTSkxiI++3+Se5qk4uXp0n37XvH8MD3o/wX3KHmvL2OP0Pe0CHuoe/Y3wdSmurg7yrPxm7LmuvU7H6/reGP1rzhlew8rDwNlTeE4L049pn5K3xiK/xDQP4umdr60u8u5ikwvHT+2xh3Vv9f077S/2miBmiqnixH5jjo94945qlL3Z5Ui8yG8iRscLa9L+YS5L7LHQGHqHWtH8lctuPhTHKw8XxHBcs08505iT6sv1kJuXxI34Eaej2efmpJs3HabdGcbtZoD2huOec8fxNnBWe5s4kDOnjU4rjtsj7Xdzmly5nhvw2+VBjtkfTuOcqdQya+/wcRiQF84hzgblif8D/jv5z1A9UC/l9x9tPQ2j 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /testmaps/maps/ortho/Ortho_1_32__32.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | eJxjZGBgYBzFo3gUj+JRPIpHMV4MAIBCAc0= 12 | 13 | 14 | 15 | 16 | eJytlFEKwDAIQ4P3P/R+t9BoUicUSjXP0G4WgIKOMhfw5fzBZB6f3frsdFueYrteJxbvJ6ZiOX7d++ti8nrLU8yE9a5Jat18Wu/k0nNHl77DppfT+6RzPDqsrjb5t5VO5VJf3feczIqTnvesS2eSW+PO4m2fqX8SrH0AW4MBUw== 17 | 18 | 19 | 20 | 21 | eJzNlEsKADEIQwu9/51nK0GTqF2M4KI1Pvv1nNpucGVMg5ybzDm8Sq/WWOVU2lcsFcviXX2cd+7J4U1ZyNtwkLflRN4LVudvuKw47uSyceS7/9jVo1bV7p5VloN9ZGKsF22ZzP/AdXpxp4azPuddsNqTPbtM1Cr7AKhgAaU= 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /testmaps/js/resources.js: -------------------------------------------------------------------------------- 1 | define(function () { 2 | var resources = { 3 | worlds: [ 4 | // Orthogonal test maps 5 | 'maps/ortho/formosa_gzip.tmx', 6 | 'maps/ortho/formosa_zlib.tmx', 7 | 'maps/ortho/Ortho_1_16__16_large.json', 8 | 'maps/ortho/Ortho_1_16__16_large.tmx', 9 | 'maps/ortho/Ortho_1_32__32.tmx', 10 | 'maps/ortho/Ortho_1_32__32_objects.tmx', 11 | 'maps/ortho/Ortho_1_32__32_objects.json', 12 | 'maps/ortho/basicRotate.tmx', 13 | 14 | // Isometric test maps 15 | 'maps/iso/Isometric_32x16_nooffset.tmx', 16 | 'maps/iso/Isometric_32x16_with_offset_x.tmx', 17 | 'maps/iso/Isometric_32x16_with_offset_x_y_even.tmx', 18 | 'maps/iso/Isometric_32x16_with_offset_x_y_odd.tmx', 19 | 'maps/iso/Isometric_64_32_with_offset_y.tmx', 20 | 'maps/iso/Isometric_64_32_with_offset_y_evensize.tmx', 21 | 'maps/iso/Isometric_cubes.tmx', 22 | 'maps/iso/Isometric_cubes_large.tmx', 23 | 'maps/iso/Isometric_cubes_with_objects.tmx', 24 | 'maps/iso/Isometric_cubes_with_objects_large.tmx', 25 | 'maps/iso/Isometric_land.tmx' 26 | ] 27 | }; 28 | return resources; 29 | }); 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phaser-tiled", 3 | "version": "2.0.4", 4 | "description": "A tilemap implementation for phaser focusing on large complex maps", 5 | "author": "Chad Engler ", 6 | "license": "MIT", 7 | "homepage": "https://github.com/englercj/phaser-tiled", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/englercj/phaser-tiled.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/englercj/phaser-tiled/issues" 14 | }, 15 | "keywords": [ 16 | "phaser", 17 | "html5", 18 | "tilemap", 19 | "tile", 20 | "map", 21 | "2d", 22 | "tiled" 23 | ], 24 | "files": [ 25 | "build/", 26 | "src/", 27 | "typescript/", 28 | "LICENSE", 29 | "README.md", 30 | "package.json" 31 | ], 32 | "dependencies": { 33 | "Base64": "^0.3.0", 34 | "xmldom": "^0.1.21", 35 | "zlibjs": "^0.2.0" 36 | }, 37 | "devDependencies": { 38 | "browserify": "^13.0.0", 39 | "code-style": "englercj/code-style", 40 | "eslint": "^1.10.3", 41 | "event-stream": "^3.3.2", 42 | "gulp": "^3.9.0", 43 | "gulp-eslint": "^1.1.1", 44 | "gulp-jscs": "^3.0.2", 45 | "gulp-util": "^3.0.7", 46 | "jscs": "^2.8.0", 47 | "vinyl-source-stream": "^1.1.0", 48 | "watchify": "^3.7.0", 49 | "gulp-connect": "^2.0.6", 50 | "gulp-phaser-tiled-pack": "^1.1.0" 51 | }, 52 | "peerDependencies": { 53 | "phaser": "^2.4.4" 54 | }, 55 | "main": "./src/index.js", 56 | "browser": { 57 | "./src/index.js": "./src/browser.js", 58 | "xmldom": false 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_32x16_with_offset_x.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | eJxjYGBgYGJABbj42MSZcIjjMwebOlIwAwN+ewkBbO6mxFx0d5FqNwwAAELkAE8= 20 | 21 | 22 | 23 | 24 | eJxjYEAARihmQBNjwCKODhgZsOun1FxcduEyHxubWDtINZeQWcTYj2wmABj0ACE= 25 | 26 | 27 | 28 | 29 | eJxjZoAAZgZUwIxFDFkcmxy6OlLMJRfgMguXvaT4k5C56Hpx+RmXPejqAUFYAFU= 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_64_32_with_offset_y_evensize.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | eJxjZGBgYBzFgwYDAFB4AGU= 24 | 25 | 26 | 27 | 28 | eJxjYGBgkGSAABjNgMSXxCJODSBJJB5p9gIAWhIDbA== 29 | 30 | 31 | 32 | 33 | eJyTZkAF0gzYgTSRmNpgpNkLABLZA2E= 34 | 35 | 36 | 37 | 38 | eJxjYIAAKQYEkELjkwKkiMTUBsPFXgCgzgNb 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_cubes_with_objects_large.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | eJztxTERAAAIAKHX/qE1CAPHVPvGtm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3bdgeZrTqZ 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_64_32_with_offset_y.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | eJxjZGBgYCQSDzWAzc24xEhRS4x9xIQXur0AFWgAFg== 28 | 29 | 30 | 31 | 32 | eJxjYCAeMJGABwvA5hZc7qNULbocsWEBUwMAJFQAKQ== 33 | 34 | 35 | 36 | 37 | eJxjYKANYCYB0xpgswOXveSqJcYfhPwLAC98ADo= 38 | 39 | 40 | 41 | 42 | eJxjYBh4wEICpsQOYsSIUYuLjc9uQupA8gA3jABR 43 | 44 | 45 | 46 | 47 | eJxjYBhagJUEjE0vMWKUqMWlBl09NnUAOfQAYA== 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_32x16_with_offset_x_y_odd.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | eJxjZGBgYCQSDzVAyM2MONiEzMGlFps4MWIwPgAUxAAV 28 | 29 | 30 | 31 | 32 | eJxjYCAeMJGABwvA5RZs4sSKYRPHx8cXHshyACRsACk= 33 | 34 | 35 | 36 | 37 | eJxjYKANYCYB0xqg24HPTmYcbGLliXUDNgAAL6AANw== 38 | 39 | 40 | 41 | 42 | eJxjYBh4wEICpsQOZBpdnBwxQuaRIgcCADnMAFU= 43 | 44 | 45 | 46 | 47 | eJxjYEAAVgbiwUCpZSUBE2s2sWqJ1Y/PD6x42ABSuAB5 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /testmaps/maps/iso/Isometric_32x16_with_offset_x_y_even.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | eJxjZGBgYCQCD3ZAyI2MaDQhM3CpQxfHpg6bGmLdBwAU0AAW 28 | 29 | 30 | 31 | 32 | eJxjYCAOMBGJBxLgsh9dHJs6YsRw8fH5mwkHG5caACUgACs= 33 | 34 | 35 | 36 | 37 | eJxjYKAuYCYS0wqgm43LLmYi1BCSo7Y6kBwAL0QANw== 38 | 39 | 40 | 41 | 42 | eJxjYBgYwEIkJtdsZBpdHBefWDFc7mIhQg2yHDY1ADzwAFU= 43 | 44 | 45 | 46 | 47 | eJxjYEAAVgbiAD3VsRKJqWk3MWK4zGclQg2yHLoaAFYsAHQ= 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var path = require('path'); 3 | var gutil = require('gulp-util'); 4 | var eslint = require('gulp-eslint'); 5 | var jscs = require('gulp-jscs'); 6 | var tiledmapPack = require('gulp-phaser-tiled-pack'); 7 | var connect = require('gulp-connect'); 8 | 9 | var source = require('vinyl-source-stream'); 10 | var watchify = require('watchify'); 11 | var browserify = require('browserify'); 12 | 13 | var index = './src/index.js'; 14 | var outdir = './build'; 15 | var bundle = 'Phaser.Plugin.Tiled'; 16 | var outfile = 'phaser-tiled.js'; 17 | 18 | function rebundle(file) { 19 | if (file) { 20 | gutil.log('Rebundling,', path.basename(file[0]), 'has changes.'); 21 | } 22 | 23 | return this.bundle() 24 | // log errors if they happen 25 | .on('error', gutil.log.bind(gutil, 'Browserify Error')) 26 | .pipe(source(outfile)) 27 | .pipe(gulp.dest(outdir)); 28 | } 29 | 30 | function createBundler(args) { 31 | args = args || {}; 32 | args.standalone = bundle; 33 | 34 | return browserify(index, args); 35 | } 36 | 37 | /***** 38 | * Dev task, incrementally rebuilds the output bundle as the the sources change 39 | *****/ 40 | gulp.task('watch', function () { 41 | var bundler = watchify(createBundler()); 42 | 43 | bundler.on('update', function (file) { 44 | gulp.start('lint'); 45 | rebundle.call(this, file).pipe(connect.reload()); 46 | }); 47 | 48 | gulp.watch('testmaps/maps/**/*', ['packmaps']); 49 | gulp.watch('testmaps/js/*', function (file) { 50 | gulp.start('lint'); 51 | gulp.src('testmaps/js/*').pipe(connect.reload(file)); 52 | }); 53 | 54 | connect.server({ 55 | root: '', 56 | livereload: true 57 | }); 58 | 59 | return rebundle.call(bundler); 60 | }); 61 | 62 | /***** 63 | * Build task, builds the output bundle 64 | *****/ 65 | gulp.task('build', function () { 66 | return rebundle.call(createBundler()); 67 | }); 68 | 69 | /***** 70 | * ESLint task, lints the lib and test *.js files. 71 | *****/ 72 | gulp.task('lint', function () { 73 | return gulp.src([ 74 | './src/**/*.js', 75 | 'testmaps/js/*.js', 76 | 'gulpfile.js', 77 | '!node_modules/**' 78 | ]) 79 | .pipe(eslint()) 80 | .pipe(eslint.format()) 81 | .pipe(jscs()) 82 | .pipe(jscs.reporter()); 83 | }); 84 | 85 | gulp.task('packmaps', function () { 86 | return gulp.src('./testmaps/maps/{iso,ortho}/*.{json,tmx}') 87 | .pipe(tiledmapPack({ useExtInKey: true, baseUrl: 'maps' })) 88 | .pipe(gulp.dest('./testmaps/maps')) 89 | .pipe(connect.reload()); 90 | }); 91 | 92 | gulp.task('dev', ['packmaps', 'lint', 'build', 'watch']); 93 | 94 | /***** 95 | * Base task 96 | *****/ 97 | gulp.task('default', ['lint', 'build']); 98 | -------------------------------------------------------------------------------- /testmaps/maps/ortho/formosa_zlib.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | eJwTYmBgEBrFwxJnU6CPHL3ZZOrNJlMvuj5CerGpHwwYAHdzIkA= 40 | 41 | 42 | 43 | 44 | eJzdjksOQDAURd8LgjGCKZbABtiYPaOYuZKKT6rU0E1O0t95vURm6UAPBrkXYAQTmB9ci4ls4PB+5mLtAZ/1cwLchyA6uDHWCUj5PEco/IKpvet1nKOKzt0iyPxfVRp0qCSloVte+tcm8sXLf+it7zOJyss0fOn3NgsYKxS4 45 | 46 | 47 | 48 | 49 | eJxjYBgFxAIvRgYHID5Ajl4roF4rqF4tRoYEIDsBaFYCMXqB6h20oHqBehYA9S4A8heQ4w5SANAOEG6AsklyM1AtCIP1kupmoHoQbiDL0UMQAAAYyhAJ 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Please read this short guide to contributing before performing pull requests or reporting issues. The purpose 4 | of this guide is to ensure the best experience for all involved and make development as smooth as possible. 5 | 6 | 7 | ## Reporting issues 8 | 9 | To report a bug, request a feature, or even ask a question, make use of the [GitHub Issues][10] in this repo. 10 | When submitting an issue please take the following steps: 11 | 12 | **1. Search for existing issues.** Your bug may have already been fixed or addressed in an unreleased version, so 13 | be sure to search the issues first before putting in a duplicate issue. 14 | 15 | **2. Create an isolated and reproducible test case.** If you are reporting a bug, make sure you also have a minimal, 16 | runnable, code example that reproduces the problem you have. 17 | 18 | **3. Include a live example.** After narrowing your code down to only the problem areas, make use of [jsFiddle][11], 19 | [jsBin][12], or a link to your live site so that we can view a live example of the problem. 20 | 21 | **4. Share as much information as possible.** Include browser version affected, your OS, version of the library, 22 | steps to reproduce, etc. "X isn't working!!!1!" will probably just be closed. 23 | 24 | [10]: https://github.com/englercj/phaser-tiled/issues 25 | [11]: http://jsfiddle.net 26 | [12]: http://jsbin.com/ 27 | 28 | 29 | ## Making Changes 30 | 31 | To build the library you will need to download node.js from [nodejs.org][20]. After it has been installed open a 32 | console and run `npm install -g gulp` to install the global `gulp` executable. 33 | 34 | After that you can clone the repository and run `npm install` inside the cloned folder. This will install 35 | dependencies necessary for building the project. You can rebuild the project by running `gulp` in the cloned 36 | folder. 37 | 38 | Once that is ready, you can make your changes and submit a Pull Request: 39 | 40 | - **Send Pull Requests to the `master` branch.** All Pull Requests must be sent to the `master` branch. 41 | 42 | - **Ensure changes are jshint validated.** Our JSHint configuration file is provided in the repository and you 43 | should check against it before submitting. This should happen automatically when running `gulp` in the repo directory. 44 | 45 | - **Never commit new builds.** When making a code change you should always run `gulp` which will rebuild the project 46 | so you can test, *however* please do not commit the new builds placed in `dist/` or your PR will be closed. By default 47 | the build process will output to an ignored folder (`build/`) you should be fine. 48 | 49 | - **Only commit relevant changes.** Don't include changes that are not directly relevant to the fix you are making. 50 | The more focused a PR is, the faster it will get attention and be merged. Extra files changing only whitespace or 51 | trash files will likely get your PR closed. 52 | 53 | [20]: http://nodejs.org 54 | 55 | 56 | ## Quickie Code Style Guide 57 | 58 | Use EditorConfig and JSHint! Both tools will ensure your code is in the required styles! Either way, here are some tips: 59 | 60 | - Use 4 spaces for tabs, never tab characters. 61 | 62 | - No trailing whitespace, blank lines should have no whitespace. 63 | 64 | - Always favor strict equals `===` unless you *need* to use type coercion. 65 | 66 | - Follow conventions already in the code, and listen to jshint. Our config is set-up for a reason. 67 | -------------------------------------------------------------------------------- /testmaps/maps/ortho/formosa_gzip.tmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | H4sIAAAAAAAACxNiYGAQGsXDEmdToI8cvdlk6s0mUy+6PkJ6sakfDBgA3TcUToQDAAA= 40 | 41 | 42 | 43 | 44 | H4sIAAAAAAAAC92OSw5AMBRF3wuCMYIplsAG2Jg9o5i5kopPqtTQTU7S33m9RGbpQA8GuRdgBBOYH1yLiWzg8H7mYu0Bn/VzAtyHIDq4MdYJSPk8Ryj8gqm963Wco4rO3SLI/F9VGnSoJKWhW1761ybyxct/6K3vM4nKyzR86fc2Cx4LRKqEAwAA 45 | 46 | 47 | 48 | 49 | H4sIAAAAAAAAC2NgGAXEAi9GBgcgPkCOXiugXiuoXi1GhgQgOwFoVgIxeoHqHbSgeoF6FgD1LgDyF5DjDlIA0A4QboCySXIzUC0Ig/WS6magehBuIMvRQxAAAAvGQyuEAwAA 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /testmaps/js/main.js: -------------------------------------------------------------------------------- 1 | require.config({ 2 | shim: { 3 | 'jquery.query': { 4 | deps: ['jquery'], 5 | exports: 'jQuery.fn.query' 6 | } 7 | }, 8 | paths: { 9 | jquery: 'vendor/jquery-2.1.1.min', 10 | 'jquery.query': 'vendor/jquery.query-object' 11 | } 12 | }); 13 | 14 | require([ 15 | 'jquery', 16 | 'resources', 17 | 'jquery.query' 18 | ], function ($, resources) { 19 | 20 | var $game; 21 | var game; 22 | var packDataKey = 'tiledmaps_pack_data'; 23 | var packData; 24 | 25 | // when DOM is ready, create the game instance 26 | $(function () { 27 | $game = $('#game'); 28 | window.game = game = new Phaser.Game($game.width(), 29 | $game.height(), Phaser.AUTO, 'game', { preload: gamePreload, create: gameSetup }, false, false); 30 | }); 31 | 32 | function gamePreload() { 33 | game.load.json(packDataKey, 'maps/tilemap-assets.json'); 34 | } 35 | 36 | function gameSetup() { 37 | 38 | game.add.plugin(Phaser.Plugin.Tiled); 39 | 40 | packData = game.cache.getJSON(packDataKey); 41 | 42 | var $sw = $('#switch'); 43 | var $fullscreen = $('#fullscreen'); 44 | var map = $.query.get('map'); 45 | 46 | // create a game state for each of the worlds 47 | resources.worlds.forEach(function (w) { 48 | var key = w.substring(w.lastIndexOf('/') + 1); 49 | 50 | game.state.add(key, { 51 | preload: function () { 52 | this.load.pack(key, null, packData); 53 | }, 54 | create: function () { 55 | this.add.tiledmap(key).spawnObjects(function (obj) { 56 | if (obj.type !== Phaser.SPRITE) return; 57 | 58 | obj.inputEnabled = true; 59 | obj.input.enableDrag(); 60 | }); 61 | }, 62 | update: function () { 63 | if (game.input.mousePointer.active) { 64 | moveCamera(game.input.mousePointer); 65 | } 66 | 67 | if (game.input.pointer1.active) { 68 | moveCamera(game.input.pointer1); 69 | } 70 | } 71 | }, false); 72 | 73 | $('