SpriteEngine and rotate

Started by
2 comments, last by narvik 22 years, 1 month ago
I use SpriteEngine in my game. I need rotate the picture in DoMove procedure but I don''t know how. Can you help me, please? narvik
Advertisement
I assume you''re using a TImageSprite?
To rotate it you will need to use the TImageSpriteEx class or a descendant.
TImageSpriteEx has an Angle property which specifies how much to rotate (0..255).
I don''t think this class is listed in the DelphiX Help file, but if you look in the DXSprite.pas file, you will see how to use it.
[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]
I tried use TImageSpriteEx instead of TImageSprite but the picture wasn''t displaied. I looked at the DXSprite.pas and I did''t find out where is the mistake.
Here is the code (THrac is TImageSpriteEx):

constructor THrac.Create(AParent: TSprite);
begin
inherited Create(AParent);

Image := Form1.DXImageList.Items.Find(''rak'');
x := 10;
y := 10;
z := 2;
Angle := 90;
end;

procedure TForm1.DXTimerTimer(Sender: TObject; LagCount: Integer);
begin
DXInput.Keyboard.Update;
DXDraw.Surface.Fill(0);
SpriteEngine.Move(15);
SpriteEngine.Draw;
DXDraw.Flip;
end;

procedure TForm.FormCreate(Sender: TObject);
begin
THrac.Create(SpriteEngine.Engine);
end;

And other codes, which aren''t neccesary(I hope).
You need to set the Width and Height properties of the sprite to that of the Image, i.e:
...Image := Form1.DXImageList.Items.Find(''rak'');Width := Image.Width;Height := Image.Height;X := 10... 

I think this should work...
[ PGD - The Home of Pascal Game Development! ] [ Help GameDev.net fight cancer ]

This topic is closed to new replies.

Advertisement