View Single Post
  #2  
Old 07-10-2006, 06:28 PM
upsilon upsilon is offline
Shmoo
upsilon's Avatar
Join Date: Dec 2005
Location: Birmingham, Alabama
Posts: 58
upsilon is on a distinguished road
I think you should qualify the object-local variables with 'this.'. I dont really know the default scope of unqualified variable in the body of functions/events, but i think it either makes them class local, or even global variables.
NPC Code:

this.acceleration = 1;
this.granularity = 0.05;
... etc



and i think the general convention for function local-variable, is to just make them members of the temp object, like:

NPC Code:

function foo(x,y) {
temp.baz = x*y;
this.bar = temp.baz * 11;
}


to avoid unintentionally over writing global variables with the same name.
__________________
Health nuts are going to feel really stupid someday, lying in hospitals dying of nothing. - Redd Foxx

Last edited by upsilon; 07-10-2006 at 06:46 PM..
Reply With Quote