Jump to content

How to pass scope into inline function?


Recommended Posts

Uncaught ReferenceError: tempScope is not defined

         console.log('animation complete');
         //temp scope = this = creature[e] ??         
         tempScope.angle *= -1;
         tempScope.x = -1000;
         tempScope.y = tempScope.world.randomY;
         tempScope.varSpeed = Math.floor((Math.random() * 4) + 1);
}, this);


Link to comment
Share on other sites

`tempScope` is a parameter of the function, if this parameter is not passed to the function then its reference becomes undefined, if you try and operate on it then the runtime will throw an error.

Whatever `creature[e].anim.onLoop.add` is doing with the callback you supplied, it isnt passing anything to the function.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...