本文整理汇总了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);
}
示例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);
//.........这里部分代码省略.........