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


C++ Label::Init方法代码示例

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


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

示例1: Init

void MyWorld::Init()
{
    World::Init();

    TurnsLeft = 10;
    TurnsLeftChanged = true;
    Round = 1;
    RoundChanged = true;

    // Generate game grid
    RegenerateGameGrid();

    // Create board
    Actor* board = new Actor();
    board->Init();
    board->setModel(g_pResources->Board);
    board->setTouchable(false);
    AddActor(board);

    // Create grid of cubes
    float offs = CUBE_SIZE / 2.0f;
    int *gg = GameGrid;
    for (int y = -GameGridHeight / 2; y < GameGridHeight / 2; y++)
    {
        for (int x = -GameGridWidth / 2; x < GameGridWidth / 2; x++)
        {
            // Create a game object
            MyActor* actor = new MyActor();
            actor->Init();
            
            // Set model and position
            actor->setModel(g_pResources->Cube);
            actor->setPosition(x * CUBE_SIZE + offs, CUBE_SIZE / 2.0f + 2.5f, y * CUBE_SIZE + offs);
            actor->setRotation(((float)*gg) * 90.0f, 90, 0);
            actor->setCollisionSphereRadius(CUBE_SIZE / 2.5f);
            actor->setGridPosition(x + GameGridWidth / 2, y + GameGridHeight / 2);
            actor->setID(0);

            // Add to world to be processed and rendered
            AddActor(actor);
            gg++;
        }
    }

    // Create turns left label text
    Label* label = new Label();
    label->Init();
    label->setColour(200, 200, 80, 255);
    label->setFont(g_pResources->Font);
    label->setText("TURNS LEFT");
    AddActor(label);
    
    // Create turns left label to show how many turns are left
    TurnsLeftLabel = new Label();
    TurnsLeftLabel->Init();
    TurnsLeftLabel->setPosition(0, 30, 0);
    TurnsLeftLabel->setFont(g_pResources->Font);
    AddActor(TurnsLeftLabel);

    // Create current round label text
    label = new Label();
    label->Init();
    label->setColour(200, 200, 80, 255);
    label->setFont(g_pResources->Font);
    label->setText("ROUND");
    label->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP);
    AddActor(label);
    
    // Create turns left label to show how many turns are left
    RoundLabel = new Label();
    RoundLabel->Init();
    RoundLabel->setPosition(0, 30, 0);
    RoundLabel->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP);
    RoundLabel->setFont(g_pResources->Font);
    AddActor(RoundLabel);

    // Create game over label text
    GameOverLabel = new Label();
    GameOverLabel->Init();
    GameOverLabel->setPosition(0, 0, 0);
    GameOverLabel->setScale(2.0f);
    GameOverLabel->setColour(255, 255, 255, 255);
    GameOverLabel->setAligment(IW_GX_FONT_ALIGN_CENTRE, IW_GX_FONT_ALIGN_MIDDLE);
    GameOverLabel->setFont(g_pResources->Font);
    GameOverLabel->setText("GAME OVER");
    GameOverLabel->setVisible(false);
    AddActor(GameOverLabel);
    
}
开发者ID:AbrahamKO,项目名称:gbsgamejam,代码行数:89,代码来源:MyWorld.cpp

示例2: Init

void MyWorld::Init()
{
    World::Init();

    TurnsLeft = 10;
    TurnsLeftChanged = true;
    Round = 1;
    RoundChanged = true;


    // Generate game grid
    //RegenerateGameGrid();

    // Create board
    Actor* board = new Actor();
    board->Init();
    board->setModel(g_pResources->Board);
    board->setTouchable(false);
	board->setPosition(0, -10.f, 0);
    AddActor(board);

    // Create grid of cubes
    const float offs = CUBE_SIZE / 2.0f;
    for (int i = 0; i < MAX_CUSTOMERS; ++i)
    {
		// Create a game object
		MyActor* actor = new MyActor();
		actor->Init();
            
		// Set model and position
		actor->setModel(g_pResources->Cube);
		actor->setRotation(((float)(rand() % 4)) * 90.0f, 90, 0);
		actor->setCollisionSphereRadius(offs * 1.5f);
		actor->setID(0);
		actor->setVisible(false);
		actor->setPosition(0.f, 0.f, 90.f);
		// Add to world to be processed and rendered
		AddActor(actor);
    }

	for (int i = 0; i < 4; ++ i)
	{
		CustomerStore* actor = new CustomerStore();
		actor->Init();
            
		// Set model and position
		actor->setModel(g_pResources->Cube);
		actor->setRotation(((float)(i)) * 90.0f, 90, 0);
		actor->setScale(1.75f);
		actor->setPosition(-45.f + (i * CUBE_SIZE * actor->getScale() * 1.8f), 0.f, -40.f);
		actor->setCollisionSphereRadius(offs * actor->getScale() * 1.5f);
		actor->setID(0);
		// Add to world to be processed and rendered
		AddActor(actor);
	}
	SpawnCustomer();

    // Create turns left label text
    Label* label = new Label();
    label->Init();
    label->setColour(200, 200, 80, 255);
    label->setFont(g_pResources->Font);
    label->setText("SCORE:");
    AddActor(label);
    
    // Create turns left label to show how many turns are left
    TurnsLeftLabel = new Label();
    TurnsLeftLabel->Init();
    TurnsLeftLabel->setPosition(0, 30, 0);
    TurnsLeftLabel->setFont(g_pResources->Font);
    AddActor(TurnsLeftLabel);

    // Create current round label text
    label = new Label();
    label->Init();
    label->setColour(200, 200, 80, 255);
    label->setFont(g_pResources->Font);
    label->setText("ROUND");
    label->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP);
    AddActor(label);
    
    // Create turns left label to show how many turns are left
    RoundLabel = new Label();
    RoundLabel->Init();
    RoundLabel->setPosition(0, 30, 0);
    RoundLabel->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP);
    RoundLabel->setFont(g_pResources->Font);
    AddActor(RoundLabel);

    // Create game over label text
    GameOverLabel = new Label();
    GameOverLabel->Init();
    GameOverLabel->setPosition(0, 0, 0);
    GameOverLabel->setScale(2.0f);
    GameOverLabel->setColour(255, 255, 255, 255);
    GameOverLabel->setAligment(IW_GX_FONT_ALIGN_CENTRE, IW_GX_FONT_ALIGN_MIDDLE);
    GameOverLabel->setFont(g_pResources->Font);
    GameOverLabel->setText("GAME OVER");
    GameOverLabel->setVisible(false);
    AddActor(GameOverLabel);
//.........这里部分代码省略.........
开发者ID:nickw22,项目名称:gbsgamejam,代码行数:101,代码来源:MyWorld.cpp


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