Exemple #1
0
void EquipInfoView::onEnter()
{
    CCNode::onEnter();
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
    setTouchEnabled(true);
    //CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, false);
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(EquipInfoView::refreashData), EQUIP_BAG_SHOW_DES, NULL);
    
    if (m_isAni) {
        playBombEff();
        this->getAnimationManager()->runAnimations("FadeIn");
    }
}
void Light::setIsConnectToSwitch(bool bConnectToSwitch)
{
    m_bConnected = bConnectToSwitch;
    if (m_bConnected)
    {
        CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(Light::switchStateChanged), MSG_SWITCH_STATE, NULL);
    }
    else
    {
        CCNotificationCenter::sharedNotificationCenter()->removeObserver(this, MSG_SWITCH_STATE);
    }
    updateLightState();
}
void MessageManager::sendStrenghtenInfoMessage(int pid,int petid,int typeids){
    CSJson::FastWriter writer;
    CSJson::Value root;
    root["pid"]=pid;
    root["petid"]=petid;
    root["typeid"]=typeids;
    std::string str=writer.write(root);
    CCLOG("%s",str.c_str());
    Message * msg= g_pSocket->constructMessage(str, CMID_STRENGTHPET);
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(MessageManager::receiveStrengthenInfoMessage), "1402", NULL);
    g_pSocket->sendMessage_(msg, false);
    
}
void ChuanqiduanzaoItem::menuItemClicked_DuanZao(CCObject* pObj)
{
	int tag = ((CCMenuItem*)pObj)->getTag();
	bool  bShici = false;
	if (tag == Tag_MenuItem_Yici)  bShici = false;
	else if(tag == Tag_MenuItem_Shici) bShici = true;
	else return;

	int profId = (int)((CCMenuItem*)pObj)->getUserData();

	CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(ChuanqiduanzaoItem::rsp_DuanZao), MSG_DuanzaoRsp_F, NULL);
	CmdHelper::getHelper()->cmdDuanzao(bShici, profId);
}
KDbool CCTextureAtlas::initWithTexture ( CCTexture2D* pTexture, KDuint uCapacity )
{
//	CCAssert ( pTexture != KD_NULL, "texture should not be null" );
    
	m_uCapacity   = uCapacity;
	m_uTotalQuads = 0;

	// retained in property
	m_pTexture = pTexture;
	CC_SAFE_RETAIN ( m_pTexture );

	// Re-initialization is not allowed
	CCAssert ( m_pQuads == KD_NULL && m_pIndices == KD_NULL, "" );

	m_pQuads   = (ccV3F_C4B_T2F_Quad *) kdCalloc ( 1, sizeof ( ccV3F_C4B_T2F_Quad ) * m_uCapacity );
	m_pIndices = (GLushort *) kdCalloc ( 1, sizeof ( GLushort ) * m_uCapacity * 6 );
	if ( !( m_pQuads && m_pIndices ) && m_uCapacity > 0 ) 
	{
		//CCLOG ( "XMCocos2D : CCTextureAtlas: not enough memory" );

		CC_SAFE_FREE ( m_pQuads );
		CC_SAFE_FREE ( m_pIndices );

		// release texture, should set it to null, because the destruction will
		// release it too. see cocos2d-x issue #484
		CC_SAFE_RELEASE ( m_pTexture );

		return KD_FALSE;
	}

#if CC_ENABLE_CACHE_TEXTURE_DATA
    // listen the event when app go to background
    CCNotificationCenter::sharedNotificationCenter ( )->addObserver 
	(
		this, callfuncO_selector ( CCTextureAtlas::listenBackToForeground ),
		EVENT_COME_TO_FOREGROUND, KD_NULL 
	);
#endif

	this->setupIndices ( );

#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO ( );    
#else    
    setupVBO ( );
#endif

	m_bDirty = KD_TRUE;	

	return KD_TRUE;
}
void FlySystemUpdateHint::onEnter(){
    CCNode::onEnter();
    
    CCLog("FlySystemUpdateHint onEnter" );
    
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
    setTouchEnabled(true);
    
    //hujiuxing 2015.12.17
    if( m_type == FLY_HINT_SERVER_STOP )
    {
         CCLog("FlySystemUpdateHint FLY_HINT_SERVER_STOP run" );
        
        this->stopAllActions();
        
      auto action = CCSequence::create(CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::showUIQuestNode))
                                 ,CCScaleTo::create(0.01, 1, 1)
                                 , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::rollText))
                                 , CCDelayTime::create(m_rollTime)
                                 , CCScaleTo::create(0.01, 1, 1)
                                 , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::hideUIQuestNode))
                                 , NULL
                                 );
     
        

    
      
        if (CCCommonUtils::isIosAndroidPad() && CCCommonUtils::getIsHDViewPort())
        {
            action = CCSequence::create(CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::showUIQuestNode))
                                     ,CCScaleTo::create(0.01, 2, 2)
                                     , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::rollText))
                                     , CCDelayTime::create(m_rollTime)
                                     , CCScaleTo::create(0.01, 2, 2)
                                     , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::hideUIQuestNode))
                                     , NULL);
        }
    
        
        auto forever = CCRepeatForever::create( action );
        this->runAction(forever);
    }
    else
    {
        CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(FlySystemUpdateHint::removeSelf), "remove_hint", NULL);
        this->schedule(schedule_selector(FlySystemUpdateHint::loop), 1);
    }
   //    m_time = m_countDown;
    //CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, Touch_Default, true);
   }
bool OtherLayer::init()
{
	if (!Layer::init())
	{
		return false;
	}
	NotificationCenter::getInstance()->addObserver(
		this,
		callfuncO_selector(OtherLayer::testMsg),
		"test",
		NULL
		);
	return true;
}
void GAMEUI_Scene::transitionOutUiDone(GAMEUI_Window *ui)
{
    if (!m_dialog) {
//        [self switchUi:ui toUi:m_ui];
    }
    
    GUI_WINDOW_STATE state = ui->getState();
	if (state == GUI_WINDOW_IDLE) {
		//nextWindow:
        removeChild(ui, false);
	}
	else if (state == GUI_WINDOW_ABANDON) {
		//prevWindow:
        if (ui->isCached()) {
            removeChild(ui, false);
        }
        else {
            removeChild(ui, true);
        }
        ui->release();
	}
	
	if (m_ui) {
		// transition next window in.
		m_transitionUi = m_ui;
        addChild(m_ui);
        CCCallFuncO * actionCallback = CCCallFuncO::create(this, callfuncO_selector(GAMEUI_Scene::transitionInUiDone), m_transitionUi);
        m_transitionUi->setVisible(true);
        m_transitionState = WINDOW_TRANSITION_IN;
        m_transitionUi->transitionIn(actionCallback);
	}
	else {
        m_transitionUi = NULL;
		m_transitionState = WINDOW_STATABLE;
        if (!m_dialog) {
            if (m_noUiCallback) {
                noUiCallback(NULL);
            }
            
            CCCallFunc * callback = CCCallFunc::create(this, callfunc_selector(GAMEUI_Scene::hideMask));
            CCFadeTo * fade = CCFadeTo::create(0.2f, 0);
            CCSequence * seq = CCSequence::create(fade, callback, NULL);
            m_windowMask->setOpacity(0x80);
            m_windowMask->runAction(seq);
        }
        else {
            m_dialog->resume();
        }
	}
}
void TexturePreLoad::loadTexture(string file,bool async)
{
#ifdef DEBUG_ENABLE_TEXTURE_LOAD_LOG
	T_LOG("TexturePreLoad::loadTexture ----> to load texture : [%s]",file.c_str());
#endif

	if (async)
	{
		cache->addImageAsync(file.c_str(), this, callfuncO_selector(TexturePreLoad::textureLoadedCallback));
	}else
	{
		cache->addImage(file.c_str());
	}
}
void NetworkPackageDispatch::initNode()
{
	CCNode::init();

// 	EventListenerCustom *listener = EventListenerCustom::create(MSG_WAIT_TIME_OUT, std::bind(&NetworkPackageDispatch::onTimeOut, this, std::placeholders::_1));
// 	Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);

	CCNotificationCenter *_sharedCenter = CCNotificationCenter::sharedNotificationCenter();
	_sharedCenter->addObserver(this, callfuncO_selector(NetworkPackageDispatch::onTimeOut), MSG_WAIT_TIME_OUT, NULL);

	// Let's running
	this->onEnter();
	this->onEnterTransitionDidFinish();
}
Exemple #11
0
void PropSpeedupView::onEnter(){
    CCNode::onEnter();
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
//    this->setModelLayerDisplay(true);
    setTouchEnabled(true);

    if (getParent() && (getParent()->getChildByTag(BUILDINGVIEW_TAG) || getParent()->getChildByTag(YESNODLG_TAG))){
    }else{
        setTag(YESNODLG_TAG);
    }
    CCSafeNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(PropSpeedupView::checkClose), MSG_QUEUE_REMOVE, NULL);
    
    onUpBtn1Click(NULL,CCControlEventTouchUpInside);
}
void SpriteMask::setMask(const char *pMaskFile)
{
	if (_isSetMask)    return;

	_maskTexture = CCTextureCache::sharedTextureCache()->addImage(pMaskFile);
	//_maskTexture->setAliasTexParameters();
	_maskTexture->retain();

	CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(SpriteMask::listenBackToForeground), EVNET_COME_TO_FOREGROUND, NULL);

	initProgram();

	_isSetMask = true;
}
Exemple #13
0
TextureCacheTest::TextureCacheTest()
    : m_nNumberOfSprites(20)
    , m_nNumberOfLoadedSprites(0)
{
    CCSize size = CCDirector::sharedDirector()->getWinSize();

    m_pLabelLoading = CCLabelTTF::create("loading...", "Arial", 15);
    m_pLabelPercent = CCLabelTTF::create("%0", "Arial", 15);

    m_pLabelLoading->setPosition(CCPointMake(size.width / 2, size.height / 2 - 20));
    m_pLabelPercent->setPosition(CCPointMake(size.width / 2, size.height / 2 + 20));

    this->addChild(m_pLabelLoading);
    this->addChild(m_pLabelPercent);

    // load textrues
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/HelloWorld.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_01.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_02.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_03.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_04.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_05.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_06.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_07.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_08.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_09.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_10.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_11.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_12.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_13.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_14.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/background1.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/background2.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/background3.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
    CCTextureCache::sharedTextureCache()->addImageAsync("Images/blocks.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack));
}
bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity)
{
//    CCAssert(texture != NULL, "texture should not be null");
    m_uCapacity = capacity;
    m_uTotalQuads = 0;

    // retained in property
    this->m_pTexture = texture;
    CC_SAFE_RETAIN(m_pTexture);

    // Re-initialization is not allowed
    CCAssert(m_pQuads == NULL && m_pIndices == NULL, "");

    m_pQuads = (ccV3F_C4B_T2F_Quad*)malloc( m_uCapacity * sizeof(ccV3F_C4B_T2F_Quad) );
    m_pIndices = (GLushort *)malloc( m_uCapacity * 6 * sizeof(GLushort) );
    
    if( ! ( m_pQuads && m_pIndices) && m_uCapacity > 0) 
    {
        //CCLOG("cocos2d: CCTextureAtlas: not enough memory");
        CC_SAFE_FREE(m_pQuads);
        CC_SAFE_FREE(m_pIndices);

        // release texture, should set it to null, because the destruction will
        // release it too. see cocos2d-x issue #484
        CC_SAFE_RELEASE_NULL(m_pTexture);
        return false;
    }

    memset( m_pQuads, 0, m_uCapacity * sizeof(ccV3F_C4B_T2F_Quad) );
    memset( m_pIndices, 0, m_uCapacity * 6 * sizeof(GLushort) );
    
    // listen the event when app go to background
    extension::CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
                                                           callfuncO_selector(CCTextureAtlas::listenBackToForeground),
                                                           EVNET_COME_TO_FOREGROUND,
                                                           NULL);

    this->setupIndices();

#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO();    
#else    
    setupVBO();
#endif

    m_bDirty = true;

    return true;
}
Exemple #15
0
void BaoZangView::afterGetFriendsInfo(CCObject* param){
    GameController::getInstance()->removeWaitInterface();
    CCArray* friends = dynamic_cast<CCArray*>(param);
    if (friends) {
        m_data->removeAllObjects();
        m_friendDatas->removeAllObjects();
        m_installDatas->removeAllObjects();
        int num = friends->count();
        string ids = "";
        for (int i=0; i<num; i++) {
            auto dic = _dict(friends->objectAtIndex(i));
            if(dic){
                dic->setObject(CCString::create("1"), "flag");
                FBFriendInfo* info = FBFriendInfo::create();
                info->id = dic->valueForKey("id")->getCString();
                info->name = dic->valueForKey("name")->getCString();
                info->url = CCString::createWithFormat("https://graph.facebook.com/%s/picture?type=square",dic->valueForKey("id")->getCString())->getCString();
                m_data->addObject(info);
                m_friendDatas->addObject(info);
                if(ids!=""){
                    ids += ",";
                }
                ids += info->id;
                m_installDatas->addObject(dic);
            }
        }
        int gapNum = 5 - m_data->count();
        if(gapNum<=0){
            gapNum = 1;
        }
        for(int i=0;i<gapNum;i++){
            FBFriendInfo* info = FBFriendInfo::create();
            info->id = CC_ITOA(12241111+i);
            info->name = "";
            info->url = "";
            info->add = true;
            m_data->addObject(info);
        }
        if(ids!="" && ActivityController::getInstance()->baozangHelpArr && ActivityController::getInstance()->baozangHelpArr->count()<=0){
            FBMineFriendsCommand* fbCmd = new FBMineFriendsCommand(ids);
            fbCmd->setSuccessCallback(CCCallFuncO::create(this, callfuncO_selector(BaoZangView::updateServerData), NULL));
            fbCmd->sendAndRelease();
        }
        if(m_friendDatas->count()>0){
            refreshHelpData();
        }
        CCLOG("friends count=%d",friends->count());
    }
}
bool KingBattleRewardView::init()
{
    if (!PopupBaseView::init()) {
        return false;
    }
    CCLoadSprite::doResourceByCommonIndex(8, true);
    setCleanFunction([](){
        CCLoadSprite::doResourceByCommonIndex(8, false);
    });

    setIsHDPanel(true);
    
    auto ccb = CCBLoadFile("KingdomThroneActivityReward",this,this);
    this->setContentSize(ccb->getContentSize());
    
    m_labelTitle->setString(_lang("170036"));
    m_tab1->setString(_lang("170044"));
    m_tab2->setString(_lang("170043"));
    m_tab3->setString(_lang("170037"));
    m_attackPrizeLabel->setString(_lang("170038"));
    m_defensePrizeLabel->setString(_lang("170038"));
    m_attackWinLabel->setString(_lang("170039"));
    
    
    //Hide other function
//    this->setModelLayerTouchCallback([&](cocos2d::CCTouch *pTouch){
//        this->touchPressed(pTouch->getLocation());
//    });
    m_btnNode->setVisible(false);
    
    
    
    
    

    bannerType=3;
    attackRewardArr = NULL;
    defenseRewardArr = NULL;
    singleRewardArr = NULL;
    m_attackScrollView=NULL;
    m_defenseScrollView=NULL;
    m_singleScrollView=NULL;
    
    CTFGetRewardCommand* cmd = new CTFGetRewardCommand();
    cmd->setCallback(CCCallFuncO::create(this, callfuncO_selector(KingBattleRewardView::getRewardDataCallBack), NULL));
    cmd->sendAndRelease();
    
    return true;
}
bool ControllerPlayer::init()
{

    rocker = HRocker::createHRocker("yao2.png", "yao1.png", Point(60, 60));
	rocker->startlistener();   // ×¢²á¼àÌý
	this->addChild(rocker);

	NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(ControllerPlayer::stopFunc), "stop", NULL);

	NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(ControllerPlayer::is_startlistener), "startlistener", NULL);

	NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(ControllerPlayer::is_stoplistener), "stoplistener", NULL);


	auto UI_1 = cocostudio::GUIReader::getInstance()->widgetFromJsonFile("fight_1.ExportJson");
	UI_1->setPosition(Point(0, 0));
	UI_1->setSwallowTouches(false);
	this->addChild(UI_1, 2);

	attack = (Button*)Helper::seekWidgetByName(UI_1, "Button_4");
	attack->addTouchEventListener(this, toucheventselector(ControllerPlayer::attackEvent));

	skill = (Button*)Helper::seekWidgetByName(UI_1, "Button_1");
	skill->addTouchEventListener(this, toucheventselector(ControllerPlayer::skillEvent));

	shangxian = (Button*)Helper::seekWidgetByName(UI_1, "Button_3");
	shangxian->addTouchEventListener(this, toucheventselector(ControllerPlayer::sxEvent));

	bigskill = (Button*)Helper::seekWidgetByName(UI_1, "Button_2");
	bigskill->addTouchEventListener(this, toucheventselector(ControllerPlayer::bigskillEvent));


	this->scheduleUpdate();

	return true;
}
Exemple #18
0
Platform::Platform (GameLayer * game) : b2Sprite (game) {
    
    //create body
    b2BodyDef bodyDef;
    bodyDef.type = b2_staticBody;
    
    _body = game->getWorld()->CreateBody(&bodyDef);
    _body->SetSleepingAllowed(true);
    _body->SetUserData(this);
    
    //register game notifications
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(Platform::onGravityChanged), NOTIFICATION_GRAVITY_SWITCH, NULL);
    

}
Exemple #19
0
void CardShop::showChooseCard(int idx)
{
    m_iSelNo = idx;
    CShopCardInfo* pShopCard = pShopCardsArr->getObjectAtIndex(idx);
    
    if (m_cfmLayer == NULL)
    {
        m_cfmLayer = new CardConfirm(this, callfuncO_selector(CardShop::cbCfm), pShopCard);
        addChild(m_cfmLayer);
        m_cfmLayer->setPosition(CCPointMake(0, -getPosition().y));
        m_cfmLayer->release();
    }
    
    
}
bool BattleManagerScreen::init()
{

	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    //CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	setContentSize( visibleSize );
	
	initAbilities();

	m_travelLastSpawnLocation = 0.0f;
	m_travelProgess = 0.0f;
	m_travelDistance = 100.0f;
	float pbMargin = 50;
	m_pbTravel = ProgressBar::create( CCRectMake( pbMargin, visibleSize.height - pbMargin, visibleSize.width - pbMargin*2, pbMargin ) );
	m_pbTravel->setProgress( m_travelProgess / m_travelDistance );
	addChild(m_pbTravel);

	//todo: remove listener on destructor
	EventBus::game()->addListener("GameEntityDeathEvt", this, callfuncO_selector(BattleManagerScreen::onEntityDeath));
	EventBus::game()->addListener("GameEntityLevelupEvt", this, callfuncO_selector(BattleManagerScreen::onEntityLevelup));
	EventBus::game()->addListener("GameEntityEffectEvt", this, callfuncO_selector(BattleManagerScreen::onEntityEffectEvent));
	
	
	CastWorldModel::get()->setPhysicsInterface(this);

	initPartyFromJson();


	spawnEnemy();

	scheduleUpdate();
	//setTouchEnabled(true);
    
    return true;
}
/**
 * 加载共有plist文件
 */
void LoadingLayer::loadYAllPng(CCObject* pSender)
{
    m_staticYloadIndex--;
    if (m_staticYPlist && m_staticYloadIndex >= 0)
    {
        const char* loadPngName = ((CCString* )m_staticYPlist->objectAtIndex(m_staticYloadIndex))->getCString();
        CCLog("loading加载plist:%s", loadPngName);
        CCTextureCache::sharedTextureCache()->addImageAsync(loadPngName, this, callfuncO_selector(LoadingLayer::imageCallBcakDelay));
    }
    if(m_staticYloadIndex < 0)
    {
        // 开启线程加载plist
        pthread_create(&pid, NULL, updateInfo, NULL);
    }
}
bool T_NoImage::init()
{
	if (!CCLayer::init())
	{
		return false;
	}
    
    // make depth tree
    Depth::AddCurDepth("T_NoImage", this);
    
    this->setTouchEnabled(true);
    this->setKeypadEnabled(true);
    this->setTouchPriority(Depth::GetCurPriority());
    CCLog("NoImage : touch prio = %d", this->getTouchPriority());
    
    // notification observer
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, callfuncO_selector(T_NoImage::Notification), Depth::GetCurName(), NULL);
    
    // notification post
    CCString* param = CCString::create("1");
    CCNotificationCenter::sharedNotificationCenter()->postNotification(Depth::GetParentName(), param);
    
    winSize = CCDirector::sharedDirector()->getWinSize();
    
    InitSprites();
    
    ttrArrow = CCSprite::create("images/tutorial/tutorial_arrow.png");
    ttrPos = CCScale9Sprite::create("images/tutorial/tutorial_position.png");
    
    // ccp(717+5, 711+offset) (offset = 0)
    ttrArrow->setAnchorPoint(ccp(0.5, 0));
    ttrArrow->setPosition(ccp(722+233/2, 711+115+10));
    CCActionInterval* action = CCSequence::create( CCMoveBy::create(0.5f, ccp(0, -5)), CCMoveBy::create(0.5f, ccp(0, 5)), NULL);
    ttrArrow->runAction(CCRepeatForever::create(action));
    this->addChild(ttrArrow, 101);
    
    ttrPos->setAnchorPoint(ccp(0, 0));
    ttrPos->setPosition(ccp(722, 711));
    //ttrPos->setScaleX( (float)233 / (float)782 );
    //ttrPos->setScaleY( (float)115 / (float)177 );
    ttrPos->setContentSize(CCSize(233-5, 110));
    this->addChild(ttrPos, 101);
    
    isEnded = false;
    isTouched = false;
    
    return true;
}
Exemple #23
0
void SndTest::onEnter()
{
    CCLayer::onEnter();
    
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
    makeBtn();
    
    playBGM();
    
    isNarrPlaying = false;
    
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
                                                                  callfuncO_selector(SndTest::onNarrationFinished),
                                                                  CJNOTIFICATION_VOICE_FINISHCALL,
                                                                  NULL);
}
Exemple #24
0
void CardShop::showSuccessAlert()
{
    if (m_dlgAlert == NULL)
    {
        m_dlgAlert = new Dialog1(this,
                                 callfuncO_selector(CardShop::cbAlertDlg),
                                 CGameData::Inst()->getLanguageValue("card_shop_tips_3"),
                                 false);
        addChild(m_dlgAlert, 100);
        m_dlgAlert->release();
    }
    
    m_dlgAlert->setPosition(CCPointMake(320, 480 - getPosition().y));
    m_dlgAlert->setScale(0.0);
    m_dlgAlert->runAction(CCScaleTo::actionWithDuration(0.2, 1.0));
}
void
MCSkillBarItem::intoColdTime()
{
    CCSprite *coldSprite = CCSprite::create(kMCColdTimeSkillIconFilepath);
    CCProgressTimer *progressTimer = CCProgressTimer::create(coldSprite);
    
    progressTimer->setReverseProgress(true);
    progressTimer->setAnchorPoint(CCPointZero);
    addChild(progressTimer);
    
    setOpacity(kMCSkillBarItemColdTimeOpacity);
    progressTimer->runAction(CCSequence::createWithTwoActions(CCProgressFromTo::create(skill_->coldTime, 100.f, 0.0f),
                                                              CCCallFuncO::create(this,
                                                                                  callfuncO_selector(MCSkillBarItem::coldTimeDidFinish),
                                                                                  progressTimer)));
}
bool CCDrawNode::init()
{
    m_sBlendFunc.src = CC_BLEND_SRC;
    m_sBlendFunc.dst = CC_BLEND_DST;

    setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionLengthTexureColor));
    
    ensureCapacity(512);
    
#if CC_TEXTURE_ATLAS_USE_VAO    
    glGenVertexArrays(1, &m_uVao);
    ccGLBindVAO(m_uVao);
#endif
    
    glGenBuffers(1, &m_uVbo);
    glBindBuffer(GL_ARRAY_BUFFER, m_uVbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(ccV2F_C4B_T2F)* m_uBufferCapacity, m_pBuffer, GL_STREAM_DRAW);
    
    glEnableVertexAttribArray(kCCVertexAttrib_Position);
    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, vertices));
    
    glEnableVertexAttribArray(kCCVertexAttrib_Color);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, colors));
    
    glEnableVertexAttribArray(kCCVertexAttrib_TexCoords);
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, texCoords));
    
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    
#if CC_TEXTURE_ATLAS_USE_VAO 
    ccGLBindVAO(0);
#endif
    
    CHECK_GL_ERROR_DEBUG();
    
    m_bDirty = true;

#if CC_ENABLE_CACHE_TEXTURE_DATA
    // Need to listen the event only when not use batchnode, because it will use VBO
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
            callfuncO_selector(CCDrawNode::listenBackToForeground),
            EVENT_COME_TO_FOREGROUND,
            NULL);
#endif

    return true;
}
bool DragonBattleRewardView::init(){
    bool ret = false;
    if(PopupBaseView::init()){
        setIsHDPanel(true);
        CCLoadSprite::doResourceByCommonIndex(502, true);
        setCleanFunction([](){
            CCLoadSprite::doResourceByCommonIndex(502, false);
        });
        auto node = CCBLoadFile("DragonBattleRewardView", this, this);
        this->setContentSize(node->getContentSize());
        
        int preHeight = this->m_viewBg->getContentSize().height;
        changeBGHeight(m_viewBg);
        m_viewBg->setVisible(false);
        int dh = m_viewBg->getContentSize().height - preHeight;
        if (CCCommonUtils::isIosAndroidPad()) {
            dh = CCDirector::sharedDirector()->getWinSize().height - 2048;
        }
        this->m_infoList->setContentSize(CCSize(m_infoList->getContentSize().width, m_infoList->getContentSize().height + dh));
        m_infoList->setPositionY(m_infoList->getPositionY()-dh);
        
        m_titleTxt->setString(_lang("140041"));
        m_data = CCArray::create();
        
        m_scrollView = CCScrollView::create(m_infoList->getContentSize());
        m_scrollView->setDirection(kCCScrollViewDirectionVertical);
        m_infoList->addChild(m_scrollView);
        m_scrollView->setVisible(false);
        
        for (int i=0; i<6; i++) {
            DragonRewardTitleCell* record = DragonRewardTitleCell::create(CCDictionary::create(), i,m_infoList);
            m_scrollView->addChild(record);
            m_data->addObject(record);
        }
        //updatePosition(0);
        
        DragonBattleRewardInfoCommand* cmd = new DragonBattleRewardInfoCommand();
        cmd->setSuccessCallback(CCCallFuncO::create(this, callfuncO_selector(DragonBattleRewardView::getServerData), NULL));
        cmd->sendAndRelease();
        
        m_waitInterface = GameController::getInstance()->showWaitInterface(m_infoList);
        m_waitInterface->setPosition(m_infoList->getContentSize().width/2, m_infoList->getContentSize().height/2);
        ret = true;
    }
    return ret;
}
/* 普通攻击 */
void
MCEnemy::attackTarget(MCRole *aTargetRole, CCObject *aTarget, SEL_CallFuncO aSelector, CCObject *anUserObject)
{
    if (! canAttackTarget(aTargetRole)) {
        attackDidFail();
        return;
    }
    
    MCRole::attackTarget(aTargetRole);
    ai_->lockState();
    
    /* 检测攻击距离 */
    MCRoleEntity *selfEntity = getEntity();
    MCOBB targetOBB = aTargetRole->getEntity()->getOBB();
    MCOBB selfOBB = selfEntity->getOBB();
    CCPoint offset = ccpSub(targetOBB.center, selfOBB.center);
    float distance = ccpLength(offset) / selfOBB.width - 1;
    
    if (distance > (float) distance_) { /* 太远了干不了,需要走过去 */
        target_ = aTarget;
        attackDidFinishSelector_ = aSelector;
        userObject_ = anUserObject;
        /* approachTargetAndKeepDistance版本不能保持距离和approachTarget效果一样,暂时放弃 */
//        selfEntity->approachTargetAndKeepDistance(aTarget,
//                                                  this,
//                                                  callfuncO_selector(MCHero::roleDidApproachTarget),
//                                                  aTarget,
//                                                  weapon->distance);
        selfEntity->approachTarget(aTargetRole,
                                   this,
                                   callfuncO_selector(MCRole::roleDidApproachTarget),
                                   aTargetRole);
        return;
    }
    /* 进入攻击判断 */
//    printf("进入攻击判断\n");
    pp_ -= consume_;
    MCDungeonMaster::sharedDungeonMaster()->roleAttackTarget(this, aTargetRole);
    ai_->unlockState();
    if (aTarget) {
        (aTarget->*aSelector)(anUserObject ? anUserObject : this);
    }
    target_ = NULL;
    attackDidFinishSelector_ = NULL;
    userObject_ = NULL;
}
BonusPanel::BonusPanel()
{
    m_commDlg = NULL;
    m_cntryDialog = NULL;
    
    m_lyPanel = CCLayer::node();
    addChild(m_lyPanel);
    
    CCSprite* spBg = CCSprite::spriteWithFile("bonuspanel.png");
    if (spBg) {
        m_lyPanel->addChild(spBg, -1);
        spBg->setAnchorPoint(ccp(0,1));
        spBg->setPosition(CCPointZero);
    }

    char buf[64];

    //元宝数
    long lGuildCoin = CGameData::Inst()->getGuildCoin();
    snprintf(buf, sizeof(buf), "%s:%ld", CGameData::Inst()->getLanguageValue("deadDlgtip6"), lGuildCoin);
    m_txtCoin = TextNode::textWithString(buf, 22);
    m_txtCoin->setPosition(CCPointMake(307, -34));
    m_txtCoin->setColor(ccBLACK);
    m_lyPanel->addChild(m_txtCoin);
    
    //成员、近5次伤害、上次伤害
    TextNode* txtMember = TextNode::textWithString(CGameData::Inst()->getLanguageValue("cntry_member_alone"), 22);
    txtMember->setPosition(CCPointMake(120, -70));
    txtMember->setColor(ccc3(93, 0, 4));
    m_lyPanel->addChild(txtMember);
    
    TextNode* txtRecentScore = TextNode::textWithString(CGameData::Inst()->getLanguageValue("jifeng_recentscore"), 22);
    txtRecentScore->setPosition(CCPointMake(270, -70));
    txtRecentScore->setColor(ccc3(93, 0, 4));
    m_lyPanel->addChild(txtRecentScore);
    
    TextNode* txtLastScore = TextNode::textWithString(CGameData::Inst()->getLanguageValue("jifeng_lastscore"), 22);
    txtLastScore->setPosition(CCPointMake(410, -70));
    txtLastScore->setColor(ccc3(93, 0, 4));
    m_lyPanel->addChild(txtLastScore);
    
    //列表
    m_pBonusList = new BonusList(this, callfuncO_selector(BonusPanel::cbBonusList));
    m_lyPanel->addChild(m_pBonusList);
    m_pBonusList->setPosition(CCPointZero);
}
//-------------------------------------------------------------------------
// 加载贴图
void FKAnimateExRes::_LoadTextureAsync( const char* szResName )
{
	string strPathName = CCFileUtils::sharedFileUtils()->fullPathForFilename( szResName );
	if( !m_SaxParser.init("UTF-8") )
		return;
	m_SaxParser.setDelegator( &m_SaxDelegator );
	if( !m_SaxParser.parse( strPathName.c_str() ) )
		return;

	vector<string>	vecPlists = m_SaxDelegator.m_vecPlists;
	for( unsigned int i = 0; i < vecPlists.size(); ++i )
	{
		string strFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(
			vecPlists[i].c_str(), strPathName.c_str() );
		CCDictionary *pDict = CCDictionary::createWithContentsOfFileThreadSafe( strFullPath.c_str() );
		if( pDict == NULL )
			continue;

		string strTexturePath("");
		CCDictionary* pMetadataDict = (CCDictionary*)pDict->objectForKey("metadata");
		if( pMetadataDict )
			strTexturePath = pMetadataDict->valueForKey("textureFileName")->getCString();

		if( !strTexturePath.empty() )
		{
			strTexturePath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile( 
				strTexturePath.c_str(), strPathName.c_str() );
		}
		else
		{
			strTexturePath = vecPlists[i].c_str();

			size_t unStartPos = strTexturePath.find_last_of(".");
			strTexturePath = strTexturePath.erase( unStartPos );

			strTexturePath = strTexturePath.append(".png");
		}

		pDict->release();

		m_mapTextureLoadInfo[strTexturePath] = false;
		CCTextureCache::sharedTextureCache()->addImageAsync(
			strTexturePath.c_str(),this, callfuncO_selector(FKAnimateExRes::_OnImageLoadOver) );
	}
}