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

Author Topic: sfml 1.6 sprite::GetSize equivalent? and general 2.0 questions  (Read 21908 times)

0 Members and 1 Guest are viewing this topic.

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
So I'm back with another fairly stupid question :P

Is there a 2.0 equivalent to 1.6 sprite::GetSize() function, or is getGlobalBounds() the closest thing to that that we get?

I'm just wondering because I am in the middle of changing my project from 1.6 to 2.0, so I would just like to know, since it would change the structure of some crucial functions.(Not in a bad way, I just wonder whether I have to rewrite them :P)
« Last Edit: August 18, 2012, 02:32:29 pm by natchos »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #1 on: August 17, 2012, 12:21:33 am »
Is there a 2.0 equivalent to 1.6 sprite::GetSize() function, or is getGlobalBounds() the closest thing to that that we get?
Why "closest thing"? getGlobal/LocalBounds() is the function for getting dimensions. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #2 on: August 17, 2012, 12:24:21 am »
Aye, but it returns a rect whereas GetPosition returns a vector :P
Also localbounds returns the size, right? Whereas globalbounds return the size and position and rotation?

Thanks for the fast reply :)

EDIT: Sorry, meant GetSize
« Last Edit: August 17, 2012, 12:53:49 am by natchos »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #3 on: August 17, 2012, 12:51:55 am »
Aye, but it returns a rect whereas GetPosition returns a vector :P
Also localbounds returns the size, right? Whereas globalbounds return the size and position and rotation?
GetPosition has nothing to do with GetSize, there's still a getPosition() function. ;)
The local bounds will return a rect with top = left = 0 and the width and height of the initial sprite size, whereas the global bounds acctually represents more the bounding box of the sprite, i.e. it takes into account the rotation, scale and position. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #4 on: August 17, 2012, 12:54:45 am »
Ya, sorry wrote wrong :) I meant GetSize, anyhow, thank you very much for the clarification.

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #5 on: August 17, 2012, 01:36:58 am »
New question! :D
Is there any specific reason as to why sf::rect.offset() was removed from 2.0?

EDIT: Also, why the removal of Right and Bottom coordinates in a rect?
« Last Edit: August 17, 2012, 01:39:51 am by natchos »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #6 on: August 17, 2012, 01:42:36 am »
I guess it's mostly qeustion for Laurent but I guess it's kind of useless/feature bloat and in 2.0 the rect is defined by left,top,width,height so if you want to move it, it's just 2 changes to left and top and in 1.6 it was defined by left,top,right,bottom so moving it would take 4 changes to each of these, which is a bit much already.

Edit: Again it's very Laurent focused question BUT it seems extremely unituitive to have right and bottom instead of width and height. And it makes getting width and height in 1.6 a pain if you're not careful and use two methods(2 more methods = more feature bloat).
« Last Edit: August 17, 2012, 01:45:16 am by FRex »
Back to C++ gamedev with SFML in May 2023

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #7 on: August 17, 2012, 01:53:31 am »
Ah yea, I see your point.

Still, now you have to change 2 values, instead of just calling a single function.
But I'm no expert on the inner workings of either Laurents mind or SFML, so I'll just accept the new classes as they are :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #8 on: August 17, 2012, 07:56:56 am »
sf::Rect members are public, so there's nothing you can't implement yourself on top of it -- like an offset function. Don't stop at what SFML directly provides, such functions are mostly for convenience (they don't bring new features), so add whatever is convenient for you ;)
Laurent Gomila - SFML developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #9 on: August 17, 2012, 10:59:25 pm »
So was Randomizer completely removed in 2.0? I can always construct my own randomizer, but if SFML already has one I see no reason to make my own instead of adding to the existing one.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #10 on: August 17, 2012, 11:07:40 pm »
Quote
So was Randomizer completely removed in 2.0?
Yes. It was nothing more than a very thin wrapper around std::rand.
Laurent Gomila - SFML developer

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #11 on: August 17, 2012, 11:08:22 pm »
Aight, I'll get to making my own then :D

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #12 on: August 17, 2012, 11:40:46 pm »
Time for next question :D

Why was getFrameTime removed? Feature bloat? Is there any good way to get the frame time?

EDIT: Can sf::RenderWindow::pollEvent in 2.0 be used in a similar way to sf::RenderWindow::GetInput from 1.6?
EDIT2: Nope it cannot I saw now. How should you handle inputs in 2.0?
« Last Edit: August 17, 2012, 11:50:35 pm by natchos »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #13 on: August 18, 2012, 01:09:28 am »
Why was getFrameTime removed? Feature bloat? Is there any good way to get the frame time?
It was a design decision; it's actually a bit too highlevel and can get easily implemented with a sf::Clock:
sf::Clock clock;
float dt = 0.f;
while(window.isOpen())
{
    dt = clock.restart().asSeconds();
    // ...
}

Nope it cannot I saw now. How should you handle inputs in 2.0?
The Input class got replaced by the three classes sf::Mouse, sf::Keyboard and sf::Joystick. See the documentation and/or tutorials for more information on the usage. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natchos

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • Email
Re: sfml 1.6 sprite::GetSize equivalent?
« Reply #14 on: August 18, 2012, 08:51:02 am »
Alright I will. Thank you for the helpful reply :)

EDIT: How do you check for a released key?
Since sf::Keyboard::"key" returns a bool on whether it is pressed or not, how do you check for a released key as opposed to a key which was never pressed?
« Last Edit: August 18, 2012, 09:01:06 am by natchos »

 

anything