Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "Obstacle.h"
- TubeObstacle::TubeObstacle(sf::Texture& up, sf::Texture& down)
- {
- mUp = SpriteNode::Ptr(new SpriteNode(up));
- mDown = SpriteNode::Ptr(new SpriteNode(down));
- mUp->scale(0.75, 1);
- mDown->scale(0.75, 1);
- setPosition(sf::Vector2f{ 800, 0 } );
- int random = rand() % 200; random -= 100;
- mUp->setOrigin(0, mUp->getBoundingRect().height / 2);
- mUp->setPosition( 0, (float)random );
- mDown->setPosition(0, (float)random + mUp->getBoundingRect().height/2 + spaceBetween);
- setVelocity(-300, 0);
- attachChild(std::move(mUp));
- attachChild(std::move(mDown));
- }
- void TubeObstacle::updateCurrent(sf::Time frameTime)
- {
- Entity::updateCurrent(frameTime);
- if (getPosition().x < -200)
- {
- remove();
- }
- std::cout << mChildren.at(0)->getBoundingRect().left << std::endl; // output is always 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement