3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by tango2009
0

Yes sorry I have defined an animated sprite in my header file like this

AnimatedSprite( const Image& Img, const Vector2f& Position = Vector2f(0, 0), const Vector2f& Scale = Vector2f(1, 1), float Rotation = 0.f, const Color& Col = Color(255, 255, 255, 255),int xCount=2,int yCount=2);

I want the user to move the sprite upwards when the up key is pressed and I have this code below.

if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Up))
                {


                }

However because vector2f is a type I cannot manipulate it so I need to make an instance of it. How would I do this?

Edited by mike_2000_17: Fixed formatting

0

>> However because vector2f is a type I cannot manipulate it so I need to make an instance of it.

what do you mean?

0

I cannot just change the vector directly like this for example


if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Up))
{

vector2f += 1;

}

This won sork so I need to make an instance of vector2f but I cannot figure it out in c++

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.