Archived

This topic is now archived and is closed to further replies.

SpriteEngine and rotate

This topic is 5779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites