Пример #1
0
void Row::addMovingObjects(std::string type, int distanceBetween, int num ){
    MovingObject* first = getMovingObject(type);
    distanceBetweenMovingObjects = distanceBetween;
    float x = first->getX();
    int width = first->getWidth();
    movingObjects.push_back(first);
    for(int i =1; i < num; i++){
        x -= (distanceBetween + width);
        MovingObject* entry = getMovingObject(type);
        entry->setX(x);
        movingObjects.push_back(entry);
    }
}
Пример #2
0
void Row::addMovingObject(std::string type){
  MovingObject * newMovingObject =  getMovingObject(type);

  if(movingObjects.size() >0){
    MovingObject * lastMovingObject = movingObjects.at(movingObjects.size()-1);
    float x = lastMovingObject->getX();
    int width = lastMovingObject->getWidth();

    newMovingObject->setX(x - distanceBetweenMovingObjects -width );
  }
  movingObjects.push_back(newMovingObject);


}