本文整理汇总了C++中CCNode::boundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::boundingBox方法的具体用法?C++ CCNode::boundingBox怎么用?C++ CCNode::boundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::boundingBox方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ccTouchEnded
void GameScene::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent){
CCDirector* pDirector = CCDirector::sharedDirector();
CCPoint touchPoint = pDirector->convertToGL(pTouch->getLocationInView());
CCNode* pCard = this->getChildByTag(nextNumber);
if (!pCard)
{
return;
}
CCRect cardRect = pCard->boundingBox();
if (cardRect.containsPoint(touchPoint)) {
CCSprite* pNewCard = CCSprite::create("card_backside.png");
pNewCard->setPosition(pCard->getPosition());
this->addChild(pNewCard);
pCard->removeFromParentAndCleanup(true);
if (nextNumber >= 25)
{
this->unschedule(schedule_selector(GameScene::measureGametime));
showHighScoreLabel();
return;
}
nextNumber++;
}
//CCLog("x: %f, y:%f", touchPoint.x, touchPoint.y);
}
示例2: onTouchBegan
//-------------------------------------------------------------------------
ENUM_WidgetTouchModel FKCW_UIWidget_Layout::onTouchBegan(CCTouch* pTouch)
{
m_pSelectedWidget = NULL;
m_eSelectedWidgetTouchModel = eWidgetTouchNone;
CCPoint tNodePoint = convertToNodeSpace(pTouch->getLocation());
if( m_pChildren && m_pChildren->count() > 0 )
{
CCObject* pObject = NULL;
CCARRAY_FOREACH_REVERSE( m_pChildren, pObject )
{
CCNode* pNode = dynamic_cast<CCNode*>(pObject);
FKCW_UIWidget_Widget* pWidget = dynamic_cast<FKCW_UIWidget_Widget*>(pObject);
if( pWidget && pNode->isVisible() && pWidget->isEnabled() && pWidget->isTouchEnabled() )
{
if( pNode->boundingBox().containsPoint(tNodePoint) )
{
m_eSelectedWidgetTouchModel = pWidget->executeTouchBeganHandler(pTouch);
if( m_eSelectedWidgetTouchModel == eWidgetTouchNone )
{
m_pSelectedWidget = NULL;
m_eSelectedWidgetTouchModel = eWidgetTouchNone;
}
else
{
m_pSelectedWidget = pWidget;
return m_eSelectedWidgetTouchModel;
}
}
}
}
示例3: ccTouchBegan
bool CWidgetLayout::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
if( m_bTouchEnabled && m_bVisible && m_pChildren && m_pChildren->count() > 0 )
{
CCPoint touchPointInView = convertToNodeSpace(pTouch->getLocation());
if( m_pChildren && m_pChildren->count() > 0 )
{
CCObject* pObject = NULL;
CCARRAY_FOREACH_REVERSE( m_pChildren, pObject )
{
CCNode* pNode = dynamic_cast<CCNode*>(pObject);
CWidget* pWidget = dynamic_cast<CWidget*>(pObject);
if( pWidget && pNode->isVisible() && pWidget->isEnabled() && pWidget->isTouchEnabled() )
{
if( pNode->boundingBox().containsPoint(touchPointInView) )
{
if( pWidget->executeTouchBeganHandler(pTouch) != eWidgetTouchNone )
{
m_pSelectedWidget = pWidget;
m_bIsTouched = true;
m_fTouchedDuration = 0.0f;
return true;
}
}
}
}
示例4: touchMoved
KDvoid JewelController::touchMoved ( APSGraphic* pGraphic, const APSTouch& tTouch )
{
// calculate touched position in symbol
CCPoint tPosition = m_pSymbol->convertPositionFromParentNode ( tTouch.getPosition ( ) );
CCNode* pJewelNode = pGraphic->getNode ( );
// change jewel graphic node position to touched position.
pJewelNode->setPosition ( tPosition );
// get the rectangular box of jewel node
CCRect tJewelBox = pJewelNode->boundingBox ( );
// get the rectangular box of boy node.
CCRect tBoyBox = m_pBoyGraphic->getNode ( )->boundingBox ( );
// check intersection of the two boxes.
if ( tJewelBox.intersectsRect ( tBoyBox ) )
{
APSActionGroup* pShakeBoyAction = (APSActionGroup*) m_pSymbol->getResourceForTag ( "ShakeBoy" );
// trigger 'ShakeBoy' action group only if it is currently not running.
if ( !pShakeBoyAction->getRunning ( ) )
{
pShakeBoyAction->trigger ( );
}
}
}
示例5: onTouchClicked
void SecondScene::onTouchClicked(CCTouch *touch, CCEvent *event, CCPoint location)
{
CCLOGFUNC();
CCNode *image = this->getChildByTag(kTagSecondSceneImage);
if (image->boundingBox().containsPoint(location))
{
this->popScene();
}
}
示例6: update
void MainLayer::update(float delta)
{
if (!disappearing)
{
CCNode *left = this->getChildByTag(TAG_LEFT);
CCNode *right = this->getChildByTag(TAG_RIGHT);
if (left && right)
{
CCRect leftRect = left->boundingBox();
CCRect rightRect = right->boundingBox();
leftRect.size = leftRect.size * 0.85f;
rightRect.size = rightRect.size * 0.8f;
if (leftRect.intersectsRect(rightRect))
{
disappearing = true;
/*爆炸*/
playDropAnimation();
}
else if (left->getPosition().x > right->getPosition().x)
{
disappearing = true;
leftJumping = false;
rightJumping = false;
//计分
Counter *counter = Counter::sharedCounter();
(*counter)++;
this->reCreateNewRole();
// left->runAction(CCFadeOut::create(0.8f));
// right->runAction(
// CCSequence::createWithTwoActions(CCFadeOut::create(0.8f),
// CCCallFunc::create(this,
// callfunc_selector(
// MainLayer::reCreateNewRole))));
}
}
}
}
示例7: CCLOG
//check if any node is clicked.
CCNode *VEScrollView::touchCheck(CCPoint touchPoint)
{
CCArray *children = m_pContainer->getChildren();
if(children == NULL)
return NULL;
CCPoint np = m_pContainer->convertToNodeSpace(touchPoint);
for(int i=0; i<children->count(); i++)
{
CCNode *node = (CCNode*)children->objectAtIndex(i);
CCRect box = node->boundingBox();
if(node->boundingBox().containsPoint(np)) {
CCLOG("click node %d %p\n", i, node);
if (m_touchListener && m_touchHandler)
(m_touchListener->*m_touchHandler)(node);
return node;
}
}
return NULL;
}
示例8: getTouchBlockTag
void GameScene::getTouchBlockTag( CCPoint touchPoint, int &tag, kBlock &blockType )
{
for( int x = 0; x < MAX_BLOCK_X; x++ ) {
for ( int y = 0; y < MAX_BLOCK_Y; y++ ) {
int currentTag = getTag( x, y );
CCNode* node = m_background->getChildByTag( currentTag );
if ( node && node->boundingBox().containsPoint( touchPoint ) ) {
tag = currentTag;
blockType = ((BlockSprite*)node)->getBlockType();
return;
}
}
}
}
示例9: ccTouchMoved
void GameScene::ccTouchMoved(CCTouch* pTouch, CCEvent* pEvent)
{
CCLOG("ccTouchMoved");
CCPoint touchPoint = background->convertTouchToNodeSpace(pTouch);
TouchedBlock touched_block = getTouchedBlock(touchPoint);
if (currentTag != 0 && touchPoint.x >= (blockAreaStartPoint.x - blockSize / 2) && touchPoint.y >= (blockAreaStartPoint.y - blockSize / 2) && touchPoint.x <= (blockAreaEndPoint.x + blockSize / 2) && touchPoint.y <= (blockAreaEndPoint.y + blockSize / 2))
{
CCNode* tmp_current = background->getChildByTag(tmpCurrentTag);
tmp_current->setPosition(touchPoint);
if (previousTag != 0)
{
CCNode* previousBlock = background->getChildByTag(previousTag);
if (!previousBlock->boundingBox().containsPoint(touchPoint))
{
previousTag = 0;
}
}
if (touched_block.tag != 0 && touched_block.tag != previousTag)
{
previousTag = touched_block.tag;
CCNode* current = background->getChildByTag(currentTag);
CCNode* target = background->getChildByTag(touched_block.tag);
// ブロックを入れ替える
BlockFiledsPositionIndex target_position_idex = getBlockFieldsPositionIndex(touched_block.tag);
BlockFiledsPositionIndex current_position_idex = getBlockFieldsPositionIndex(currentTag);
blockFields[target_position_idex.x][target_position_idex.y] = (BlockSprite*)current;
blockFields[current_position_idex.x][current_position_idex.y] = (BlockSprite*)target;
CCPoint prePoint = getPosition(current_position_idex.x, current_position_idex.y);
current->setPosition(getPosition(target_position_idex.x, target_position_idex.y));
CCMoveTo* targetMove = CCMoveTo::create(0.2f, prePoint);
CCPlaySE* playSe = CCPlaySE::create(kSEMoveBlock);
CCFiniteTimeAction* moveAction = CCSpawn::create(targetMove, playSe, NULL);
target->runAction(moveAction);
}
}
}
示例10: isTouchForMe
bool SkillLayer::isTouchForMe(CCPoint touchLocation){
CCNode* node = this->getChildByTag(1);
CCRect rec = node->boundingBox();
return CCRect::CCRectContainsPoint(rec, touchLocation);
}