示例#1
0
//******************************************************************************
// initRetry
//******************************************************************************
void CommDlg::initRetry()
{
    CCSprite* sp = CCSprite::spriteWithSpriteFrameName("commdlg.png");
    if(sp)
        addChild(sp);
    char buf[100];
    initBtn();
     
    if(m_iRc == kReqConnectErr){
        //title
        snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("net_error"));
        TextNode* lbText = TextNode::textWithString(buf,45);
        lbText->setPosition(CCPointMake(0, 86));
        lbText->setColor(ccWHITE);
        lbText->setShadowColor(ccBLACK);
        addChild(lbText, 1);
        
        lbText = TextNode::textWithString(HttpComm::Inst()->getLocalErrStr().c_str(), CCSizeMake(400, 60), CCTextAlignmentCenter,26);
        lbText->setPosition(CCPointMake(0, 30));
        lbText->setColor(ccWHITE);
        lbText->setShadowColor(ccBLACK);
        addChild(lbText, 1);
        
        snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("net_again"));
        lbText = TextNode::textWithString(buf,26);
        lbText->setPosition(CCPointMake(0, -16));
        lbText->setColor(ccWHITE);
        lbText->setShadowColor(ccBLACK);
        addChild(lbText, 1);
    }
    else{
        //服务器来的错误提示
        const char* errMsg = CGameData::Inst()->getErrMsg();
        
        if(errMsg != NULL){
            TextNode* lbText = TextNode::textWithString(errMsg, CCSizeMake(400, 120), CCTextAlignmentCenter,26);
            lbText->setAnchorPoint(CCPointMake(0.5, 1));
            lbText->setPosition(CCPointMake(0, 100));
            lbText->setColor(ccWHITE);
            lbText->setShadowColor(ccBLACK);
            addChild(lbText, 1);
        }
    }
}
// on "init" you need to initialize your instance
bool HelloWorld::init() {
	//////////////////////////////
	// 1. super init first
	if (!CCLayer::init()) {
		return false;
	}

	//启用触摸
	this->setIsTouchEnabled(true);

	screenSize = CCDirector::sharedDirector()->getWinSize();
	xmlParse = HXmlParse::parserWithFile("string.xml");

	initBackground();
	initBtn();
	initLeftArea();
	initRightArea();
	initPlayer();

	return true;
}
示例#3
0
void createWindow(void)
{
	//Start up SDL and create window
	if( !initSDL() ){
		printf("Failed to init SDL windowi\r\n");
	}
	else{
		//Open the font
		font = TTF_OpenFont( "/usr/share/fonts/gnu-free/FreeMono.ttf", 22 );

		//If there was an error in loading the font
		if( font == NULL ){
			printf("Can't load FreeMono.ttf\r\n");
		}

		TTF_SetFontStyle(font, TTF_STYLE_ITALIC);
	
		// Creating keyboard
		initBtn(&keyBoard[0], "0");		initBtn(&keyBoard[1], "1");		initBtn(&keyBoard[2], "2");		initBtn(&keyBoard[3], "3");
		initBtn(&keyBoard[4], "4");		initBtn(&keyBoard[5], "5");		initBtn(&keyBoard[6], "6");		initBtn(&keyBoard[7], "7");
		initBtn(&keyBoard[8], "8");		initBtn(&keyBoard[9], "9");		initBtn(&keyBoard[10], "+");	initBtn(&keyBoard[11], "-");
		initBtn(&keyBoard[12], "/");	initBtn(&keyBoard[13], "*");	initBtn(&keyBoard[14], "=");
		
		
		//Render the text
		message = TTF_RenderText_Solid( font, "Hello, this is MVP example", textColor );
		
		//If there was an error in rendering the text
		if( message == NULL ){
			printf("createWindow: Can't create message\r\n");
		}
		//Fill the surface with black color 
	  SDL_FillRect( gScreenSurface, NULL, SDL_MapRGB( gScreenSurface->format, 0x00, 0x00, 0x00 ) );
	
		//Apply greetings
		SDL_BlitSurface( message, NULL, gScreenSurface, NULL );
		//Update the surface
		SDL_UpdateWindowSurface( gWindow );
		
	}
}