Jump to content
  • Advertisement

Archived

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

narvik

SpriteEngine and rotate

This topic is 6058 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 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

Share this post


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

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!