How about an 'extends' and 'implements' clause in
javascript?
function MyPerson( name ) extends Person
{
this.name = name;
this.hitPoints = 10;
this.onWalk = function( ... ) {}
this.slash = function( enemy ){ enemy.fireEvent(
"onSlash" );
}
var p = new MyPerson( "personName" );
CreatePerson( p, "person.rss", false );
Person p = GetPersonByName( "personName" );
Debug( p.hitPoints );
Person p2 = GetPersonByName( "enemy" );
p.slash( p2 );
===============
===============
function MyTrigger() implements Trigger
{
this.onTouch = function( ... ) {}
this.onClick = function( ... ) {}
this.tile = "";// etc
}
===============
And, when adding triggers, a "reference object" field
should be supported.
I know a some of this can be achieved by using the
prototype clause, but a more close interaction between
the engine functions and the user's objects would
improve Sphere a lot.
Away better than work with strings :D
Logged In: YES
user_id=387078
Not going to happen.
JavaScript supports inheritance already via using prototype
Logged In: NO
This is more a forum question/request than a bug, please ask
in the forums.
Why not try:
http://www.kevlindev.com/tutorials/javascript/inheritance/
Logged In: YES
user_id=1206940
It can _all_ be done by prototyping, actually. Refer to the
official JS guide for details:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide
Also, Sphere _uses_ the SpiderMonkey JS engine. The
JavaScript syntax is something that's managed in that
project, by those guys: Sphere just uses it.