englercj / phaser-tiled

A tilemap implementation for phaser focusing on large complex maps built with the Tiled Editor.
MIT License
288 stars 31 forks source link

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

Closed sharmad closed 9 years ago

sharmad commented 9 years ago

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/

pooya72 commented 9 years ago

please give a live version link to debug.

sharmad commented 9 years ago

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

pooya72 commented 9 years ago

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

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

to init in boot.js

pooya72 commented 9 years ago

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

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

pooya72 commented 9 years ago

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

sharmad commented 9 years ago

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.

pooya72 commented 9 years ago

please upload your project live somewhere too

sharmad commented 9 years ago

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.

englercj commented 9 years ago

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

sharmad commented 9 years ago

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"

pooya72 commented 9 years ago

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.

sharmad commented 9 years ago

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

pooya72 commented 9 years ago

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

englercj commented 9 years ago

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