8
« on: November 07, 2011, 10:34:39 pm »
I'm rather new to all this, and I'm not sure if this even qualifies as a problem, it's more of a question on how all this works, and if maybe I'm doing something wrong, so i pasted the whole code.
I created a sprite that replaces the cursor, and then set the position of the sprite to Mouse::GetPosition. But the sprite seems to be trailing behind the cursor, especially in fullscreen. Then i set the framelimit to 60 and it didn't help, but if I set it to 58 it still trails a little, but it's a lot better.
Oh I also commented out the 121 and 133 lines in WindowImpl before building the libs, I thought it might help(it didn't).
I'm using SFML2, winxp
any help or info would be appreciated.
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
int main()
{
sf::VideoMode VMode(1280, 960, 32);
sf::RenderWindow Window(VMode, "SFML Sample Application", sf::Style::Default, sf::ContextSettings());
sf::View View;
View.Reset(sf::FloatRect(0, 0, 320, 240));
Window.SetView(View);
Window.SetFramerateLimit(60);
//Window.ShowMouseCursor(false);
sf::Mouse Mouse;
sf::Texture CursorTexture;
CursorTexture.LoadFromFile("Cursor.png");
sf::Sprite CursorSprite;
CursorSprite.SetTexture(CursorTexture);
CursorSprite.SetSubRect(sf::IntRect(0, 0, 9, 9));
CursorSprite.SetPosition(0.0f, 0.0f);
while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Window.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
Window.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Return))
{
Window.Create(VMode, "SFML Sample Application", sf::Style::Fullscreen);
Window.SetView(View);
Window.SetFramerateLimit(60);
//Window.ShowMouseCursor(false);
}
}
CursorSprite.SetPosition((sf::Mouse::GetPosition(Window).x /4) - 4, (sf::Mouse::GetPosition(Window).y /4) - 4);
Window.Clear(sf::Color(25, 25, 25));
Window.Draw(CursorSprite);
Window.Display();
}
return 0;
}