Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Scaling sprites in 2D

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 ta0soft   Members   

127
Like
0Likes
Like

Posted 24 February 2012 - 04:08 PM

I'm trying to create a resizable UI using sprites in SlimDX. I am drawing them in screen/window coordinates using Sprite.Draw, but I can't figure out how to scale sprites in screen coordinates.

For instance I need 9 sprites to draw the background of a button control. One for each corner and edge of the rectangle, and one for the center area. I want to stretch the center sprite so it fills the buttons background when it changes size.

Posted Image

I know how to get the scalar value of 2 integers but I don't know how this would apply in scaling the sprite. Any help would be greatly appreciated.

float scaleWidth = ?
float scaleHeight = ?

Sprite.Transform = Matrix.Transformation2D(new Vector2(p_Bounds.X + MiddleLeft.Width, p_Bounds.Y + TopCenter.Height), 0.0f, new Vector2(scaleWidth, scaleHeight), new Vector2(), 0.0f, new Vector2());
Sprite.Draw(Texture, MiddleCenter, new Vector3(), new Vector3(p_Bounds.X + MiddleLeft.Width, p_Bounds.Y + TopCenter.Height, 0.0f), new Color4(Color.White));





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.