Пример #1
0
void Item::itemTouchEnded() {

    isInTouch=false;
    
    isInMove=false;
    
    
    if ( !afterLongPress &&(millisecondNow()-touchBeginTime)<200) {
        this->unschedule(schedule_selector(Item::checkLongPress));
        if ( m_bClicked ) {
             m_bClicked = false;
              this->doubleClickSprite();
        }
        else
        {
            scheduleOnce(schedule_selector(Item::singleClickSprite), 0.2f);
            m_bClicked = true;
            return;
        }
    }
    //     恢复 精灵

//    this->setScale(1);
//
//    this->setPosition(orignalPoint);
//    
//    this->setOpacity(255);
}
Пример #2
0
void WallSingleScene::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent){
	CCTouch* pTouch = (CCTouch*)pTouches->anyObject();
	long endTime = millisecondNow();
	float length = ccpDistance(prePoint,pTouch->getLocation());

	if (endTime-beginTime < 1000 && length <= 50)
	{
		//single click
		CCPoint touchpoint = pTouch->getLocation();
		for (vector<CHanziManage>::iterator iter = hanzilist.begin();iter!=hanzilist.end();++iter)
		{
			CCPoint hanziPos = iter->pos;
			//CCLog("hanziPos %f %f",hanziPos.x,hanziPos.y);
			CCPoint realPos = ccp(hanziPos.x+changepoint.x,hanziPos.y+changepoint.y);
			//CCLog("hanziPos %f %f",hanziPos.x,hanziPos.y);
			CCRect rect = CCRectMake(realPos.x-100,realPos.y-100,200,200);
			//在字周围200像素内,判断为点中
			if (rect.containsPoint(touchpoint))
			{
                CCLog("current %s", iter->character.c_str());

				this->singleClick(iter->character);
				return;
			}
		}
	}

	touched=false;
	isMoved = false;
	selectedHanzi = "";

	//解除定时器
	CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(WallSingleScene::longPressUpdate),this);
}
Пример #3
0
void ComboLayer::update(float time)
{
	switch(m_comboState)
	{
	case NONO_COMBO:
		if(m_comboNumber > 0)
		{
			comboComeIn();
		}
		break;
	case COMBO_SHOWING:
		long long currentTime = millisecondNow();
		if(currentTime - m_lastHitTime > 2000)
		{
			// ʱ¼ä 
			this->comboComeOut();
		}
		else
		{
			if(m_comboNumber != m_comboShow)
			{
				updateComboNum();
			}
		}
		break;
	}
}
Пример #4
0
void WallSingleScene::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent){
	CCLog("Touches Began~~~");
	CCTouch* pTouch = (CCTouch*)pTouches->anyObject();

	touchbeginpoint = ccp(pTouch->getLocation().x , pTouch->getLocation().y);
	prePoint = touchbeginpoint;
	touched=true;

	beginTime = millisecondNow();
	//定时器,直接使用scheduleUpdate无效
	//this->scheduleUpdate();
	CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(WallSingleScene::longPressUpdate),this,1.5f,false);
	for (vector<CHanziManage>::iterator iter = hanzilist.begin();iter!=hanzilist.end();++iter)
	{
		CCPoint hanziPos = iter->pos;
		//CCLog("hanziPos %f %f",hanziPos.x,hanziPos.y);
		CCPoint realPos = ccp(hanziPos.x+changepoint.x,hanziPos.y+changepoint.y);
		//CCLog("hanziPos %f %f",hanziPos.x,hanziPos.y);
		CCRect rect = CCRectMake(realPos.x-100,realPos.y-100,200,200);

		if (rect.containsPoint(touchbeginpoint))
		{
			selectedHanzi = iter->character;
			selectedCHanziManageIter = iter;
		}
	}

}
Пример #5
0
bool Item::itemTouchBegan(){
    // CCLOG("item touch began:%d",getTag());
    
        isInTouch=true;
       afterLongPress=false;
      this->touchBeginTime=millisecondNow();
      this->unschedule(schedule_selector(Item::checkLongPress));
      this->scheduleOnce(schedule_selector(Item::checkLongPress), 2);

}
void EquipmentUpgradeUILayer::updateColdTime(float value)
{
	if(m_coldTime > 0)
	{
		long long currentTime = millisecondNow();
		long long deltaTime = (currentTime - m_laststengthTime)/1000;
		unsigned int time = (deltaTime > m_coldTime ) ?  0 : (m_coldTime - deltaTime);
		showColdTime(time);
	}
}
Пример #7
0
void ComboLayer::HandleComboIncrease(unsigned int incremental)
{
	m_comboNumber += incremental;
	m_lastHitTime = millisecondNow();

	switch(m_comboState)
	{
	case NONO_COMBO:
		comboComeIn();
		break;
	//case COMBO_SHOWING:
	//	updateComboNum();
	//	break;
	}
}
Пример #8
0
void QTELayer::onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event)
{
    if(!enableFight) return;
    Touch *touch = touches.at(0);
    Vec2 pos = touch->getLocation();
    //this->getChildByTag(111)->setPosition(Vec2(t->getLocation().x,t->getLocation().y));
    
    //star->setPosition(pos);
    streak->setPosition(pos);
    
    streak->reset();
    startTouchPosition = pos;
    
    currentTouchTime = millisecondNow();
}
Пример #9
0
 bool  Item:: isDoubleTouch(){
    

    
    long thisTouchTime=millisecondNow();
    long ti = abs(thisTouchTime-this->touchBeginTime);
    
    if(ti<500){
        

        
        return true;
        
    }else{
        
     //   lastTouchTime=millisecondNow();
        
        return false;
        
    }
    
}
void EquipmentUpgradeUILayer::successToStrength(unsigned int pos,unsigned int coldTime)
{
	GameAudioManager::sharedManager()->playEffect(350006,false);
	m_coldTime = coldTime;
	m_laststengthTime = millisecondNow();
	BackPackItem* item = ItemManager::Get()->findItemByPos(pos);
	playUpgradeEffect();
	bool bHeroEquip = true;
	unsigned int index = pos;
	if(index >= kItemFairyEquip)
	{
		bHeroEquip = false; 
		index -= kItemFairyEquip;
	}
	else
	{
		index -= kItemHeroEquip;
	}

	if(m_equipLayoutIndex == bHeroEquip && m_choosedEquipIndex == index)
	{
		if(item)
		{
			showColdTime(m_coldTime);
			showCurrentLevel(item->itemLevel);

			showSingleEquip(pos,index);
			if(item->m_attribution)
			{
				std::list<ITEMATTR*>::iterator it = item->m_attribution->begin();
				if(it != item->m_attribution->end())
				{
					ITEMATTR* attr = *it;
					if(attr)
					{
						showCurrentAttribute(attr->attr_key,attr->attr_basic_value,attr->attr_intensify_value);
					}
					if(++it != item->m_attribution->end())
					{
						attr = *it;
						showSecondAttribute(attr->attr_key,attr->attr_basic_value,attr->attr_intensify_value);
					}
					else
					{
						showSecondAttributeLabel("");
					}
				}

			}
			if(item->m_equipInfo)
			{
				std::list<EQUIPNEXTATTR>::iterator it = item->m_equipInfo->m_nextAttribution.begin();
				if(it != item->m_equipInfo->m_nextAttribution.end())
				{
					EQUIPNEXTATTR attr = *it;
					showNextLevelAttribution(attr.key,attr.value);
				}
				if(++it != item->m_equipInfo->m_nextAttribution.end())
				{
					EQUIPNEXTATTR attr = *it;
					showSecondNextLevelAttribution(attr.key,attr.value);
				}
				else
				{
					showSecondNextLevelAttributionLabel("");
				}
				showLevelUpCost(item->m_equipInfo->levelUpCost);
			}
		}
		
	}
}
void EquipmentUpgradeUILayer::setUpgradeColdTime(unsigned int value)
{
	m_coldTime = value;
	m_laststengthTime = millisecondNow();
	showColdTime(m_coldTime);
}
void HelloWorld::BeginContact(b2Contact *contact){
	B2Sprite *p = (B2Sprite *)contact->GetFixtureA()->GetBody()->GetUserData();
	if(p->getTag()==SPRITE_TAG_GROUND)
	{
		CCDirector::sharedDirector()->getScheduler()->setTimeScale(1.f);
		//mBird->setRotation(-90.f);

		//CCMessageBox("Game Over!", "Game Over!");
		//mBird->setVisible(false);
		this->runAction(CCShake::create(1,5));

		//std::string fullPath;
		//#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)  
		//fullPath = CCFileUtils::sharedFileUtils()->getWritablePath(); 
		//fullPath += "score.abc";

		//unsigned long size;
		//unsigned char *str = CCFileUtils::sharedFileUtils()->getFileData(fullPath,"wt+",&size);
		m_bnew=false;
		string filedata;
		filedata = TDInvFileUtils::getFileByName("score.abc");
		int filescore = 0;
		if (filedata != "")
		{
			filescore = atoi(filedata.c_str());
			if (filescore < testnum)
			{
				m_bnew=true;
				m_bestscore = testnum;
				char str[10];
				char   temp[256];   
				sprintf(str,"%d",testnum); 
				TDInvFileUtils::saveFile(str,"score.abc");
			}
			else
			{
				m_bestscore = filescore;
			}

		}
		else
		{
			m_bestscore = testnum;
			char str[10];
			sprintf(str,"%d",testnum); 
			TDInvFileUtils::saveFile(str,"score.abc");
		}



		//#else   

		//#endif  
		//Sleep(1000);
		if(!m_bhitbar)
		{
//			EFFECT_PLAY(true,MUSIC_HIT);
		}
		else
		{
//			EFFECT_PLAY(true,MUSIC_DIE);
		}
		stopGame();


	}
	if(p == mBird || p == mBird){
		CCScheduler* pScheduler = CCDirector::sharedDirector()->getScheduler();
		pScheduler->setTimeScale(0.f);//实现减速效果
		//scheduleOnce(schedule_selector(HelloWorld::ResumeSpeed), 1);
		long now=millisecondNow();

		while(false){
			if((millisecondNow()-now)>1000)
			{
				break;
			}
		};
		CCDirector::sharedDirector()->getScheduler()->setTimeScale(1.f);
		//CCDirector::sharedDirector()->getScheduler()->setTimeScale(0.2f);
		//mBird->getB2Body()->SetLinearVelocity(b2Vec2(0, -5));
		myflag=1;
		b2Filter myfilter;
		myfilter.maskBits=0x0002;
		mBird->getB2Body()->GetFixtureList()->SetFilterData(myfilter);
		m_istatus=GAMEOVER;
		m_bhitbar=true;
//		EFFECT_PLAY(true,MUSIC_HIT);
		//stopGame();
		// CCMessageBox("Game Over!", "Game Over!");
	}
}