'SFML Constantly moving sprite
I have had a look at other posts and didn't really help, I was able to do movements with gravity for the player movements but I cannot seem to do it for constantly moving sprites which are being drawn by a vector. Any help welcome!
CLASS:
class fall {
private:
sf::Sprite* fallSprite;
sf::Vector2f movement;
public:
float moveSpeed;
float directionY;
float x, y;
fall(sf::Sprite* fallTex) {
this->fallSprite = fallTex;
y = 10;
x = rand() % 1000;
cout << "spawn fall" << endl;
}
void draw(sf::RenderWindow* window) {
fallSprite->setPosition(x, y);
window->draw(*fallSprite);
}
sf::FloatRect getRect() {
return fallSprite->getGlobalBounds();
}
fall()
{
moveSpeed = 5;
directionY = +10;
}
~fall()
{
}
};
FUNCTION:
void moveFall();
{
sat.fall.move(f.moveSpeed * f.directionY);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
