Another update: Now the tutorial includes a section on custom Types.
Grey Alien: Yeah, Type Functions is next in the tutorial. However, instead of this:
, I prefer this:
This way, New or Create can be used, and it will still get added to EntityList. Basically, crucial stuff should be added to New() 9stuff that might cause bugs if not done when the object is created), while you can initialize other variables (like x and y) with Create().
Grey Alien: Yeah, Type Functions is next in the tutorial. However, instead of this:
Function Create:TEntity(x,y) Local e:TEntity = New TEntity e.x = x e.y = y EntityList.AddLast(e) Return e End Function
, I prefer this:
Method New:TEntity() EntityList.AddLast(Self) End Method Function Create:TEntity(x,y) Local e:TEntity = New TEntity e.x = x e.y = y Return e End Function
This way, New or Create can be used, and it will still get added to EntityList. Basically, crucial stuff should be added to New() 9stuff that might cause bugs if not done when the object is created), while you can initialize other variables (like x and y) with Create().