Advertisement
Guest User

Untitled

a guest
Mar 5th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include "Obstacle.h"
  3.  
  4.  
  5. TubeObstacle::TubeObstacle(sf::Texture& up, sf::Texture& down)
  6. {
  7.     mUp = SpriteNode::Ptr(new SpriteNode(up));
  8.     mDown = SpriteNode::Ptr(new SpriteNode(down));
  9.  
  10.     mUp->scale(0.75, 1);
  11.     mDown->scale(0.75, 1);
  12.  
  13.     setPosition(sf::Vector2f{ 800, 0 } );
  14.     int random = rand() % 200;  random -= 100;
  15.     mUp->setOrigin(0, mUp->getBoundingRect().height / 2);
  16.     mUp->setPosition( 0, (float)random );
  17.     mDown->setPosition(0, (float)random + mUp->getBoundingRect().height/2 +  spaceBetween);
  18.     setVelocity(-300, 0);
  19.     attachChild(std::move(mUp));
  20.     attachChild(std::move(mDown));
  21. }
  22.  
  23.  
  24.  
  25. void TubeObstacle::updateCurrent(sf::Time frameTime)
  26. {
  27.     Entity::updateCurrent(frameTime);
  28.     if (getPosition().x < -200)
  29.     {
  30.         remove();
  31.     }
  32.  
  33.     std::cout << mChildren.at(0)->getBoundingRect().left << std::endl; // output is always 0
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement