Python? C++? I saw it somewhere...
Thanks for the tip. I got it right by making the TSpriteEngine a derived class from TList and each time a TSprite instance gets created its added to the TSpriteEngine list... So calling TSpriteEngine.Draw() will draw all the sprites... and calculate drawing order according to the Z value of TSprite.
[pascal]
type
  TSprite = class;
  TSpriteEngine = class(TList);
  TSprite = class
  private
    FEngine: TSpriteEngine;
  public
    constructor Create(AEngine: TSpriteEngine);
    property Engine: TSpriteEngine;
  end;
  TSpriteEngine = class(TList)
  private
    ...
  public
    procedure Add(Sprite: TSprite);
    property Items[Index: Integer]: TSprite read GetItem write SetItem;
    procedure Draw();
  end;
...
constructor TSprite.Create(AEngine: TSpriteEngine);
begin
  //Create the sprite and add to engine
  FEngine := AEngine;
  FEngine.Add(Self);
end;
[/pascal]
That helps to stop errors: "Undeclared identifier - TSpriteEngine"
Thanks for the help everyone...
Bookmarks