Javascript+Base Voodoo? How to make Consts work like the engine does?

2 views
Skip to first unread message

Terence Tan

unread,
May 22, 2011, 7:24:29 AM5/22/11
to The Render Engine
I've been trying to get consts to work like in some of the classes in
the engine but I keep get NaN or undefined for the consts I define:

Tile = function() {
return R.engine.PooledObject.extend(/** @scope Tile.prototype */{
sourceRect: null,
tileInfo: null,
attribute: null,
constructor: function(sourceRect,tileInfo,attribute)
{
this.sourceRect = sourceRect;
this.tileInfo = tileInfo;
this.attribute = attribute;
},
getClassName: function() {
return "Tile";
},
TILE_WIDTH: 16,
TILE_HEIGHT: 16
});
};

Here is a sample of a class. Now I'm not a javascript guru so bear
with me. I tried using Tile.TILE_WIDTH both in the class definition
and in other classes and I always get a undefined. I notice however in
the engine scripts this is being done alot:

} else if (sMap.s == R.resources.types.Tile.ALL_TRANSPARENT)
{

Now I should probably rename my class to be something that won't
pollute the global namespace but besides that...how would you do a
static consts attached to a class definition.


Terence Tan

unread,
May 22, 2011, 8:19:26 AM5/22/11
to The Render Engine
Nevermind....I was missing } .. ;P

That's 1 hour I will never get back...

T.
Reply all
Reply to author
Forward
0 new messages