Example #1
0
// Initialise the games user interface
void Game::initUI()
{
	CSprite* background = new CSprite();
	background->m_X = (float)(ScreenWidth / 2);
	background->m_Y = (float)(ScreenHeight / 2);
	background->SetImage(g_pResources->getMenuBG());
	background->m_AnchorX = 0.5f;
	background->m_AnchorY = 0.5f;
	// Fit background to Device size
	background->m_ScaleX = (float)(ScreenWidth) / background->GetImage()->GetWidth();
	background->m_ScaleY = (float)ScreenHeight / background->GetImage()->GetHeight();
	AddChild(background);

	CSprite* FloorSprite = new CSprite();
	FloorSprite->m_X = (float)(background->m_X / 4);
	FloorSprite->m_Y = (float)(ScreenHeight / 2);
	FloorSprite->SetImage(g_pResources->getFloorImage());
	FloorSprite->m_AnchorX = 0.5f;
	FloorSprite->m_AnchorY = 0.5f;
	// Fit FloorSprite to Device size
	FloorSprite->m_ScaleX = (float)(ScreenWidth / 4) / FloorSprite->GetImage()->GetWidth();
	FloorSprite->m_ScaleY = (float)ScreenHeight / FloorSprite->GetImage()->GetHeight();
	AddChild(FloorSprite);

	player = new Fighter*[2];
	lifeBars = new CSprite*[2];

	CreateFighter(PLAYER_ONE, (float)(ScreenHeight / 3));
	CreateFighter(PLAYER_TWO, (float)(player[PLAYER_ONE]->m_Y * 2));
	CreateLifeBar(PLAYER_ONE, 0);
	CreateLifeBar(PLAYER_TWO, ScreenHeight);


	//2 special buttons
	buttons = new CSprite*[NUM_BUTTONS + 2];

	int i;
	for (i = 0; i < NUM_BUTTONS; i++)
	{
		CreateButton(i, FloorSprite->m_X, (float)(ScreenHeight / 5) * (i + 1));
	}

	CreateButton(i, FloorSprite->m_X + (ScreenWidth / 8), buttons[i - 2]->m_Y + (float)(ScreenHeight / 8));

	i++;

	CreateButton(i, buttons[i - 1]->m_X, buttons[i - 2]->m_Y + (float)(ScreenHeight / 8));

	//flip the first button as it is the same as the second
	buttons[0]->m_Angle += 180.0f;

	float fontScale = (float)IwGxGetScreenWidth() / FONT_DESIGN_WIDTH;
	float actualFontHeight = FONT_HEIGHT * fontScale;

	MessageLabel = new CLabel();
	MessageLabel->m_X = IwGxGetDisplayWidth() / 2;
	MessageLabel->m_Y = ScreenHeight / 2;
	MessageLabel->m_W = FONT_DESIGN_WIDTH;
	MessageLabel->m_H = actualFontHeight;
	MessageLabel->m_AlignHor = IW_2D_FONT_ALIGN_LEFT;
	MessageLabel->m_AlignVer = IW_2D_FONT_ALIGN_TOP;
	MessageLabel->m_Font = g_pResources->getFont();
	MessageLabel->m_ScaleX = fontScale;
	MessageLabel->m_ScaleY = fontScale;
	MessageLabel->m_Angle = 270.0f;
	AddChild(MessageLabel);
	MessageLabel->m_Alpha = 0.0f;
}
Example #2
0
void Streamer::Init()
{
    
    //Game* game = (Game*)g_pSceneManager->Find("game");
	initAudio("128.198.85.100", 8000);
	s3eDeviceRegister(S3E_DEVICE_EXIT, &exitCB, 0);
    
    facebook = new CSprite();
    facebook->SetImage(g_pResources->getFacebook());
    facebook->m_X = (float)IwGxGetScreenWidth() / 1.4;
    facebook->m_Y = (float)IwGxGetScreenHeight() / 16;
    facebook->m_W = facebook->GetImage()->GetWidth();
    facebook->m_H = facebook->GetImage()->GetHeight();
    facebook->m_AnchorX = 0.5;
    facebook->m_AnchorY = 0.5;
    facebook->m_ScaleX = (float)IwGxGetScreenWidth() / facebook->GetImage()->GetWidth() / 8;
    facebook->m_ScaleY = (float)IwGxGetScreenHeight() / facebook->GetImage()->GetHeight() / 12;
    
    twitter = new CSprite();
    twitter->SetImage(g_pResources->getTwitter());
    twitter->m_X = (float)IwGxGetScreenWidth() / 1.1;
    twitter->m_Y = (float)IwGxGetScreenHeight() / 16;
    twitter->m_W = twitter->GetImage()->GetWidth();
    twitter->m_H = twitter->GetImage()->GetHeight();
    twitter->m_AnchorX = 0.5;
    twitter->m_AnchorY = 0.5;
    twitter->m_ScaleX = (float)IwGxGetScreenWidth() / twitter->GetImage()->GetWidth() / 8;
    twitter->m_ScaleY = (float)IwGxGetScreenHeight() / twitter->GetImage()->GetHeight() / 12;

    // Create menu background
    header = new CSprite();
    header->SetImage(g_pResources->getHeader());
    header->m_X = (float)IwGxGetScreenWidth() / 3;
    header->m_Y = (float)IwGxGetScreenHeight() / 17;
    header->m_W = header->GetImage()->GetWidth();
    header->m_H = header->GetImage()->GetHeight();
    header->m_AnchorX = 0.5;
    header->m_AnchorY = 0.5;
    // Fit background to screen size
    header->m_ScaleX = (float)IwGxGetScreenWidth() / header->GetImage()->GetWidth() / 1.5;
    header->m_ScaleY = (float)IwGxGetScreenHeight() / header->GetImage()->GetHeight() / 5;
    
    // Create menu background
    CSprite* whiteBanner = new CSprite();
    whiteBanner->SetImage(g_pResources->getWhiteBanner());
    whiteBanner->m_X = (float)IwGxGetScreenWidth() / 2;
    whiteBanner->m_Y = (float)IwGxGetScreenHeight() / 17;
    
    whiteBanner->m_W = whiteBanner->GetImage()->GetWidth();
    whiteBanner->m_H = whiteBanner->GetImage()->GetHeight();
    whiteBanner->m_AnchorX = 0.5;
    whiteBanner->m_AnchorY = 0.5;
    // Fit background to screen size
    whiteBanner->m_ScaleX = (float)IwGxGetScreenWidth() / whiteBanner->GetImage()->GetWidth() / 1;
    whiteBanner->m_ScaleY = (float)IwGxGetScreenHeight() / whiteBanner->GetImage()->GetHeight() / 5;
    
    // Create menu background
    playWrapper = new CSprite();
    playWrapper->SetImage(g_pResources->getPlayWrapper());
    playWrapper->m_X = (float)IwGxGetScreenWidth() / 2;
    playWrapper->m_Y = (float)IwGxGetScreenHeight() / 1.09;
    playWrapper->m_W = playWrapper->GetImage()->GetWidth();
    playWrapper->m_H = playWrapper->GetImage()->GetHeight();
    playWrapper->m_AnchorX = 0.5;
    playWrapper->m_AnchorY = 0.5;
    //playWrapper->m_Alpha = 0.9;
    // Fit background to screen size
    playWrapper->m_ScaleX = (float)IwGxGetScreenWidth() / playWrapper->GetImage()->GetWidth() / 1;
    playWrapper->m_ScaleY = (float)IwGxGetScreenHeight() / playWrapper->GetImage()->GetHeight() / 6;

    playButton = new CSprite();
    playButton->SetImage(g_pResources->getPlayButton());
    playButton->m_X = (float)IwGxGetScreenWidth() / 2;
    playButton->m_Y = (float)IwGxGetScreenHeight() / 1.13;
    //buttonTop = (float)IwGxGetScreenHeight() / 1.14 - (playButton->GetImage()->GetHeight() / 8);
    playButton->m_W = playButton->GetImage()->GetWidth();
    playButton->m_H = playButton->GetImage()->GetHeight();
    playButton->m_AnchorX = 0.5;
    playButton->m_AnchorY = 0.5;
    // Fit background to screen size
    playButton->m_ScaleX = (float)IwGxGetScreenWidth() / playButton->GetImage()->GetWidth() / 3.2;
    playButton->m_ScaleY = (float)IwGxGetScreenHeight() / playButton->GetImage()->GetHeight() / 4.5;
    
    //buttonTop = ((float)IwGxGetScreenHeight() / 1.14) - (playButton->GetImage()->GetHeight() / 3.7);
    
    stopButton = new CSprite();
    stopButton->SetImage(g_pResources->getStopButton());
    stopButton->m_X = (float)IwGxGetScreenWidth() / 2;
    stopButton->m_Y = (float)IwGxGetScreenHeight() / 1.13;
    stopButton->m_W = stopButton->GetImage()->GetWidth();
    stopButton->m_H = stopButton->GetImage()->GetHeight();
    stopButton->m_AnchorX = 0.5;
    stopButton->m_AnchorY = 0.5;
    // Fit background to screen size
    stopButton->m_ScaleX = (float)IwGxGetScreenWidth() / stopButton->GetImage()->GetWidth() / 3.2;
    stopButton->m_ScaleY = (float)IwGxGetScreenHeight() / stopButton->GetImage()->GetHeight() / 4.5;
    
    banner = new CSprite();
    banner->SetImage(g_pResources->getGreyBanner());
    banner->m_X = (float)IwGxGetScreenWidth() / 2;
    banner->m_Y = (float)IwGxGetScreenHeight() /6;
    banner->m_W = banner->GetImage()->GetWidth();
    banner->m_H = banner->GetImage()->GetHeight();
    banner->m_AnchorX = 0.5;
    banner->m_AnchorY = 0.5;
    // Fit background to screen size
    banner->m_ScaleX = (float)IwGxGetScreenWidth() / banner->GetImage()->GetWidth() / 1;
    banner->m_ScaleY = (float)IwGxGetScreenHeight() / banner->GetImage()->GetHeight() / 8;
    
    buttonTop = IwGxGetScreenHeight() / 4;
    
    labelLeft = new CLabel();
	labelLeft->m_Font = g_pResources->getBannerFontSmall();
	labelLeft->m_Text = "Cal.";
    labelLeft->m_Y = IwGxGetDisplayHeight() / 6.5;
    labelLeft->m_W = IwGxGetDisplayWidth() / 2;
    labelLeft->m_ScaleX = 1.0;
    labelLeft->m_AlignHor = IW_2D_FONT_ALIGN_LEFT;
    labelLeft->m_X += 10;
    labelLeft->m_Color = CColor(114, 114, 114, 0xff);
    
    labelRight = new CLabel();
	labelRight->m_Font = g_pResources->getBannerFontSmall();
	labelRight->m_Text = "Events";
    labelRight->m_Y = IwGxGetDisplayHeight() / 6.5;
    labelRight->m_W = IwGxGetDisplayWidth() / 2;
    labelRight->m_AlignHor = IW_2D_FONT_ALIGN_RIGHT;
    labelRight->m_X += (IwGxGetDisplayWidth() / 2.0) -10;
    labelRight->m_Color = CColor(114, 114, 114, 0xff);
    
    labelMain = new CLabel();
	labelMain->m_Font = g_pResources->getBannerFontLarge();
	labelMain->m_Text = "News";
    labelMain->m_Y = IwGxGetDisplayHeight() / 7.5;
    labelMain->m_W = IwGxGetDisplayWidth();
    labelMain->m_AlignHor = IW_2D_FONT_ALIGN_CENTRE;
    
    AddChild(banner);
    AddChild(whiteBanner);
    AddChild(header);
    AddChild(labelRight);
    AddChild(labelLeft);
    AddChild(playWrapper);
    AddChild(playButton);
    AddChild(stopButton);
    AddChild(labelMain);
    AddChild(facebook);
    AddChild(twitter);
    
    stopButton->m_X = IwGxGetScreenWidth() * 2.0;
    currentPage = 0;
    
    
}