Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by John

I'm trying to make a multiplayer game with node js and socket io and this error keeps popping up "Uncaught TypeError: Cannot call method 'getEntitiesByType' of null "

Here's my code, I put it on my index page don't really know if that was the right thing to do. Any help would be greatly appreciated.

socket.on('playermove', function (positionx,positiony,currentanimation,thisgamename) {

var otherplayer = ig.game.getEntitiesByType(EntityOtherplayer);

if(otherplayer){

for(var i in otherplayer){

if(thisgamename == otherplayer[i].gamename){

otherplayer[i].pos.x = positionx;

otherplayer[i].pos.y = positiony;

otherplayer[i].animation = currentanimation;

}}}
});

1 decade ago by Joncom

Does your game show the loading bar and then run? It is possible that your socket server is sending packets before the game has finished loading. If that happened, ig.game would be null.

1 decade ago by John

Yes it shows the loading bar, but you may be on to something. I think I'll go look into that. Thanks for the tip.
Page 1 of 1
« first « previous next › last »