Пример #1
0
void StarPuzzle::initPuzzle(PuzzleLevel level) {
	for (int i = 0; i < 10; i++) {
		//CCLog("generatePuzzle times %d", i+1);
		clearPuzzle();
		generatePuzzle(level);
		if (evaluateMaxScore() >= 2000)
			break;
	}
	createStars();
	hideAllStars();
}
Пример #2
0
int MeshAdaptPUMIDrvr::constructEdges(Mesh& mesh)
{
  mesh.edgeNodesArray = new int[mesh.nEdges_global * 2];
  apf::MeshIterator* it = m->begin(1);
  apf::MeshEntity* e;
  while ((e = m->iterate(it))) {
    int i = localNumber(e);
    apf::MeshEntity* v[2];
    m->getDownward(e, 0, v);
    for(int iVtx=0; iVtx < 2; ++iVtx) {
      int vtxID = localNumber(v[iVtx]);
      mesh.edgeNodesArray[i * 2 + iVtx] = vtxID;
    }
  }
  m->end(it);
  createStars(mesh);
  return 0;
}
Пример #3
0
bool SelectCollection::init()
{
    if (!DrawLayer::init())
    {
        return false;
    }
    const CCPoint ORIGIN = Screen::getOrigin();
    const CCSize VISIBLE_SIZE = Screen::getVisibleSize();
    const float SCALE = Screen::getScaleFactor();

    _collections = CCLabelTTF::create( _("Collection"),
                                                   Fonts::getFontName(),
                                                   72);

    auto button_show = [](){return CCFadeTo::create(0.1f, 255);};
    _collections->setOpacity(0);
    _collections->runAction(button_show());


    _collections->setPosition(ccp(ORIGIN.x + VISIBLE_SIZE.width*0.5,
                               ORIGIN.y + VISIBLE_SIZE.height - 70/SCALE));
    _collections->setColor(GameInfo::getInstance()->getTitleColor());
    this->addChild(_collections);


    //Back Button
    _back_menu = _back.start(this, [this](){this->onButtonBackClicked(0);});
    this->addChild(_back_menu);


    //To trigger back button
    this->setKeypadEnabled(true);


    //Create menu with collections
    _col_spl = GraphicsManager::getLoaderFor(
                0,
                "collection-menu/collection_button.plist",
                "collection-menu/collection_button.png");




    _buttons_menu = MenuSpriteBatch::create(_col_spl);


    //unsigned int i = 0;
    unsigned int in_row = 1;

    CCSprite* image = _col_spl->loadSprite("collection_button.png");

    CCSize s = image->getContentSize();
    image->removeFromParent();

    float margin = s.width * 0.15f;
    float margin_vertical = s.width * 0.09f;
    float width = s.width*in_row + margin*(in_row - 1);

    unsigned int rows = GameInfo::getInstance()->getCollectionNumber();
    float height = rows * s.height + margin*(rows - 1);

    _buttons_menu->setContentSize(CCSize(width+margin*2, height+margin*2));

    _stars_spl = GraphicsManager::getLoaderFor(_buttons_menu,
                                               "level-end/big_stars.plist",
                                               "level-end/big_stars.png");
    _stars_spl->inject();

    unsigned int collection_id_first = 0;

    unsigned int* order = nullptr;

    unsigned int arr_premium[10] = {1,2,3,10,4,9,5,8,6,7};
    unsigned int arr_normal[10] = {1,2,3,4,5,6,7,8,9,10};
    if(GameInfo::getVersion() == Version::Premium)
    {
        
        order = arr_premium;
    }
    else
    {
        
        order = arr_normal;
    }

    float working_y = height-s.height/2+margin;
    for(unsigned int y=0; y<rows; ++y)
    {
        float working_x = s.width / 2 + margin;

        const JoinyCollectionID coll_id = order[collection_id_first];
        const JoinyCollection* l = RW::getLevelManager().getCollection(coll_id);

        AnimatedMenuItem* item = createCollectionItem(l, _col_spl);
        _buttons_menu->menu()->addChild(item, 100);

        item->setPosition(ccp(working_x, working_y));

        item = createStars(item,l);

        _buttons_map[item] = l;

        working_x += s.width + margin;
        collection_id_first++;
        working_y -= s.height + margin_vertical;
    }



    newScrolling(_buttons_menu);

    for(auto& i:_buttons_map)
    {
        AnimatedMenuItem* item = i.first;

        //animation
        float scale_button = item->getScale();
        item->setScale(scale_button*0.9);
        item->setAnchorPoint(ccp(0.5, 0.5));
        item->runAction(CCEaseElasticOut::create(
                                  CCScaleTo::create(0.7f, scale_button),
                                  0.4f));
    }

    return true;
}