当前位置: 首页>>代码示例>>C++>>正文


C++ Levels::collectionLevel方法代码示例

本文整理汇总了C++中Levels::collectionLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ Levels::collectionLevel方法的具体用法?C++ Levels::collectionLevel怎么用?C++ Levels::collectionLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Levels的用法示例。


在下文中一共展示了Levels::collectionLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST(Levels, empty)
{
    Levels l;
    
    ASSERT_EQ(0, l.numLevels());
    
    ASSERT_EQ(string("err"), l.levelName(0, false));
    ASSERT_EQ(string("err"), l.levelName(0, true));
    
    ASSERT_LT(l.findLevel("non-existent"), 0);
    ASSERT_EQ(0, l.numCollections());
    ASSERT_LT(l.collectionFromLevel(0), 0);

    ASSERT_EQ(0, l.collectionSize(0));
    ASSERT_EQ(0, l.collectionSize(1));

    ASSERT_EQ(0, l.collectionLevel(0, 0));

    ASSERT_FALSE(l.demoPath(0).empty());
    ASSERT_FALSE(l.demoName(0).empty());
    ASSERT_FALSE(l.hasDemo(0));
}
开发者ID:smr99,项目名称:numptyphysics,代码行数:22,代码来源:LevelsTest.cpp

示例2: setCollection

    void setCollection(int c, int levelInC)
    {
        if (c < 0 || static_cast<unsigned int>(c) >=m_levels->numCollections()) {
            return;
        }
        m_collection = c;
        m_dispbase = 0;
        m_dispcount = m_levels->collectionSize(c);
        m_scroll->virtualSize(Vec2(SCREEN_WIDTH,150+(SCREEN_HEIGHT/ICON_SCALE_FACTOR+40)*((m_dispcount+2)/3)));

        m_scroll->empty();
        Box *vbox = new VBox();
        vbox->add( new Spacer(),  10, 0 );
        Box *hbox = new HBox();
        Widget *w = new Button("<<",Event::PREVIOUS);
        w->border(false);
        hbox->add( w, BUTTON_WIDTH, 0 );
        hbox->add( new Spacer(), 10, 0 );
        Label *title = new Label(m_levels->collectionName(c));
        title->font(Font::headingFont());
        title->alpha(100);
        hbox->add( title, BUTTON_WIDTH, 4 );
        w= new Button(">>",Event::NEXT);
        w->border(false);
        hbox->add( new Spacer(), 10, 0 );
        hbox->add( w, BUTTON_WIDTH, 0 );
        vbox->add( hbox, 64, 0 );
        vbox->add( new Spacer(),  10, 0 );

        hbox = new HBox();
        hbox->add( new Spacer(),  0, 1 );
        int accumw = 0;
        for (int i=0; i<m_dispcount; i++) {
            accumw += SCREEN_WIDTH / ICON_SCALE_FACTOR + 10;
            if (accumw >= SCREEN_WIDTH) {
                vbox->add(hbox, SCREEN_HEIGHT/ICON_SCALE_FACTOR+30, 4);
                vbox->add( new Spacer(),  10, 0 );
                hbox = new HBox();
                hbox->add( new Spacer(),  0, 1 );
                accumw = SCREEN_WIDTH / ICON_SCALE_FACTOR;
            }
            m_thumbs[i] = new IconButton("--","",Event(Event::PLAY, //SELECT,
                                         m_levels->collectionLevel(c,i)));
            m_thumbs[i]->font(Font::blurbFont());
            m_thumbs[i]->setBg(SELECTED_BG);
            m_thumbs[i]->border(false);
            hbox->add( m_thumbs[i],  SCREEN_WIDTH / ICON_SCALE_FACTOR, 0 );
            hbox->add( new Spacer(), 0, 1 );
        }
        vbox->add(hbox, SCREEN_HEIGHT/ICON_SCALE_FACTOR+30, 4);
        vbox->add( new Spacer(), 110, 10 );
        m_scroll->add(vbox,0,0);

        for (int i=0; i<THUMB_COUNT && i+m_dispbase<m_dispcount; i++) {
            Canvas temp( SCREEN_WIDTH, SCREEN_HEIGHT );
            Scene scene( true );
            unsigned char buf[64*1024];
            int level = m_levels->collectionLevel(c,i);
            int size = m_levels->load( level, buf, sizeof(buf) );
            if ( size && scene.load( buf, size ) ) {
                scene.draw( temp, FULLSCREEN_RECT );
                m_thumbs[i]->text( m_levels->levelName(level) );
                m_thumbs[i]->canvas( temp.scale( ICON_SCALE_FACTOR ) );
                m_thumbs[i]->transparent(m_dispbase+i!=levelInC);
            }
        }
    }
开发者ID:smr99,项目名称:numptyphysics,代码行数:67,代码来源:Dialogs.cpp


注:本文中的Levels::collectionLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。