Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. void MainScene::createWalls()
  2. {
  3.     std::vector<cocos2d::Color3B> usingColors;
  4.     for (int i = 0; i<=colors.size()-1; i++)
  5.     {
  6.         usingColors.push_back(colors[i]);
  7.     }
  8.     Vec2 pBottom = Vec2(visibleSize.width/2,0);
  9.     Vec2 pTop = Vec2(visibleSize.width/2,visibleSize.width);
  10.     Vec2 pLeft = Vec2(0,visibleSize.width/2);
  11.     Vec2 pRight = Vec2(visibleSize.width,visibleSize.width/2);
  12.    
  13.     if(this->getChildByTag(2))
  14.          this->removeChild(this->getChildByTag(2));
  15.     if(this->getChildByTag(3))
  16.         this->removeChild(this->getChildByTag(3));
  17.     if(this->getChildByTag(4))
  18.         this->removeChild(this->getChildByTag(4));
  19.     if(this->getChildByTag(5))
  20.         this->removeChild(this->getChildByTag(5));
  21.  
  22.     int color ;
  23.    
  24.     int minSize = usingColors.size()-1;
  25.     wtf(usingColors);
  26.     color = random(0, minSize);
  27.    
  28.     Wall* wall1 = Wall::create(usingColors[color], pBottom);
  29.    
  30.     usingColors.erase(usingColors.begin() + color);
  31.    
  32.     wall1->setTag(2);
  33.     this->addChild(wall1);
  34.    
  35.     minSize = usingColors.size()-1;
  36.     wtf(usingColors);
  37.     color = random(0, minSize);
  38.    
  39.     Wall* wall2 = Wall::create(usingColors[color], pTop);
  40.    
  41.     usingColors.erase(usingColors.begin() + color);
  42.    
  43.     wall2->setTag(3);
  44.     this->addChild(wall2);
  45.    
  46.    
  47.     minSize = usingColors.size()-1;
  48.     wtf(usingColors);
  49.     color = random(0, minSize);
  50.    
  51.     Wall* wall3 = Wall::create(usingColors[color], pLeft);
  52.    
  53.     usingColors.erase(usingColors.begin() + color);
  54.    
  55.     wall3->setTag(4);
  56.     wall3->setRotation(90);
  57.     this->addChild(wall3);
  58.    
  59.     minSize = usingColors.size()-1;
  60.     color = random(0, minSize);
  61.    
  62.     Wall* wall4 = Wall::create(usingColors[color], pRight);
  63.    
  64.     usingColors.erase(usingColors.begin() + color);
  65.    
  66.     wall4->setTag(5);
  67.     wall4->setRotation(90);
  68.     this->addChild(wall4);
  69.  
  70.    
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement