9 years ago by orangebread
I'm having trouble loading my EntityPlayer inside my Weltmeister because I'm getting an undefined error in my EntityPlayer that takes a property value defined when client receives socket messages like such:
And:
Any ideas on how to fix this? Thanks!
// socket.js (client-side)
var namerand = Math.floor(Math.random()*999);
var playername = "player" + namerand; // Player name defined here
var socket = io.connect('http://localhost:8080');
socket.on('message', function (data) {
var player = ig.game.getEntitiesByType( EntityPlayer )[0];
if(player) {
player.messagebox = player.messagebox + '\n' + data + ' disconnected';
}
});
And:
// player.js
EntityPlayer = ig.Entity.extend({
size: {x: 32, y: 48},
direction: 1,
type: ig.Entity.TYPE.A,
nettimer: 10,
movementspeed: 100,
name: "player",
gamename: playername,
destinationx:99999999,
destinationy:99999999,
messageboxtimer: 200,
messagebox:'',
speed: 100,
checkAgainst: ig.Entity.TYPE.NONE,
collides: ig.Entity.COLLIDES.PASSIVE,
animSheet: new ig.AnimationSheet( 'media/player.png', 32, 48 ),
init: function( x, y, settings ) {
...
....
Any ideas on how to fix this? Thanks!
