当前位置: 首页>>代码示例>>C++>>正文


C++ CCMenuItem::convertToNodeSpace方法代码示例

本文整理汇总了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;
                    }
                }
            }
        }
开发者ID:itita,项目名称:2-z-q-x-,代码行数:53,代码来源:MyMenu.cpp

示例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;
				}
			}
		}
开发者ID:hantingmeixue,项目名称:Aoyi,代码行数:26,代码来源:PullMachMenu.cpp

示例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;
                    }
                }
            }
        }
开发者ID:itita,项目名称:2-z-q-x-,代码行数:38,代码来源:NewMenuDevice.cpp


注:本文中的CCMenuItem::convertToNodeSpace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。