Quick query that's confusing me.
Doing this: console.dir(playerObjects);
Returns this:
Array[0]
0: hiderGameClient.obj.player
1: hiderGameClient.obj.player
length: 2
__proto__: Array[0]
But when I do this: console.dir(playerObjects[0]);
It returns this:
undefined
When the expected result should be this:
0: hiderGameClient.obj.player
    displayObject: 1
    location: Array[2]
    name: "asdf"
   __proto__: Object
Any ideas what's happening?
I can't really post a fiddle as it's calling data from node using websockets.
Creating the array of objects:
data.forEach(function(obj) {
    var tmp = new hiderGameClient.obj.player();
    tmp.name = obj.displayName; // Gonna actually skip this binding after it's fixed
    tmp.location = obj.pos;
    tmp.displayObject = obj.object;
    playerObjects.push(tmp);
});
Edit 2:
hiderGameClient.gfx.updateGame = function() {
    playerObjects = [];
    getAllPlayerData = hiderGameClient.net.getAllPlayerData(function(data){
        data.forEach(function(obj) {
            var tmp = new hiderGameClient.obj.player();
            tmp.name = obj.displayName; // Gonna actually skip this binding after it's fixed
            tmp.location = obj.pos;
            tmp.displayObject = obj.object;
            playerObjects.push(tmp);
        });
    });
};
hiderGameClient.gfx.drawGame = function() {
    console.dir(playerObjects[0].toString());
    console.log("typeof playerObjects: " + typeof playerObjects);
    console.log("typeof playerObjects[0]: " + typeof playerObjects[0]);
    playerObjects.forEach(function(obj) {
        var canvas = document.getElementById('myCanvas');
        var context = canvas.getContext('2d');
        var imageObj = new Image();
        imageObj.onload = function() {
            context.drawImage(imageObj, 200, 300);
        };
        imageObj.src = './maps/' + map + '/obj/' + '1' + '.png';
    });
};
hiderGameClient.net.getAllPlayerData = function(callback) {
    socket.emit('whereare players', {timestamp: new Date().getTime()});
    socket.on('answer playerPositions', function(data) {
        callback(data);
    });
}
Edit 3:
Forgot main loop function:
hiderGameClient.gfx.mainloop = function() {
    this.updateGame();
    this.drawGame();
};
 
    