本文整理汇总了C++中CCMenuItem::convertToNodeSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItem::convertToNodeSpace方法的具体用法?C++ CCMenuItem::convertToNodeSpace怎么用?C++ CCMenuItem::convertToNodeSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItem
的用法示例。
在下文中一共展示了CCMenuItem::convertToNodeSpace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: itemForTouch
CCMenuItem* MyMenu::itemForTouch(CCTouch *touch) {
CCPoint touchLocation = touch->getLocationInView();
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
if (m_pChildren && m_pChildren->count() > 0)
{
CCObject* pObject = NULL;
CCARRAY_FOREACH(m_pChildren, pObject)
{
CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject);
if (pChild && pChild->isVisible() && ((CCMenuItem*)pChild)->isEnabled())
{
if (dynamic_cast<MyTiledMenuItemSprite*>(pChild) != NULL){
CCPoint posiT = map->transMapToTiled(this->getPosition());
CCPoint tiled = map->transMapToTiled(map->convertToNodeSpace(touchLocation));
if (contentSizeByTiled.width == 1 && contentSizeByTiled.height == 1) {
CCPoint local = pChild->convertToNodeSpace(touchLocation);
CCRect r = ((CCMenuItem*)pChild)->rect();
r.origin = CCPointZero;
if (r.containsPoint(local))
{
//物体碰撞系统参数,上面是地形碰撞系统
// ((MyMap*)map)->initTip(this->getPosition(), contentSizeByTiled.width);
// ((MyMap*)map)->cancelAllBuilding();
// ((MyMap*)map)->moveTemp = this;
cacheLoc = this->getPosition();
return (CCMenuItem*)pChild;
}
} else {
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)) {
cacheLoc = this->getPosition();
// ((MyMap*)map)->initTip(this->getPosition(), contentSizeByTiled.width);
// ((MyMap*)map)->cancelAllBuilding();
// ((MyMap*)map)->moveTemp = this;
return (CCMenuItem*)pChild;
}
}
} else {
CCPoint local = pChild->convertToNodeSpace(touchLocation);
CCRect r = ((CCMenuItem*)pChild)->rect();
r.origin = CCPointZero;
if (r.containsPoint(local))
{
//物体碰撞系统参数,上面是地形碰撞系统
//TODO
// ((MyMap*)map)->moveTemp = this;
cacheLoc = this->getPosition();
return (CCMenuItem*)pChild;
}
}
}
}
示例2: itemForTouchPM
CCMenuItem* CPullMachMenu::itemForTouchPM(CCTouch * touch)
{
CCPoint touchLocation = touch->getLocation();
if (m_pChildren && m_pChildren->count() > 0)
{
CCObject* pObject = NULL;
CCARRAY_FOREACH(m_pChildren, pObject)
{
CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject);
if (pChild && pChild->isVisible() && pChild->isEnabled())
{
CCPoint local = pChild->convertToNodeSpace(touchLocation);
CCRect r;
r.size = pChild->getContentSize();
r.origin.x = r.size.width * 0.2f;
r.size.width *= 0.6f;
r.origin.y = r.size.height * 0.2f;
r.size.height *= 0.8f;
if (r.containsPoint(local))
{
return pChild;
}
}
}
示例3: itemForTouch
CCMenuItem* NewMenuDevice::itemForTouch(CCTouch *touch) {
CCPoint touchLocation = touch->getLocationInView();
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
if (m_pChildren && m_pChildren->count() > 0)
{
CCObject* pObject = NULL;
CCARRAY_FOREACH(m_pChildren, pObject)
{
CCMenuItem* pChild = dynamic_cast<CCMenuItem*>(pObject);
if (pChild && pChild->isVisible() && ((CCMenuItem*)pChild)->isEnabled())
{
if (dynamic_cast<NewMenuSpriteItem*>(pChild) != NULL){
CCPoint posiT = parent->getMap()->transMapToTiled(this->getPosition());
CCPoint tiled = parent->getMap()->transMapToTiled(parent->getMap()->convertToNodeSpace(touchLocation));
// CCLog("posiTx:%f,posiTy:%f", posiT.x,posiT.y);
// CCLog("tiledX:%f,tiledY:%f", tiled.x,tiled.y);
// CCLog("pChildTiledSizeW:%f,pChildTiledSizeH:%f",pChildTiledSize.width,pChildTiledSize.height);
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;
cacheLoc = this->getPosition();
((NewCreateMap*)parent->getMap())->initTip(this->getPosition(), contentSizeByTiled.width);
((NewCreateMap*)parent->getMap())->moveTemp = this;
((NewCreateMap*)parent->getMap())->cancelAllBuilding();
return (CCMenuItem*)pChild;
}
} else {
CCPoint local = pChild->convertToNodeSpace(touchLocation);
CCRect r = ((CCMenuItem*)pChild)->rect();
r.origin = CCPointZero;
if (r.containsPoint(local))
{
return (CCMenuItem*)pChild;
}
}
}
}