englercj / phaser-tiled

A tilemap implementation for phaser focusing on large complex maps built with the Tiled Editor.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't add plugin to phaser. Get "TypeError: Cannot read property 'plugin' of null"

sharmad opened this issue · comments

commented

Tried to add this plugin to phaser and using

game.add.plugin(Phaser.Plugin.Tiled);

and I get this error and a completely dark,blank game page.

TypeError: Cannot read property 'plugin' of null

Interestingly, someone else have been having the same issues as well.

http://www.html5gamedevs.com/topic/13797-having-trouble-installing-plugins/

please give a live version link to debug.

commented

http://www.filedropper.com/platformergamecopy

Thought it would be easier to bundle everything. That has the full project (tilemap, phaser, phaser-tiled, structure). Its very light. 700kb

Pls take a look

i removed this line from app.js
window.onload = function() {

and adding the game.add.plugin(Phaser.Plugin.Tiled);

to init in boot.js

screen shot 2015-07-22 at 12 24 35 pm

screen shot 2015-07-22 at 12 24 47 pm

you can also try this
screen shot 2015-07-22 at 12 26 16 pm

commented

thanks a lot for helping. Srry for the late reply. Was on holiday. What you suggested got rid of the error. Can you also pls tell me how to correctly create a map as well.

Its a tiny issue. Basically, I get "Uncaught TypeError: Cannot read property 'convertTiledmap' of null". Think I messed up somewhere when creating the map or activating the plugin.

Pls check this short file http://www.filedropper.com/platformergametiledmapissue

PS - I really appreciate all the help.

please upload your project live somewhere too

commented

The link I posted above is all I have. I have just been trying to implement phaser-tiled plugin into a project and just learning how to do that. It has all the project files in it, like last time.

@sharmad That link just redirect me to their homepage, it doesn't actually let me download anything.

commented

uploaded here
https://www.dropbox.com/s/6t5t67j1jclhooc/Platformer_game_TILED_MAP.rar?dl=0

Pls help me. I am kinda desperate now. Can't get my head around how to fix this error as I said above?
"Uncaught TypeError: Cannot read property 'convertTiledmap' of null"

i had problems with Using collidable tiles too, so i used object tools instead. its more than easy if you are using tiled, create an object layer named collision(or whatever you want), draw lines through tools mentioned here (https://github.com/englercj/phaser-tiled#using-the-object-tools) and use it like charm.

commented

pooya, went the "object tools" route instead as you advised, but I get the same/similar error.
Uncaught TypeError: Cannot read property 'convertTiledCollisionObjects' of null

https://www.dropbox.com/s/brybxyy9yx6hwl5/Platformer_game_TILED_MAP_object.rar?dl=0

@englercj i took a look and cant find the problem, please check it.

Your problem has nothing to do with phaser-tiled. You are doing game.physics.p2.convertTiledmap() but you never initialize the p2 physics system. By default if you don't initialize any physics system Phaser will initialize the Arcade system.

Try this instead:

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'gameContainer', null, false, true, { p2: true });

Which uses the physicsConfig param to initialize the p2 physics system.

http://phaser.io/docs/2.4.2/Phaser.Game.html

If you would rather not do it in the ctor, you could instead just start the system manually:

game.physics.startSystem(Phaser.Physics.P2JS);

See any of the P2 examples:

http://phaser.io/examples/v2/category/p2-physics