Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sprite.Transform.TransformRect()  (Read 5185 times)

0 Members and 1 Guest are viewing this topic.

immotus

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Sprite.Transform.TransformRect()
« on: January 02, 2016, 04:52:26 pm »
It seems like the dotnet version of SFML is becoming a bit convoluted.

Why doesn't the Sprite class simply have access to a Size member where we can set it's size with a method or a Size Property that we can set a Size on? 

Lacking documentation it appears that the purpose of TransformRect() is to change the size of the sprite. This is not very intuitive and seems like something that would be taken care of by the Scale property.  Which is a pain when all you want to do is configure the size of the sprite as you are loading up all the various objects you might need. 

For instance, I have 64x64 pixel texture regions that I want to use in a sprite that is 100x100 world units.. 
I created a Sprite and started to size it .. and promptly got lost trying when trying to set the size of the Sprite.

Just sayin.

I really like the elegance of c# but god damn, I think I'm going to switch back to c++.




zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Sprite.Transform.TransformRect()
« Reply #1 on: January 02, 2016, 05:09:51 pm »
Quote
Why doesn't the Sprite class simply have access to a Size member where we can set it's size with a method or a Size Property that we can set a Size on? 

It will as soon as it gets added back into the C++ side of things (which won't happen).

Quote
Lacking documentation...

The docs are not lacking, everything is fully documented.

Quote
...it appears that the purpose of TransformRect() is to change the size of the sprite

TransformRect(...) is a member of the Tranform class. I don't see why you would think this would change the size of a sprite. It is clearly documented as what it does. When it comes to using an API, don't assume stuff - read the docs, they weren't written to be ignored.

Quote
This is not very intuitive and seems like something that would be taken care of by the Scale property

The Scale property will change the size of the sprite by adjusting the transform. To calculate the scale (in order to achieve a specific size) simply divide the desired size by the texture size.

sprite.Scale = desiredSize / (Vector2f)sprite.Texture.Size;

Quote
I think I'm going to switch back to c++

The C++ side of SFML has the same API, so that really won't change anything.
« Last Edit: January 02, 2016, 05:14:51 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

immotus

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Sprite.Transform.TransformRect()
« Reply #2 on: January 02, 2016, 06:18:47 pm »
I apologize.  I missed the link to the low level Transform class.  Thanks for pointing me in the right direction. 

Maybe I am just getting old but it seems that properties like Size should be for configuration at start up and properties/methods of Scale are for runtime/render-loop alteration.  Basically, this is purely semantics.

Sorry to bother you.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Sprite.Transform.TransformRect()
« Reply #3 on: January 02, 2016, 07:11:17 pm »
Maybe I am just getting old but it seems that properties like Size should be for configuration at start up and properties/methods of Scale are for runtime/render-loop alteration.  Basically, this is purely semantics.

Its not my call, but it was removed in SFML 2 (was available in SFML 1) in favor of just the scale value. This was because the idea behind SFML is to not provide every single possible helper function, but to keep a minimal API that users can easily build off of. It has been discussed (feel free to search), but I really doubt an absolute size value is coming back.

Quote
Sorry to bother you.

There is no need to apologize, if I didn't want to help I wouldn't have bothered responding.  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

 

anything