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 - Dosia

Pages: [1]
1
System / Re: [SFML 2.0 RC] Mouse and moving sprite
« on: May 21, 2012, 09:31:27 pm »
I am really grateful. I used sf::Event to this, but when I pressed left and up together sprite is moving only in one direction. I put this functions behind loop and it is ok, sprite is moving in more than one direction and I do not have change in speed. Stupid mistake, but it is the worst kind of mistakes.

Thanks for help.

2
System / [SFML 2.0 RC] Mouse and moving sprite
« on: May 21, 2012, 08:46:32 pm »
Hey, I have a strange problem. When I am moving a cursor on the sfml window and try move a sprite it is moving faster than when i am not moving a cursor. When cursor isnt in window area, sprite is moving slower too. I thought that is something wrong with my code, but I have made a test in clear project and I have still this problem.

Somebody know what is it or could check it on his computer?

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
 int main()
 {
     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
         sf::Texture tex;
         tex.create(10,30);
         sf::Sprite sprite;
         sprite.setColor(sf::Color::Green);
         sprite.setTexture(tex);
         sprite.setPosition(200,100);
     while (window.isOpen())
     {
         sf::Event Event;
         while (window.pollEvent(Event))
         {
             if (Event.type == sf::Event::Closed)
                 window.close();
                         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
                                 sprite.move(-10,0);
                         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                                 sprite.move(10,0);
                         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
                                 sprite.move(0,-10);
                         if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
                                 sprite.move(0,10);
                 }
                 window.clear(sf::Color::White);
         window.draw(sprite);
         window.display();
     }
     return EXIT_SUCCESS;
 }
 

Sprite isnt drawing correctly, I saw two small rectangles, but i should see one big. In main project I dont have this problem (probably it is fault my integrated graphics card).

Thank you for sharing with me your time.

Pages: [1]
anything