Exemple #1
0
void WelcomeScene::ccTouchesEnded(CCSet* touches,CCEvent* event){
	CCTouch* touch = (CCTouch*)touches->anyObject();
	CCPoint location = CCDirector::sharedDirector()->convertToGL(touch->getLocationInView());
	if(touchId != -1){
	for(int i = 0;i < itemsArray->count();i++){
		ShopItem* item = (ShopItem*)itemsArray->objectAtIndex(i);
		if(item->isTouch(location.x - scroll->getPositionX() - scroll->getContentOffset().x,
			location.y - scroll->getPositionY())){
				if(temp != NULL){
					temp->setSelected(false);
				}
				if(item->getId() == touchId){
					if(item->touchAction() == 0){
						createItems(item->getType(),scroll->getContentOffset().x);
						temp = NULL;
					}else{
						temp = item;
						char t[100];
						if(item->getValue() < 10){
							sprintf(t,"购买物品需要%d元人民币,点击右侧的买入按钮即可购买",item->getValue());
						}else{
							sprintf(t,"购买物品需要%d仙桃,点击右侧的买入按钮即可购买",item->getValue());
						}
						tipText->setString(conv(t));
						temp->setSelected(true);
					}
				}
				break;
		}
	}
	}
	touchId = -1;
}
Exemple #2
0
void WelcomeScene::ccTouchesBegan(CCSet* touches,CCEvent* event){
	CCTouch* touch = (CCTouch*)touches->anyObject();
	CCPoint location = CCDirector::sharedDirector()->convertToGL(touch->getLocationInView());

	for(int i = 0;i < itemsArray->count();i++){
		ShopItem* item = (ShopItem*)itemsArray->objectAtIndex(i);
		if(item->isTouch(location.x - scroll->getPositionX() - scroll->getContentOffset().x,
			location.y - scroll->getPositionY())){
				/*if(item->touchAction() == 0){
				createItems(item->getType());
				}*/
				touchId = item->getId();
				lastPt = ccp(location.x,location.y);
				break;
		}
	}

}