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 npk75

Hi,

I can't wrap my head around this. And I now need your help. I new to impactjs.

I have the following entity with.

EntityHero = ig.Entity.extend({
        
        collides: ig.Entity.COLLIDES.ACTIVE,
        type: ig.Entity.TYPE.A,
        checkAgainst: ig.Entity.TYPE.B,
        size: {x:32, y:32},
        animSheet: new ig.AnimationSheet('media/player.png',32,32),
        speed: 100,
        currentDirection: 'up',
        heroName: pname,
        sendTimer: 10,

Now in the update function for the entity I can't not evaluate the sendTimer variable and only gets NaN. I can see that the variable works in the init function.

update function
if (this.sendTimer < 0){
                this.sendTimer = parseInt(10);
                socket.emit('PlayerMovement',this.pos.x,this.pos.y,this.currentDirection,this.heroName);
                
            }
               this.sendTimer = this.SendTimer-1; 
               this.parent();

What am I doing wrong here.

thanks for all your help.
/patric

1 decade ago by npk75

Hi,
Found the problem, misspelled the variable sendTimer.

Thanks all,
Patric

1 decade ago by drhayes

Hey, just curious... why the call to parseInt(10)? Temporary code in anticipation of more complex logic in the future?
Page 1 of 1
« first « previous next › last »