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

Pages: [1]
1
Graphics / Re: sprite.move is driving me crazy
« on: July 25, 2013, 04:25:13 am »
Just fixed it, instead of using events I changed to a real time system outside of the event loop.

This video here saved me in case anyone had the same problem.

2
Graphics / sprite.move is driving me crazy
« on: July 25, 2013, 04:13:44 am »
I have been trying to solve this for the past hour and I just can't fix it. Whenever I run this the sprite loads on the screen, but when I click the sprite repeats itself every 10 pixels and starts to flash. It seems like when I click, the sprite moves forever.

EDIT::
I added window.clear(); before I draw the sprite, but now it still seems like the sprite is moving multiple times from one mouse click.



int main()
{  

        sf::Texture text1;
        text1.loadFromFile("first.png");

        sf::Sprite sprite1;
        sprite1.setTexture(text1);
        sprite1.setOrigin(0,0);
        sf::RenderWindow window(sf::VideoMode(400, 250), "Preamble", sf::Style::Default);
       



    while (window.isOpen())
    {
               
       



        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)      
                window.close();
                }

                if (event.type == sf::Event::MouseButtonPressed)
                        sprite1.move(10,0);

        window.clear();
        window.draw(sprite1);
        window.display();

}
               
    return 0;
}

Pages: [1]
anything