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;
}}}
});
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;
}}}
});