obiot/melonJS — Issue #44: res.obj is undefined issue
Author: marilyse
Created: 2012-02-15 05:19:18+00:00
State: open

I found that when I load my next level in my game. FireFox will throw a "res.obj is undefined error". The error is referencing to this code:

if (res) {
// if we collide with an enemy
if (res.obj.type == me.game.ENEMY_OBJECT) {
// check if we jumped on it
if ((res.y > 0) && ! this.jumping) {
// bounce
me.audio.play("stomp");
this.forceJump();
} else {
// let's flicker in case we touched an enemy
this.flicker(45);
}
}
}

When it throws this error it will still load the next level. I have found that by deleting out the ".obj" in the "res.obj.type" the error goes away. I just wanted to post this solution in case other people were getting the same error and were trying to resolve it. After implementing this in my code, I have not noticed any issues caused by the deletion of ".obj".