colinvella / phaser-tilemap-plus

Tilemap animations, physics, events and custom property enhancements for Tiled JSON map files
MIT License
72 stars 5 forks source link

Cannot read property 'properties" of null #6

Open JohannesRolshausen opened 6 years ago

JohannesRolshausen commented 6 years ago

I tried to get it work with Ninja physics, but that always gave me the error: "Cannot set property 'game' of undefined" in phaser-ninja.physics.js.

Since I'm not using a lot of ninja physics yet, I tried it without, but now I always get: "Cannot read property 'properties' of null" in phaser-tilemap-plus.js.

Did I forget something in the installation?

colinvella commented 6 years ago

Hi,

It wasn't meant to be used with Ninja physics, but only with Arcade physics, sorry!

Having said that, can you show the code where you're trying to access the game property. The issue may be unrelated to phaser-tilemap-plus.

maxp-edcast commented 6 years ago

I am getting this same error attempting to use this with p2 phsics. The following (coffeescript) works without phaser-tilemap-plus:

# PRELOAD

@game.load.tilemap("tilemap1", @Assets.tilemap1, null, Phaser.Tilemap.TILED_JSON)
@game.load.image("tileset1", @Assets.tileset1)

# CREATE

map = @game.add.tilemap("tilemap1", 16, 16, 700, 500)
map.addTilesetImage "tileset1"
tiles_layer = map.createLayer "Tiles"
tiles_layer.resizeWorld()

But as soon as I add the following line at the beginning of the create function:

@game.plugins.add Phaser.Plugin.TilemapPlus

I get the following error from the @game.add.tilemap line:

bundle.js:65102 Phaser.Cache.getJSON: Key "tilemap1-TilemapPlus" not found in Cache.

and from the same line get the following error as well:

bundle.js:2821 Uncaught TypeError: Cannot read property 'properties' of null
    at new t (bundle.js:2821)
    at Phaser.GameObjectFactory.tilemap (bundle.js:2821)
    at PlayState.module.exports [as create] (bundle.js:1540

I would really appreciate support, because I'm not sure of any other way to get Tiled animations exported to Phaser.

If you want to reproduce, you can clone this repo: https://github.com/maxp-edcast/phaser_game . just run npm i and npm run dev and you can see the error in the console.

colinvella commented 6 years ago

Hi, I tried to clone your repo, and ran "npm i" and "npm run dev" as per your instructuions.

I get the following:

$ npm run dev

> snood-pinball-coffee@1.0.0 dev C:\Dev\phaser_game
> sh build.sh && ./node_modules/.bin/webpack-dev-server --content-base . --inline --hot

build.sh: line 2: ruby: command not found

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! file C:\windows\system32\cmd.exe
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! snood-pinball-coffee@1.0.0 dev: `sh build.sh && ./node_modules/.bin/webpack-dev-server --content-base . --inline --hot`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the snood-pinball-coffee@1.0.0 dev script 'sh build.sh && ./node_modules/.bin/webpack-dev-server --content-base . --inline --hot'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the snood-pinball-coffee package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     sh build.sh && ./node_modules/.bin/webpack-dev-server --content-base . --inline --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs snood-pinball-coffee
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls snood-pinball-coffee
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Dev\phaser_game\npm-debug.log

I suspect other dependencies are needed.

hadamlenz commented 6 years ago

I am experiencing the same issue

hadamlenz commented 6 years ago

I'm using Phaser CE and I have a preloader state. When I move all the code to load assets into the play state everything works. My assumption is there is something about preloading in a different state and reading from the cache

hadamlenz commented 6 years ago

Using console.log( game.cache._cacheMap ) when loading everything together shows the new cached tilemap tilemap-TilemapPlus. The tile map is not part of the cacheMap when using a preloader state

thanh-taro commented 6 years ago

I am too. And when I move the code to add plugin in Boot state, everything works just fine.