Beispiel #1
0
void CSmeltArmor::initFire()
{
	//获取参考位置
	CCNode* pNode = (CCNode*)m_ui->findWidgetById("fire_circle");
	CCPoint pPos = ccp(pNode->getPositionX()+15, pNode->getPositionY()+75);

	if(m_pFire1 == nullptr)
	{
		CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9010");
		pAnimation->setDelayPerUnit(0.15f);
		m_pFire1 = CCSprite::create("skill/9010.png");
		m_pFire1->setPosition(pPos);
		m_pFire1->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
		m_pFire1->setVisible(false);
		m_pFire1->setScale(1.6f);
		pNode->getParent()->addChild(m_pFire1, pNode->getZOrder());
	}
	if(m_pFire2 == nullptr)
	{
		CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9011");
		pAnimation->setDelayPerUnit(0.15f);
		m_pFire2 = CCSprite::create("skill/9011.png");
		m_pFire2->setPosition(pPos);
		m_pFire2->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
		m_pFire2->setVisible(false);
		m_pFire2->setScale(1.5f);
		pNode->getParent()->addChild(m_pFire2, pNode->getZOrder());
	}
}
void HallPage::onSendGiftClicked()
{
    if(m_sendGiftDialog != 0){
        m_sendGiftDialog->destroy();
        m_sendGiftDialog = 0;
    }
    CCNode *root = this->getParent();
    while(root->getParent())
        root = root->getParent();
    if(m_sendGiftDialog == 0){
        m_sendGiftDialog = new SendGiftDialog(root,ccc4(0,0,0,128));
        m_sendGiftDialog->setCloseCB(this,callfuncND_selector(HallPage::onSendGiftCloseClicked));
        m_sendGiftDialog->setSendCB(this,callfuncND_selector(HallPage::onSendGiftSendClicked));
        std::string name = m_headNick;
        if(name.empty())
            mailToNickName(m_headMail,name);

        std::vector<UiMsgEv::GiftPropEv> props;
        m_serverIFace->getAllUnzeroProps(m_userId,props);
        std::sort(props.begin(),props.end(),prop_sortbyId);
        for(unsigned int i = 0;i < props.size();i++){
            m_sendGiftDialog->addProp(props[i].m_id,props[i].m_count);
        }
        m_sendGiftDialog->exec();
    }
}
void IPadSprite::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
	CCNode* pNode = this->getParent();
	CCNode* pNode1 = this;
	while(pNode->getParent() != NULL)
	{
		pNode1 = pNode;
		pNode = pNode->getParent();
	}
	MainScene* pScene = dynamic_cast<MainScene*>(pNode1);
	if(pScene)
	{
		pScene->hideMenu();
	}
	
	MS5Layer* pLayer = dynamic_cast<MS5Layer*>(this->getParent());
	if(pLayer)
		pLayer->hidePopupPanel();
		
	this->setIsVisible(false);
	pNode = this->getParent();
	pNode = pNode->getParent();
	
	if(pNode->getChildByTag(TAG_IPAD_BIG) == NULL)
	{
		ScaleSprite* pSprite = ScaleSprite::scaleSpriteWithFile("ipad_big.png");
		pSprite->setTag(TAG_IPAD_BIG);
		pSprite->setScale(0.24f);
		pSprite->setPosition( ccp(855, 420) );
		pNode->addChild(pSprite, 2);
		pSprite->startScale();
	}
} 
bool LsTouch::isParentAllVisible(LsTouchEvent* lsTe)
{
    bool bRef = true;
    CCNode* nLsTe = dynamic_cast<CCNode*>(lsTe);
    CCNode* parent = getParent();
    do
    {
        if (!parent)
        {
            bRef = false;
            break;
        }
        if (nLsTe == parent)
        {
            break;
        }
        if (!parent->isVisible())
        {
            bRef = false;
            break;
        }
        parent = parent->getParent();
    } while (1);

    return bRef;
}
Beispiel #5
0
bool NewMenuDevice::ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event) {
    //    CCPoint pouchT = map->transScreenToMap(ccp(pTouch->locationInView().x,pTouch->locationInView().y));
    //    CCPoint posiT = map->transMapToTiled(this->getPosition());
    //        
    //    CCPoint tiled = map->transMapToTiled(pouchT);
    //    if(Mathlib::inBound(tiled.x, posiT.x+contentSizeByTiled.width/2, posiT.x-contentSizeByTiled.width/2) &&
    //           Mathlib::inBound(tiled.y, posiT.y+contentSizeByTiled.height/2, posiT.y-contentSizeByTiled.height/2)) {
    //        isMoved = true;
    //    }
    //    return CCMenu::ccTouchBegan(pTouch, pEvent);
    
    CC_UNUSED_PARAM(event);
    if (m_eState != kCCMenuStateWaiting || ! m_bVisible || !isEnabled())
    {
        return false;
    }
    
    for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
    {
        if (c->isVisible() == false)
        {
            return false;
        }
    }
    
    m_pSelectedItem = this->itemForTouch(touch);
    if (m_pSelectedItem)
    {
        m_eState = kCCMenuStateTrackingTouch;
        m_pSelectedItem->selected();
        return true;
    }
    return false;
    
}
Beispiel #6
0
bool GameMenu::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
	/// 把传进来的这个参数强转下,免得编译器报参数未使用的警告。
	CC_UNUSED_PARAM(pEvent);  
	if (m_eState != kCCMenuStateWaiting || ! m_bIsVisible)  
	{  
		return false;  
	}  

	for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())  
	{  
		if (c->getIsVisible() == false)  
		{  
			return false;  
		}  
	}  

	m_pSelectedItem = this->itemForTouch(pTouch);  
	if (m_pSelectedItem)  
	{  
		m_eState = kCCMenuStateTrackingTouch;  
		m_pSelectedItem->selected();  
		///这里加入自己想要的效果。。。。。。。。。。。。。。。。  
		return true;  
	}  
	return false;  
}
Beispiel #7
0
CCObject *HTouchEnabledLayerColor::dismissNodeEx(int command, HEndDismissNode *notify) {
    CCNode *node = notify->getNode();
    do {
        if (node->getParent() != this) break;
        HBakNodeInfo *info = NULL;
        for (int i = m_pBakNodeList->count() - 1; i >= 0; --i) {
            info = (HBakNodeInfo *)m_pBakNodeList->objectAtIndex(i);
            if (node == info->m_pNode) {
                break;
            }
            info = NULL;
        }
        if (!info) break;
        
        node->retain();
        node->removeFromParentAndCleanup(false);
        info->m_pParent->addChild(node, info->m_iIndex);
        node->setScaleX(info->m_fScaleX);
        node->setScaleY(info->m_fScaleY);
        node->setPosition(info->m_ptPos);
        node->release();
        
        restoreAllPriorities(info);
        m_pBakNodeList->removeObject(info);
    } while (false);
    if (notify->getTarget() && notify->getAction()) {
        (notify->getTarget()->*notify->getAction())(node);
    }
    return NULL;
}
Beispiel #8
0
CCRect LotteryRotateView::getViewRect()
{
    CCSize size = getPanelChild()->getContentSize();
    CCPoint screenPos = this->convertToWorldSpace(CCPointZero);
    
    float scaleX = this->getScaleX();
    float scaleY = this->getScaleY();
    
    for (CCNode *p = _parent; p != NULL; p = p->getParent()) {
        scaleX *= p->getScaleX();
        scaleY *= p->getScaleY();
    }
    
    if(scaleX<0.f) {
        screenPos.x += size.width*scaleX;
        scaleX = -scaleX;
    }
    
    if(scaleY<0.f) {
        screenPos.y += size.height*scaleY;
        scaleY = -scaleY;
    }

    return CCRectMake(getPanelChild()->getPositionX() - size.width/2, getPanelChild()->getPositionY() - size.height/2, size.width, size.height);
}
Beispiel #9
0
bool MDragDownView::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    if (isVisible() == false)
    {
        return false;
    }
    
    for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
    {
        if (c->isVisible() == false)
        {
            return false;
        }
    }

    updateRect();
    m_touchBeginPosition = pTouch->getLocation();
    
    if (m_viewRect.containsPoint(m_touchBeginPosition) == false)
    {
        return false;
    }
    
    
    if (m_eState != State::NONE)
    {
        return true;
    }
    
    m_isTouchDragBar = m_pDragBar ? m_dragBarRect.containsPoint(m_touchBeginPosition) : false;
    m_viewOldSize = m_viewSize;
    
    return true;
}
Beispiel #10
0
	bool CCMenu::ccTouchBegan(CCTouch* touch, CCEvent* event)
	{
        CC_UNUSED_PARAM(event);
		if (m_eState != kCCMenuStateWaiting || ! m_bIsVisible)
		{
			return false;
		}

		for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
		{
			if (c->getIsVisible() == false)
			{
				return false;
			}
		}

		m_pSelectedItem = this->itemForTouch(touch);
		if (m_pSelectedItem)
		{
			m_eState = kCCMenuStateTrackingTouch;
			m_pSelectedItem->selected();
			return true;
		}
		return false;
	}
Beispiel #11
0
bool LsTouch::isParentAllVisible(LsTouchEvent* lsTe) {
	bool bRef = true;
	// 向父类转型,以便获取地址比较对象,LsTouchEvent 的对象必须同时直接或者简介继承 CCNode
	CCNode* nLsTe = dynamic_cast<CCNode*>(lsTe);

	CCNode* parent = getParent();
	do {
		// 如果遍历完毕,说明 LsTouch 不再 LsTouchEvent 之内
		if (!parent) {
			bRef = false;
			break;
		}
		// 如果 LsTouch 在 LsTouchEvent 之内,返回 true
		// 注意:如果想让LsTouchEvent 处理 不在其 CCNode 结构之内的元素,则取消此处判断
		if (nLsTe == parent) {
			break;
		}
		if (!parent->isVisible()) {
			bRef = false;
			break;
		}
		parent = parent->getParent();
	} while (1);
	return bRef;
}
void HallPage::onAddFriendClicked()
{
    if(m_sendGiftDialog != 0){
        m_sendGiftDialog->destroy();
        m_sendGiftDialog = 0;
    }
    CCNode *root = this->getParent();
    while(root->getParent())
        root = root->getParent();
    if(m_addFriendDialog == 0){
        m_addFriendDialog = new AddFriendDialog(root,ccc4(0,0,0,128));
        m_addFriendDialog->setCloseCB(this,callfuncND_selector(HallPage::onAddFriendCloseClicked));
        m_addFriendDialog->setAddCB(this,callfuncND_selector(HallPage::onAddFriendAddClicked));
        m_addFriendDialog->setAddId(m_headId);
        m_addFriendDialog->exec();
    }
}
Beispiel #13
0
CCAffineTransform CCNode::nodeToWorldTransform()
{
	CCAffineTransform t = this->nodeToParentTransform();

	for (CCNode *p = m_pParent; p != NULL; p = p->getParent())
		t = CCAffineTransformConcat(t, p->nodeToParentTransform());

	return t;
}
void MoveLeft::update(float delta){
    CCNode* parent = (CCNode*)getOwner();
    if (parent == NULL) return;
    
    if ( ((HelloWorld*)parent->getParent())->GameOver )
    {
        parent->stopAllActions();
    }
}
void HallPage::onSendMsgSendClicked(CCNode *node,void *data)
{
    SoundMgr::getInstance()->playEffect(SoundEnum::BTN_EFFECT_NORMAL);
    if(m_sendMsgDialog){
        std::string title,word;
        m_sendMsgDialog->getSendMsg(title,word);
        m_sendMsgDialog->destroy();
        m_sendMsgDialog = 0;
        if(word.size() != 0){
            ServerInterface::getInstance()->sendMail(m_headId,title,word);
            CCNode *root = this->getParent();
            while(root->getParent())
                root = root->getParent();
            CCSize winSize = CCDirector::sharedDirector()->getWinSize();
            SendMsgAnim *anim = new SendMsgAnim(root,ccp(winSize.width / 2,winSize.height / 2));
            anim->exec();
        }
    }
}
void AskFriendWidget::touchReleaseEvent(CCTouch *pTouch, CCEvent *pEvent)
{
    SoundMgr::getInstance()->playEffect(SoundEnum::BTN_EFFECT_NORMAL);
    if(!m_has){
        CCNode *root = this->getParent();
        while(root->getParent())
            root = root->getParent();
        if(m_addDialog == 0){
            m_addDialog = new AddFriendDialog(root,ccc4(0,0,0,128));
            m_addDialog->setCloseCB(this,callfuncND_selector(AskFriendWidget::onAddFriendCloseClicked));
            m_addDialog->setAddCB(this,callfuncND_selector(AskFriendWidget::onAddFriendAddClicked));
            m_addDialog->exec();
        }
        return;
    }
    UiMsgEv::AskFriendInfo *info = m_serverIface->getAskFriendInfo();
    CCNode *root = this->getParent();
    while(root->getParent())
        root = root->getParent();
    if(m_askDialog != 0){
        m_askDialog->destroy();
        m_askDialog = 0;
    }

    m_askDialog = new AskAsFriendDialog(root,ccc4(0,0,0,128));
    m_askDialog->setCloseCB(this,callfuncND_selector(AskFriendWidget::onAskDialogCloseClicked));
    m_askDialog->setOkCB(this,callfuncND_selector(AskFriendWidget::onAskDialogOkClicked));
    m_askDialog->setRejectCB(this,callfuncND_selector(AskFriendWidget::onAskDialogRejectClicked));
    std::string nick = info->m_friendNick;
    if(nick.empty()){
        mailToNickName(info->m_friendMail,nick);
    }
    std::string *head;
    if(m_serverIface->getHeadPortrait(info->m_friendId,&head)){
        m_askDialog->setAskInfo(info->m_friendId,nick,info->m_askWord,*head);
    }else{
        m_askDialog->setAskInfo(info->m_friendId,nick,info->m_askWord,"");
    }
    m_askDialog->exec();
    if(!m_serverIface->hasUnreadAskFriend()){
        askFriendUpdated();
    }
}
void HallPage::onAddFriendAddClicked(CCNode *node,void *data)
{
    SoundMgr::getInstance()->playEffect(SoundEnum::BTN_EFFECT_NORMAL);
    if(m_addFriendDialog != 0){
        std::string id,word;
        m_addFriendDialog->getAskInfo(id,word);
        m_addFriendDialog->destroy();
        m_addFriendDialog = 0;
        if(!id.empty()){
            m_serverIFace->addFriend(id,word);
            CCNode *root = this->getParent();
            while(root->getParent())
                root = root->getParent();
            CCSize winSize = CCDirector::sharedDirector()->getWinSize();
            SendMsgAnim *anim = new SendMsgAnim(root,ccp(winSize.width / 2,winSize.height / 2));
            anim->exec();
        }
    }
}
Beispiel #18
0
void CWidget::interruptTouchCascade(CCTouch* pTouch, float fDuration)
{
	for(CCNode* pNode = (CCNode*)m_pThisObject; pNode != NULL; pNode = pNode->getParent())
	{
		CWidget* pWidgetParent = dynamic_cast<CWidget*>(pNode);
		if( pWidgetParent != NULL )
		{
			pWidgetParent->interruptTouch(pTouch, fDuration);
		}
	}
}
Beispiel #19
0
// remove objects
void LCWordCloudLayer::removeAll()
{
	for (int i=0; i<m_pNodeArray->count(); i++) {
		CCNode* node = (CCNode*) m_pNodeArray->objectAtIndex(i);
		if (node->getParent()) {
			node->removeFromParentAndCleanup(true);
		}
	}
	this->m_pNodeArray->removeAllObjects();
	this->resetNodesPosition();
}
Beispiel #20
0
void CCWidget::interruptTouchCascade(CCTouch* pTouch, float fDuration)
{
	for(CCNode* pNode = m_pWidgetNode; pNode != NULL; pNode = pNode->getParent())
	{
		CCWidget* pWidgetParent = dynamic_cast<CCWidget*>(pNode);
		if( pWidgetParent )
		{
			pWidgetParent->interruptTouch(pTouch, fDuration);
		}
	}
}
Beispiel #21
0
bool Component::hasVisibleParents()
{
    CCNode* pParent = this->getParent();
    for( CCNode *c = pParent; c != NULL; c = c->getParent() )
    {
        if( !c->isVisible() )
        {
            return false;
        }
    }
    return true;
}
Beispiel #22
0
void CWidget::setLongClickTouchHandlerWidget(CCNode* pWidget, int id)
{
	for(CCNode* pNode = (CCNode*)m_pThisObject; pNode != NULL; pNode = pNode->getParent())
	{
		CWidgetWindow* pWidgetWindow = dynamic_cast<CWidgetWindow*>(pNode);
		if( pWidgetWindow != NULL )
		{
			pWidgetWindow->setLongClickTouchHandlerWidget(pWidget, id);
			return;
		}
	}
}
void HallPage::onSendGiftSendClicked(CCNode *node,void *data)
{
    SoundMgr::getInstance()->playEffect(SoundEnum::BTN_EFFECT_NORMAL);
    std::vector<UiMsgEv::GiftPropEv> gifts;
    std::string word;
    if(m_sendGiftDialog){
        m_sendGiftDialog->getSendProp(gifts,word);
        m_sendGiftDialog->destroy();
        m_sendGiftDialog = 0;
        if(word.empty() && gifts.size() == 0)
            return;
        ServerInterface::getInstance()->sendGift(m_headId,word,gifts);
        CCNode *root = this->getParent();
        while(root->getParent())
            root = root->getParent();
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        SendMsgAnim *anim = new SendMsgAnim(root,ccp(winSize.width / 2,winSize.height / 2));
        anim->setTheme("default","uigiftsending");
        anim->exec();
    }
}
Beispiel #24
0
void CCWidget::setLongClickTouchHandlerWidget(CCNode* pWidget)
{
	for(CCNode* pNode = m_pWidgetNode; pNode != NULL; pNode = pNode->getParent())
	{
		CCWidgetLayout* pWidgetLayoutParent = dynamic_cast<CCWidgetLayout*>(pNode);
		if( pWidgetLayoutParent )
		{
			pWidgetLayoutParent->setLongClickTouchHandlerWidget(pWidget);
			return;
		}
	}
}
void HallPage::onHallMascotClicked(CCNode *node,void *data)
{
    // disable hall chat/feedback input box
    ServerInterface::getInstance()->headSettingClosed(false);
    SoundMgr::getInstance()->playEffect(SoundEnum::BTN_EFFECT_NORMAL);
    int index = *(int*)data;
    if(index == 0){
        CCNode *root = this->getParent();
        while(root->getParent())
            root = root->getParent();
        m_shopPage = new ShopPage(root,ccc4(0,0,0,64));
        m_shopPage->setCloseCB(this,callfuncND_selector(HallPage::onShopPageCloseClicked));
        m_shopPage->exec();
    }else if(index == 1){
        CCNode *root = this->getParent();
        while(root->getParent())
            root = root->getParent();
        m_sysPage = new SysPage(root,ccc4(0,0,0,64));
        m_sysPage->setCloseCB(this,callfuncND_selector(HallPage::onSysPageCloseClicked));
        m_sysPage->exec();
    }else if(index == 2){
        //social page
        CCNode *root = this->getParent();
        while(root->getParent())
            root = root->getParent();
        m_socialPage = new SocialPage(root,ccc4(0,0,0,128));
        m_socialPage->setCloseCB(this,callfuncND_selector(HallPage::onSocialPageCloseClicked));
        m_socialPage->exec();
    }
}
void HallPage::onSendMsgClicked()
{
    if(m_sendMsgDialog != 0){
        m_sendMsgDialog->destroy();
        m_sendMsgDialog = 0;
    }
    CCNode *root = this->getParent();
    while(root->getParent())
        root = root->getParent();
    if(m_sendMsgDialog == 0){
        m_sendMsgDialog = new SendMsgDialog(root,ccc4(0,0,0,128));
        m_sendMsgDialog->setCloseCB(this,callfuncND_selector(HallPage::onSendMsgCloseClicked));
        m_sendMsgDialog->setSendCB(this,callfuncND_selector(HallPage::onSendMsgSendClicked));
        m_sendMsgDialog->setInitShowPage(true);
        m_sendMsgDialog->setInitPage(true,false);
        std::string name = m_headNick;
        if(name.empty())
            mailToNickName(m_headMail,name);
        m_sendMsgDialog->setRecInfo(m_headId,name,"");
        m_sendMsgDialog->exec();
    }
}
Beispiel #27
0
	void UIScrollLayer::ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent)
	{
		// Òƶ¯
		CCPoint touchPoint = CCDirector::sharedDirector()->convertToGL(pTouch->getLocationInView());

		if(!touchIsInContent(touchPoint) || !m_bVisible)
		{
			return;
		}		

		for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
		{
			if (c->isVisible() == false)
			{
				return;
			}
		}

		CCPoint ptbaselayer = m_baseLayer->getPosition();

		if (m_ScrollDir == ESD_Horizontal)
		{
			CCPoint posPoint = CCPointMake(m_baseLayer->getPosition().x + touchPoint.x - m_TouchCurPoint.x, ptbaselayer.y);

			if(abs(touchPoint.x - m_TouchCurPoint.x) > TOUCH_DELTA)
			{
				m_bShouldStolenTouch = true;
			}
			if(abs(touchPoint.x - m_TouchDownPoint.x) > MIN_MOVE_DELTA)
			{
				m_baseLayer->setPosition(posPoint);
			}
		}
		else
		{
			CCPoint posPoint = CCPointMake(ptbaselayer.x, m_baseLayer->getPosition().y + touchPoint.y - m_TouchCurPoint.y);

			if(abs(touchPoint.y - m_TouchCurPoint.y) > TOUCH_DELTA)
			{
				m_bShouldStolenTouch = true;
			}
			if(abs(touchPoint.y - m_TouchDownPoint.y) > MIN_MOVE_DELTA)
			{
				m_baseLayer->setPosition(posPoint);
			}
		}
    
		m_TouchCurPoint = touchPoint;
		m_ScrollStatus = ESS_DRAGGING;
	}
Beispiel #28
0
void PopupLayer::buttonCallback(cocos2d::CCObject *pSender){
    CCNode* node = dynamic_cast<CCNode*>(pSender);
	int tag = node->getTag();
	//quit
	if(tag == 40)
	{
		#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
			MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
			return;
		#endif

			Director::getInstance()->end();

		#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
			exit(0);
		#endif
	}
	//resume
	else if (tag == 41)
	{
		node->getParent()->getParent()->getParent()->resume();
	}
	//restart
	else if(tag == 42)
	{
		GameMain::score = 0;
		GameMain::gravity = 0;
		ui::TextAtlas* score_lbl = (ui::TextAtlas*)(node->getParent()->getParent()->getParent()->getChildByTag(1)->getChildByTag(5)->getChildByTag(2));
		String* s = String::createWithFormat("%d", GameMain::score*5);
		score_lbl->setStringValue(s->getCString());
		ui::LoadingBar* score_bar = (ui::LoadingBar* )(node->getParent()->getParent()->getParent()->getChildByTag(1)->getChildByTag(5)->getChildByTag(1));
		score_bar->setPercent(GameMain::score*5);
		node->getParent()->getParent()->getParent()->resume();
	}
	//next
	else if (tag == 43)
	{
		GameMain::score = 0;
		GameMain::gravity = 0;
		ui::TextAtlas* score_lbl = (ui::TextAtlas*)(node->getParent()->getParent()->getParent()->getChildByTag(1)->getChildByTag(5)->getChildByTag(2));
		String* s = String::createWithFormat("%d", GameMain::score*5);
		score_lbl->setStringValue(s->getCString());
		GameMain::page+=2;
		ui::LoadingBar* score_bar = (ui::LoadingBar* )(node->getParent()->getParent()->getParent()->getChildByTag(1)->getChildByTag(5)->getChildByTag(1));
		score_bar->setPercent(GameMain::score*5);
		node->getParent()->getParent()->getParent()->resume();
	}
    this->removeFromParent();
}
Beispiel #29
0
void MDragDownView::updateRect()
{
    CCPoint worldPosition = this->convertToWorldSpace(CCPointZero);
    
    float fScaleX = this->getScaleX();
    float fScaleY = this->getScaleY();
    
    for (CCNode *p = m_pParent; p != NULL; p = p->getParent())
    {
        fScaleX *= p->getScaleX();
        fScaleY *= p->getScaleY();
    }
    
    if(fScaleX < 0.f)
    {
        worldPosition.x += m_viewSize.width * fScaleX;
        fScaleX = -fScaleX;
    }
    if(fScaleY < 0.f)
    {
        worldPosition.y += m_viewSize.height * fScaleY;
        fScaleY = -fScaleY;
    }
    
    m_viewRect.setRect(worldPosition.x,
                       worldPosition.y + (m_fViewMaxHeight - m_viewSize.height) * fScaleY,
                       m_viewSize.width * fScaleX,
                       m_viewSize.height * fScaleY);
    
    if (m_pDragBar)
    {
        auto dragSize = m_pDragBar->getContentSize();
        auto dragFixSize = CCSizeMake(dragSize.width * m_pDragBar->getScaleX() * fScaleX,
                                      dragSize.height * m_pDragBar->getScaleY() * fScaleY);
        float fWidth = dragFixSize.width < m_viewRect.size.width ? dragFixSize.width : m_viewRect.size.width;
        float fHeight = dragFixSize.height < m_viewRect.size.height ? dragFixSize.height : m_viewRect.size.height;
        m_dragBarRect.setRect(m_viewRect.origin.x + (m_viewRect.size.width-fWidth)*0.5,
                              m_viewRect.origin.y, fWidth, fHeight);
    }
    /*
    CCLog("[%.0f, %.0f, %.0f, %.0f], [%.0f, %.0f, %.0f, %.0f]",
          m_viewRect.origin.x, m_viewRect.origin.y,
          m_viewRect.size.width, m_viewRect.size.height,
          m_dragBarRect.origin.x, m_dragBarRect.origin.y,
          m_dragBarRect.size.width, m_dragBarRect.size.height);//*/
}
Beispiel #30
0
bool MyMenu::ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event) {
    if (isActive) {
        cacheTouch  = map->transMapToTiled(map->convertToNodeSpace(touch->getLocation()));
        if (CCMenu::ccTouchBegan(touch, event)) {
//            if (m_pSelectedItem->getTag() == myTiledMenuItemTag) {
//                moveEnabled = true;
//                isMoved = false;
//                //TODO
////                ((MyMap*)map)->moveTemp = this;
//                MyMenu::reorderZandTouchPriority(1000000, -499);
//            } else {
////                ((MyMap*)map)->moveTemp = this;
//                moveEnabled = false;
//                isMoved = false;
//            }
            return true;
        }
        return false;
    }
    if (((MyMap*)map)->isBuild()) {
        return false;
    }
    CC_UNUSED_PARAM(event);
    if (m_eState != kCCMenuStateWaiting || ! m_bVisible || !isEnabled())
    {
        return false;
    }
    
    for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
    {
        if (c->isVisible() == false)
        {
            return false;
        }
    }
    
    m_pSelectedItem = this->itemForTouch(touch);
    if (m_pSelectedItem)
    {
        m_eState = kCCMenuStateTrackingTouch;
        m_pSelectedItem->selected();
        return true;
    }
    return false;

}