John J. Good extension. Personally I make a Create Function (within the Type declaraion) that takes parameters, because New can't, right? e.g.
So in the code you can just do TEntity.Create(100,200) all on one line. Also If I had another field in TEntity, say Field foo, that wasn't set with Create() I would do this:
Furthermore, if I extended TEntity to TPlayer which had field Health (as per your example) I would pass health into the Create() like this TPlayer.Create(100,200,300) and TPlayer's Create function would look like this (note the use of a typecast):
:-)
Function Create:TEntity(x,y) Local e:TEntity = New TEntity e.x = x e.y = y EntityList.AddLast(e) Return e End Function
So in the code you can just do TEntity.Create(100,200) all on one line. Also If I had another field in TEntity, say Field foo, that wasn't set with Create() I would do this:
Local e:TEntity = TEntity.Create(100,200) e.foo = 300
Furthermore, if I extended TEntity to TPlayer which had field Health (as per your example) I would pass health into the Create() like this TPlayer.Create(100,200,300) and TPlayer's Create function would look like this (note the use of a typecast):
Function Create(x,y,health) Local p:TPlayer = TPlayer(Super.Create(x,y)) p.health = health End Function
:-)