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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MickeyKnox

Pages: 1 2 [3] 4
31
General / Upgrading to SFML 2.0
« on: June 12, 2011, 07:12:39 pm »
After switchin to SFML 2.0, i stumbled over a few issues.
Some things where easy to fix, like Sprite::SetCenter doesn't exist any
more, now it's SetOrigin.

But it took me a while to figure out, that Clock::GetElapsedTime now
returns an int with milliseconds resolution, instead of a float with seconds
resolution.

Is there some sort of tutorial or a collection of issues to consider when
upgrading? I think at least things like the change of Clock::GetElapsedTime
should be communicated somehow...

edit:
And i'm a little confused about the comment on GetElapsedTime:
Quote
Its resolution depends on the underlying OS, but you can generally expect a 1 ms resolution.

Isn't it the purpose of SFML, *NOT* having to worry about the underlying OS?

32
Window / Why is RenderWindow::GetDefaultView () const in SFML2?
« on: June 12, 2011, 07:04:36 pm »
thanks, i stick with nexus' suggestion.

33
Window / Why is RenderWindow::GetDefaultView () const in SFML2?
« on: June 12, 2011, 01:45:41 am »
But how do i react on ResizeEvents, or do a zoom then?
Do i have to create a new view everytime?

34
Window / Why is RenderWindow::GetDefaultView () const in SFML2?
« on: June 11, 2011, 03:40:35 pm »
I have the following Code snippet:
Code: [Select]
       case sf::Event::Resized:
            {
                window->GetDefaultView ().SetSize (event.Size.Width, event.Size.Height);
                break;
            }
        case sf::Event::MouseWheelMoved:
            {
                // When zooming in, center view on Mouse Cursor Position
                if (event.MouseWheel.Delta > 0)
                {
                    window->GetDefaultView ().SetCenter (window->ConvertCoords (window->GetInput ().GetMouseX (), window->GetInput ().GetMouseY ()));
                    window->SetCursorPosition (window->GetWidth () / 2, window->GetHeight () / 2);
                }
                window->GetDefaultView ().Zoom (event.MouseWheel.Delta < 0 ? 0.5f : 2.f);
                break;
            }

And get the following errors for it:
Code: [Select]
GUI.cc:79:87: error: passing ‘const sf::View’ as ‘this’ argument of ‘void sf::View::SetSize(float, float)’ discards qualifiers [-fpermissive]
GUI.cc:88:148: error: passing ‘const sf::View’ as ‘this’ argument of ‘void sf::View::SetCenter(const Vector2f&)’ discards qualifiers [-fpermissive]
GUI.cc:91:88: error: passing ‘const sf::View’ as ‘this’ argument of ‘void sf::View::Zoom(float)’ discards qualifiers [-fpermissive]

That did work in SFML1.6. I think the problem is, that RenderWindow::GetDefaultView () became const in SFML2.
Now i would like to know why and maybe a suggestion, how to archieve what i want.

35
Graphics / Sprite: Corner Points
« on: June 07, 2011, 03:35:44 pm »
ok, thank you guys ~

36
Graphics / Sprite: Corner Points
« on: June 07, 2011, 02:11:00 pm »
Another approach i can think of is to have another image/sprite with just
the rectangle, and the rest of it transparent. Then i keep the position and
rotation of the two synchronized and only draw the second sprite, when
the user selects that unit.

Which approach is better in your opinion?

37
General / Selection
« on: June 07, 2011, 02:06:58 pm »
ok nexus, thanks.
I don't have that many objects, so i'll do a linear search.

38
Graphics / Sprite: Corner Points
« on: June 07, 2011, 02:04:04 pm »
Well, my sprites may have an arbitrary rotation. Thus, in my case it is not
that easy. So i guess i have to do some trigonometrics?

By the way, what i want to do is to draw a rectangle (with sf::Shape)
around the sprite, when the user selects it. If there is a better way
to archive this, please let me know.

39
Graphics / Sprite: Corner Points
« on: June 07, 2011, 01:43:53 pm »
I want to access the corner Points of a Sprite, but i can't
find a suitable method. Is it possible to get these points directly?

40
General / Selection
« on: June 07, 2011, 12:33:24 pm »
I want to be able to select an object, when the user clicks on it.
But how can i identify the object, the user clicked on?

I guess i could simply test the mouse point against all my objects,
but that would be rather inefficient, i guess.

Does SFML offer some infrastructure to do that?
If not, what would be a good approach?

I'm using RenderWindow and i just have a purely 2D Environment,
in case that makes things easier.

41
System / Clock::GetElapsedTime () in milliseconds
« on: May 10, 2011, 10:41:39 pm »
Exactly, i did something like this. Cheers...

42
System / Clock::GetElapsedTime () in milliseconds
« on: May 10, 2011, 10:35:16 pm »
Nevermind, i wasn't paying enough attention. The return value is a float.
But i became an int, when i passed it down in my app. A float is perfectly fine.

43
System / Clock::GetElapsedTime () in milliseconds
« on: May 10, 2011, 10:05:57 pm »
Clock::GetElapsedTime () returns the time in seconds. I think this is way too
coarse grained, when i call (and reset) this every frame, it always returns 0.
No wonder, my machine can draw more than one frame per second...

I think the method should return the elapsed time in milliseconds.

The reason is, i want to use the clock to animate my objects. In a simple
example, when my objects just moves straight with a given speed, i can
determine its new position, given the time passed by since the last frame.
That does'nt work however, if the time passed is always 0.

My guess is, other people had the same problem, how did you solve it?

And out of couriosity: What is the purpose of a clock with seconds granularity?

44
Network / Using OnSend and OnReceive
« on: April 19, 2011, 04:39:02 pm »
Nevermind, i just found the GetData method in Packet, which is public.

And it actually makes sense, that SocketTCP calls OnSend instead of GetData.

Sorry to bother...

45
Network / Using OnSend and OnReceive
« on: April 19, 2011, 04:18:06 pm »
Well, i had a look in SocketTCP.cpp, particularly in the Send(Packet&)
method. The OnSend method of the Packet is called in there, to get
the data. This is possible, because this class is declared a friend
in Packet.

This is basically what i want to do myself.

I don't want to use the Socket class of SFML, but rather another library
(ENet to be specific). I don't think this is a silly thing.

So maybe i shall put my question another way:
How can i get the data in the packet without modifying the SFML source code?

Pages: 1 2 [3] 4
anything