예제 #1
0
void LoadBalancingListener::debugReturn(const JString& string)
{
	std::wcerr << string << std::endl;
#ifdef _EG_ANDROID_PLATFORM
	__android_log_print(ANDROID_LOG_INFO, "DemoParticle", "%s", string.UTF8Representation().cstr());
#endif
}
예제 #2
0
void LoadBalancingListener::leaveRoomReturn(int errorCode, const JString& errorString)
{
	updateState();
	if(errorCode == ErrorCode::OK)
		mpView->info("game room has been successfully left");
	else
		mpView->info("opLeaveRoom() failed: %s", errorString.UTF8Representation().cstr());
	mpView->initPlayers();
}
예제 #3
0
void LoadBalancingListener::joinRoomReturn(int localPlayerNr, const Hashtable& gameProperties, const Hashtable& playerProperties, int errorCode, const JString& errorString)
{
	updateState();
	if(errorCode == ErrorCode::OK)
	{
		mpView->info("game room has been successfully joined");
		afterRoomJoined(localPlayerNr);
	}
	else
		mpView->info("opJoinRoom() failed: %s", errorString.UTF8Representation().cstr());
}
예제 #4
0
void LoadBalancingListener::connectReturn(int errorCode, const JString& errorString)
{
	updateState();
	if(errorCode == ErrorCode::OK)
	{
		mpView->info("connected");
		mpLbc->opJoinRandomRoom();
	}
	else
		mpView->warn("Warn: connect failed %d %s", errorCode, errorString.UTF8Representation().cstr());
}
예제 #5
0
파일: CCLobbyView.cpp 프로젝트: kaznog/t09
void CCLobbyView::eventConnected( cocos2d::CCObject* sender )
{
    JString userName = "";
    CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
    CCEditBox *eb = this->getEditName();
    const char* ebtext = eb->getText();
    if (strlen(ebtext) != 0) {
        userName = ebtext;
        network->setUserName(userName);
    } else {
        userName = network->getUserName();
        eb->setText(userName.UTF8Representation().cstr());
    }
}
예제 #6
0
파일: CCLobbyView.cpp 프로젝트: kaznog/t09
bool CCLobbyView::initTopMenu()
{
    CCDirector* director = CCDirector::sharedDirector();
    const CCSize winSize = director->getWinSize();
    const CCSize mySize = this->getContentSize();
    const CCPoint center = ccpMult( ccpFromSize( mySize ), 0.5f );
    
    CCLabelTTF* consoleLabel = CCLabelTTF::create( "disconnected", "Arial", FONT_SIZE(24), CCSizeMake( winSize.width, FONT_SIZE(24) ), kCCTextAlignmentCenter );
    consoleLabel->setColor( ccc3(255, 255, 255) );
    CCMenuItemLabel* consoleItem = CCMenuItemLabel::create( consoleLabel );
    
    // bottom
    const CCSize editSize = CCSizeMake( winSize.width, FONT_SIZE(48) );
    CCMenuItem* editItem = CCMenuItem::create();
    editItem->setContentSize( editSize );
    
    CCMenu* topMenu = CCMenu::create( consoleItem, editItem, NULL );
    if( topMenu )
    {
        this->setConsole( consoleLabel );
        
        topMenu->alignItemsVertically();
        topMenu->setPosition( CCPointMake( center.x, winSize.height - (editItem->getContentSize().height + consoleItem->getContentSize().height)/2 ) );
        this->addChild( topMenu, 0, Child::CCMenu_topMenu );
        
        const CCPoint editItemPosition = editItem->getParent()->convertToWorldSpace( editItem->getPosition() );
        editItem->setContentSize( winSize );
        editItem->ignoreAnchorPointForPosition( false );
        editItem->setAnchorPoint( ccp( 0.5f, (winSize.height / (editItemPosition.y - winSize.height)) * 0.5f ) );
        
        CCScale9Sprite* editSprite = CCScale9Sprite::create("extensions/yellow_edit.png");
        CCEditBox* edit = CCEditBox::create( editSize, editSprite );
        edit->setPlaceHolder("PlayerName");
        edit->setReturnType(kKeyboardReturnTypeDone);
        edit->setFontColor(ccGRAY);
        edit->setMaxLength( 20 );
        edit->setDelegate(this);
        edit->setTouchEnabled( true );
        edit->setPosition( editItemPosition );
        CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
        JString userName = network->getUserName();
        edit->setText(userName.UTF8Representation().cstr());
        this->addChild( edit );
        this->setEditName(edit);
    }
    
    return topMenu;
}