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


C++ CCNode::convertToWorldSpace方法代码示例

本文整理汇总了C++中CCNode::convertToWorldSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::convertToWorldSpace方法的具体用法?C++ CCNode::convertToWorldSpace怎么用?C++ CCNode::convertToWorldSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCNode的用法示例。


在下文中一共展示了CCNode::convertToWorldSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getParent

//=============================================================
//=============================================================
void CC3DCircleListLayer::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
{
    if(!isVisible())
    {
        return ;
    }
    
    CCNode* fatherNode = getParent();
    if(!fatherNode)
        return ;
    
    CCPoint touchPointInWorld = pTouch->getLocation();
    CCPoint prePointInWorld = pTouch->getPreviousLocation();
    m_fLastMoveDis = touchPointInWorld.x - prePointInWorld.x;
    
    CCRect  selfRect = boundingBox();
    CCPoint selfOriginInWorld = fatherNode->convertToWorldSpace(selfRect.origin);
    CCRect selfRectInWorld = CCRectMake(selfOriginInWorld.x,selfOriginInWorld.y,selfRect.size.width,selfRect.size.height);
    if(selfRectInWorld.containsPoint(touchPointInWorld) == false)
    {
        touchEnd();
        return;
    }
    refreshItem(m_fLastMoveDis);
}
开发者ID:bingwan,项目名称:Cut2.1.2Classes,代码行数:27,代码来源:CC3DCircleListLayer.cpp

示例2: perform

bool SFVideo::perform(CCDictionary * pDict, cocos2d::CCNode * pTarget)
{
	if (!pDict)
	{
		CNLog("error");
		return false;
	}
	
	CCString * pTask = (CCString *)pDict->objectForKey("Task");
	if (!pTask)
	{
		CNLog("invalid video task");
		return false;
	}
	const char * task = pTask->getCString();
	CNLog("SFVideo: ******************************** %s", task);
	
	if (strlen(task) == 0)
	{
		CNLog("invalid task");
	}
	else if (strcasecmp(task, "Init") == 0 || strcasecmp(task, "InitPlayer") == 0)
	{
		CNLog("init video player");
		if (pTarget)
		{
			CCNode * pParent = pTarget->getParent();
			if (pParent)
			{
				CCPoint position = ccpSub(pTarget->getPosition(), pTarget->getAnchorPointInPoints());
				CCPoint p2 = ccpAdd(position, ccpFromSize(pTarget->getContentSize()));
				
				position = pParent->convertToWorldSpace(position);
				p2 = pParent->convertToWorldSpace(p2);
				
				SFVideo_initPlayer(position.x, position.y, p2.x - position.x, p2.y - position.y);
			}
			else
			{
				CNLog("error");
			}
		}
		else
		{
			CNLog("error");
		}
	}
	else if (strcasecmp(task, "play") == 0 || strcasecmp(task, "playMovie") == 0)
	{
		CCString * pFilename = (CCString *)pDict->objectForKey("File");
		const char * filename = pFilename ? pFilename->getCString() : "";
		CNLog("playing video: %s", filename);
		SFVideo_playMovie(filename);
	}
	else if (strcasecmp(task, "stop") == 0 || strcasecmp(task, "stopMovie") == 0)
	{
		CNLog("stop video");
		SFVideo_stopMovie();
	}
	
	return true;
}
开发者ID:moky,项目名称:SpriteForest,代码行数:62,代码来源:SFVideo.cpp


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