void HSGameShopLayer::setVisible(bool visible)
{
	#define HS_Shop_Tag 0x75699

	CCLayer::setVisible(visible);
	if(visible)
	{

		Shop_FlyIn(*m_p_shop_frame,m_shop_frame_Position);

		CCScene* pScene = CCDirector::sharedDirector()->getRunningScene();

		if (!pScene->getChildByTag(HS_Shop_Tag))
		{
			pScene->addChild(this,HS_Shop_Tag,HS_Shop_Tag);
		}
	}
	else
	{
		CCScene* pScene = CCDirector::sharedDirector()->getRunningScene();
		if (pScene->getChildByTag(HS_Shop_Tag))
		{
			pScene->removeChildByTag(HS_Shop_Tag);
		}
	}
}
void HSLoadingLayer::setVisible(bool visible)
{
#define HS_Loadong_Tag 0x75698
    
	if (visible)
    {
        if(!this->isVisible())
        {
            CCScene* pScene = CCDirector::sharedDirector()->getRunningScene();
            if (pScene && !pScene->getChildByTag(HS_Loadong_Tag))
            {
                this->schedule(schedule_selector(HSLoadingLayer::Updata), 1.f);
                m_time = 15;
                pScene->addChild(this, HS_Loadong_Tag, HS_Loadong_Tag);
            }
        }
	}
	else
	{
		this->SetTipsUp("");
		this->m_pTipsTTFUp->setString("");
        this->removeFromParent();
        
	}
	CCLayer::setVisible(visible);
}
cocos2d::CCScene* BYGameScene::singlePlayerScene() {
    CCScene* scene = BYGameScene::scene();
    
    BYGameScene*    layer = (BYGameScene*) scene->getChildByTag(GUI_MainLayer);
    layer->initWithSinglePlayer();
    
    return scene;
}
Exemple #4
0
CCLayer* Utils::layerWithTag(int tag) {
    CCScene *sc = CCDirector::sharedDirector()->getRunningScene();
    if (sc->getTag() == TAG_GAME_SCENE) {
        CCLayer *layer = (CCLayer *)sc->getChildByTag(tag);
        return layer;
    }
    return NULL;
}
void LevelManager::GameInToSectionLayer()
{
	setNext(false);
	ResManager::getManager()->removeAllArmatureInfo();
	CCScene* pScene = Starseneui::scene();
	Starseneui* pLayer = (Starseneui*)pScene->getChildByTag(Starseneui_tag);
	pLayer->Goxiaogk(Smalllayer_tag);

	CCTransitionFade* pTran = CCTransitionFade::create(0.5f, pScene, ccWHITE);
	CCDirector::sharedDirector()->replaceScene(pTran);
}
void HSDailyRewardSystemLayer::setVisible( bool visible )
{
#define HS_DailyRewardSystemLayer_Tag 0x75699
	if (visible)
	{
		CCScene* pScene = CCDirector::sharedDirector()->getRunningScene();
		if (!pScene->getChildByTag(HS_DailyRewardSystemLayer_Tag))
		{
			pScene->addChild(this,HS_DailyRewardSystemLayer_Tag);
		}

	}else{
		CCScene* pScene = CCDirector::sharedDirector()->getRunningScene();
		if (pScene->getChildByTag(HS_DailyRewardSystemLayer_Tag))
		{
			pScene->removeChildByTag(HS_DailyRewardSystemLayer_Tag);
		}
	}
	CCLayer::setVisible(visible);
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
    CCDirector::sharedDirector()->stopAnimation();

    //Retrieve HelloWorld scene by using the tag and call the pauseGame method
    CCScene* scene = (CCDirector::sharedDirector()->getRunningScene());
    if (scene !=NULL) {
    	HelloWorld* helloWorldScene = dynamic_cast <HelloWorld*>(scene->getChildByTag(100));
    	if (helloWorldScene != NULL) {
    		helloWorldScene->pauseGame();
    	}
    }


}
Exemple #8
0
InGameScene* InGameScene::getGameLayer() {
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCScene* pScene = pDirector->getRunningScene();
    int tag = pScene->getTag();
    if(tag == TAG_INGAMESCENE) {
        CCNode* pNode = pScene->getChildByTag(TAG_INGAMELAYER);
        if(pNode != NULL) {
            return (InGameScene*)pNode;
        } else {
            return NULL;
        }
    } else {
        return NULL;
    }
}
Exemple #9
0
BattleLayer* CommonLookUpUtils::GetBattleLayer()
{
	CCScene* pRunningScene = CCDirector::sharedDirector()->getRunningScene();
	if (pRunningScene)
	{
		CCNode* pNode = pRunningScene->getChildByTag(TAG_LAYER_BATTLE);
		if (pNode)
		{
			BattleLayer* pBattleLayer = dynamic_cast<BattleLayer*>(pNode);
			return pBattleLayer;			
		}				
	}

	return NULL;
}
Exemple #10
0
void DuelEvent::happen()
{
	CCScene* pScene = Combat::scene();
	Combat* pLayer = (Combat*)pScene->getChildByTag(COMBATLAYER);
	//pass args(defined in CSV) here 
	CCInteger* intg = (CCInteger*) this->args->lastObject();
	if(intg!=NULL && pLayer!=NULL) 
		pLayer->setMonsterType( intg->getValue() );
	else if(intg==NULL && pLayer!=NULL)
		pLayer->setMonsterType( 1 );
	else
		CCLog("Combat Layer get fail. ");

	CCTransitionFade *scenetrans = CCTransitionFade::create(0.7, pScene);
	CCDirector::sharedDirector()->pushScene(scenetrans);
}
Exemple #11
0
	void Java_org_cocos2dx_hellocpp_HelloCpp_controllerMotion(JNIEnv*  env, jobject thiz, jint player, jfloat LS_X, jfloat LS_Y, jfloat RS_X, jfloat RS_Y)
	{
		CCDirector *pDirector = CCDirector::sharedDirector();
		if(pDirector != NULL)
		{
			CCScene *scene = pDirector->getRunningScene();
			if(scene != NULL)
			{
				Game* layer = (Game*)scene->getChildByTag(1001);
				if(layer != NULL)
				{
					layer->controllerMotion(player, LS_X, LS_Y, RS_X, RS_Y);
				}
			}
		}
	}
Exemple #12
0
	void Java_org_cocos2dx_hellocpp_HelloCpp_keyPressed(JNIEnv*  env, jobject thiz, jint player, jint keyCode)
	{
		CCDirector *pDirector = CCDirector::sharedDirector();
		if(pDirector != NULL)
		{
			CCScene *scene = pDirector->getRunningScene();
			if(scene != NULL)
			{
				Game* layer = (Game*)scene->getChildByTag(1001);
				if(layer != NULL)
				{
					layer->keyControllerPressed(player, keyCode);
				}
			}
		}
	}
Exemple #13
0
void ConfigMenu::screenshot()
{
	std::string sdcard = getSDCard();
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	const char* imgName = "/bug_screenshot.jpg";
	sdcard = sdcard.append(imgName);
	CCRenderTexture* pScreen = CCRenderTexture::create(size.width, size.height);
	CCScene* pTempScene = CCDirector::sharedDirector()->getRunningScene();
	pScreen->begin();
	//pTempScene->visit();
	pTempScene->getChildByTag(TAG_RUNNING_LAYER)->visit();
	pScreen->end();
	pScreen->saveToFile(sdcard.c_str());
	CC_SAFE_DELETE(pScreen);
	share();
	CCLOG("sdcard %s", sdcard.c_str());
}
void LoadingScene::loadResource()
{
    unloadResource();
    
    
    AnimationLoader::loadData();
  
    CCScene* scene = TestScene::scene();
    CCDirector::sharedDirector()->popToRootScene();
    CCDirector::sharedDirector()->pushScene(scene);
       for(int i=0; i<DataCollector::getInstance()->getMatchData()->resourcePackList.size(); i++)
    {
        ResourceLoader::loadResourcePack(DataCollector::getInstance()->getMatchData()->resourcePackList[i]);
    }
    ((TestScene*)scene->getChildByTag(1))->loadResource();
    ((TestScene*)scene->getChildByTag(1))->initScene();

}
/**
@brief 消息回调
@param uMsgId 消息ID
@param wParam
@param lParam
@param nTouchID
@return true 表示可以忽略后面调用 false 则表示还要继续执行
*/
bool WareAppDelegate::onMessageCallBack( unsigned long uMsgId, unsigned long wParam, unsigned long lParam, int nTouchID )
{
	IRenderSystem* pRenderSystem = getRenderSystem();
	if( pRenderSystem == NULL )
	{
		return false;
	}

	CCScene* pRootScene = pRenderSystem->getRootScene();

	/// 10000 系统定义的UILayerID
	ui::TouchGroup* pUILayer = (ui::TouchGroup*)pRootScene->getChildByTag( EGameLayerDepth_GUI );
	if( pUILayer == NULL )
	{
		return false;
	}

	return pUILayer->onMessageProc(uMsgId,wParam,lParam,nTouchID);
}
Exemple #16
0
void Game::starNewGame(Player* player1, Player* player2, bool restart)
{
    CCScene *pScene = GameLayer::scene();
    GameLayer* gameLayer = (GameLayer*)pScene->getChildByTag(1337);
    
    if(!restart) {
        addPlayer(player1);
        addPlayer(player2);
    }
    gameLayer->startGame(player1, player2);
    
    if(CCDirector::sharedDirector()->getRunningScene()){
        CCDirector::sharedDirector()->replaceScene(pScene);
    }else{
        CCDirector::sharedDirector()->runWithScene(pScene);
    }
    
    setCurrentScreen(GAME_SCREEN);
    currentGameType = player2->isAI() ? VS_AI : VS_HUMAN;
}
Exemple #17
0
void ResolutionUtil::destroyBlockSprite(CCSprite* sprite) {
	CCScene* scene = CCDirector::sharedDirector()->getRunningScene();
	CCLayer* layer = (CCLayer*) scene->getChildByTag(0);
	layer->removeChild(sprite);
}
Exemple #18
0
void ResolutionUtil::appearBlockSprite(CCSprite* sprite) {
	CCNode* parent = sprite->getParent();
	CCScene* scene = CCDirector::sharedDirector()->getRunningScene();
		CCLayer* layer = (CCLayer*) (scene->getChildByTag(0));
	layer->addChild(sprite);
}
Exemple #19
0
void LoadingScene::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
    CCLog("LoadingScene::onHttpRequestCompleted");
    CCHttpResponse *response = (CCHttpResponse*)data;
    
    if (!response)
    {
        return;
    }
    
    // You can get original request type from: response->request->reqType
    if (0 != strlen(response->getHttpRequest()->getTag()))
    {
        CCLog("%s completed", response->getHttpRequest()->getTag());
    }
    
    int statusCode = response->getResponseCode();
    char statusString[64] = {};
    sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
    //m_labelStatusCode->setString(statusString);
    CCLog("response code: %d", statusCode);
    
    if (!response->isSucceed())
    {
        CCLog("response failed");
        CCLog("error buffer: %s", response->getErrorBuffer());
        return;
    }
    
    // dump data
    std::vector<char> *buffer = response->getResponseData();
	std::string s;
    bool isDataStarted = false;
    for (unsigned int i = 0; i < buffer->size(); i++)
	{
        if( isDataStarted == false && !isspace((*buffer)[i]) )
            isDataStarted = true;
        if( isDataStarted == false) continue;
        
        s += (*buffer)[i];
    }
	CCLog("LoadingScene::onHttpRequestCompleted : buffer=%s", s.data() );
    
    if(strcmp(response->getHttpRequest()->getTag(), "URL_RECEIVE_ANIMALS") == 0)
    {
        labelLoading->setString("동물들과 교감하는중...");
        vector<ANIMALINFO> animalList;
        
        CCLog("URL_RECEIVE_ANIMALS: it comes %d", s.length());
        
        bool isAlreadyExist = false;
        map<int, Animal*>* pList = pData->getAnimalsByAccount(SceneManager::sharedSceneManager()->getUserAccountKey());
        if( pList != NULL )
            isAlreadyExist = true;
        while (s.length() != 0)
        {
            int delimIndex = s.find('|');
            string oneAnimalData;
            
            if( delimIndex != -1 )
            {
                oneAnimalData = s.substr(0, delimIndex);
                s = s.substr(delimIndex+1);
            }
            else
            {
                oneAnimalData = s;
                s = "";
            }
            
            ANIMALINFO info;
            info.name               = oneAnimalData.substr(0, oneAnimalData.find(" ") );
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.key                = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.type               = (ANIMAL_TYPE)atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.level              = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.status.sleep       = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.status.poop        = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.status.exp         = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.status.fullness    = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.status.health      = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
            oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
            info.status.joy         = atoi(oneAnimalData.data());
            
            CCLog("URL_RECEIVE_ANIMALS : %s %d %d %d %d %d %d %d %d %d", info.name.c_str(), info.key, info.type, info.level, info.status.sleep, info.status.poop, info.status.exp, info.status.fullness, info.status.health, info.status.joy );
            
            pData->makeDataFromAnimalInfo(SceneManager::sharedSceneManager()->getHostAccountKey(), info);
            //            char name[32] = "께이";
            //            char strMB[256] = {0,};
            //            wchar_t strUnicode[256] = {0,};
            //            memcpy(strUnicode, info.name.data(), info.name.size());
            //            wcstombs(strMB, info.name.data(), 256);
            //
            //
            //            for(int i = 0; i < info.name.size(); i++ )
            //            {
            //                CCLog("URL_RECEIVE_ANIMALS : name %d, %d, %d", name[i], strUnicode[i], strMB[i] );
            //            }
            
        }
        
        if( SceneManager::sharedSceneManager()->isFriendHome() )
        {
            InGameScene* pInGameLayer = ((InGameScene*)InGameScene::getInGameScene()->getChildByTag(INGAME));
            pInGameLayer->resetScene(SceneManager::sharedSceneManager()->getHostAccountKey());
            CCDirector::sharedDirector()->popScene();
        }
        else
        {
            if( isAlreadyExist )
            {
                CCDirector::sharedDirector()->popScene();
                CCScene* pScene = InGameScene::getInGameScene();
                ((InGameScene*)(pScene->getChildByTag(INGAME)))->resetScene(SceneManager::sharedSceneManager()->getUserAccountKey());
            }
            else
                CCDirector::sharedDirector()->replaceScene(InGameScene::scene());
        }
    }
}
Exemple #20
0
void Game::endGame()
{
    CCScene * pScene = CCDirector::sharedDirector()->getRunningScene();
    GameLayer* gameLayer = (GameLayer*)pScene->getChildByTag(1337);
    gameLayer->endGame();
}