PDA

View Full Version : Creating sprites at runtime...



Damot
09-03-2004, 05:30 PM
For example....

--------------------

type

TPlayer = class(TImageSprite);
.......
var
MainPlayer : Tplayer;
....
procedure init;
begin
MainPlayer:=tplayer.create(form1.DXSpriteEngine.en gine); ?????
end;
-------------------

I can't seem to use "MainPlayer.tplayer.create(self)", so what should it be? It works as above, but wondered if it was correct???

Useless Hacker
09-03-2004, 07:29 PM
Yes, that is right. The parameter is supposed to be the "parent" of the sprite, so obviously it cannot be it's own parent. The Engine is the "root" sprite, so all your sprites will be a "child" of that (or the child of a child, etc.)

Damot
09-03-2004, 08:04 PM
Yes, that is right. The parameter is supposed to be the "parent" of the sprite, so obviously it cannot be it's own parent. The Engine is the "root" sprite, so all your sprites will be a "child" of that (or the child of a child, etc.)

Thanks for the quick reply.

I just wanted to check because if I create 100+ sprites this way I seem to get a lot of system crashes when I close the application.

So in the end I decided not to use sprites and draw them myself but I'm using the above for around 8 others.