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


C++ CCRect::getMidX方法代码示例

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


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

示例1: initTerritory

/*!
 * Determines initial territory size for this player based on the size of the screen and the location of the initial touch.
 * Sets player identifier based on initial territory.
 *
 * @param screenBox Size of the screen.
 */
void Player::initTerritory(CCRect screenBox) {

    this->territory = CCRectMake(screenBox.origin.x, screenBox.origin.y, screenBox.size.width, screenBox.size.height);
    territory.size.width /= 2;

    if (startingPoint.x < screenBox.getMidX()) {
        territory.origin.x = screenBox.origin.x / 2;

        if (GameManager::sharedManager()->tabletDevice()) {
            if (startingPoint.y > screenBox.getMidY()) {
                this->_identifier = GameManager::kPlayer1;
            } else {
                this->_identifier = GameManager::kPlayer3;
            }
        } else {
            this->_identifier = GameManager::kPlayer1;
        }
    } else {
        territory.origin.x = screenBox.origin.x / 2 + screenBox.size.width / 2;

        if (GameManager::sharedManager()->tabletDevice()) {
            if (startingPoint.y > screenBox.getMidY()) {
                this->_identifier = GameManager::kPlayer2;
            } else {
                this->_identifier = GameManager::kPlayer4;
            }
        } else {
            this->_identifier = GameManager::kPlayer2;
        }
    }
}
开发者ID:emmett9001,项目名称:fingerrace-core,代码行数:37,代码来源:Player.cpp

示例2: IsPutable

bool CBoxBehaviorState::IsPutable(CCSprite* sprite, CCPoint touchPos, CCPoint& avaliablePos)
{
	auto arr = CObjectManager::getInstance()->getBox2dSprite();
	CCPoint setPos;
	bool bIsEnable = true;
	CCRect rect;

	for (int i = 0; i <= 20; i++)
	{
		for (int j = 0; j <= 20; j++)
		{
			CCRect r;
			r.setRect(i * 105 + CScrollManager::getInstance()->getDeltaPosition().x, j * 105 + CScrollManager::getInstance()->getDeltaPosition().y, 105, 105);

			if (r.containsPoint(touchPos))
			{
				setPos = ccp(r.getMidX(), r.getMidY());
				rect = r;
			}
		}
	}

	for (int i = 0; i < arr->getSize(); i++)
	{
		auto anothersprite = arr->getObjectAt(i)->getSpritePtr();

		if (rect.intersectsRect(anothersprite->getBoundingBox()))
			bIsEnable = false;
	}

	avaliablePos = setPos;
	return bIsEnable;
}
开发者ID:godole,项目名称:Memory,代码行数:33,代码来源:BoxBehaviorState.cpp

示例3: onMovingToTarget

bool AllyUnit::onMovingToTarget( float dt )
{
	// let enemy stop running 
	// note: the pos is not the center point of collision rect!
	// 1. get distance color(collision) rect of ally

	//CCRect targetCollisionRect = enemy->getCollisionRect();
	if (!mPreTargetCollisionRect.equals(mTargetCollisionRect) )
	{

		CCRect CollisionRect = this->getCollisionRect();

		CCPoint destColorRectLeftTop;
		if(mTargetCollisionRect.getMidX() > CollisionRect.getMidX())
		{
			// move to left of the target
			destColorRectLeftTop.x = mTargetCollisionRect.getMinX() - mDefualtColorRect.size.width;
		}
		else
		{
			// move to right of the target
			destColorRectLeftTop.x = mTargetCollisionRect.getMaxX();
		}
		destColorRectLeftTop.y = mTargetCollisionRect.getMinY() + mDefualtColorRect.size.height;

		CCPoint destSpriteRectLeftTop = CCPoint(
			destColorRectLeftTop.x - mDefualtColorRect.origin.x,
			destColorRectLeftTop.y + mDefualtColorRect.origin.y
			);
		CCSize size = this->getContentSize();
		mDestinationPos = CCPoint(
			destSpriteRectLeftTop.x + size.width / 2,
			destSpriteRectLeftTop.y - size.height / 2 + rangedRand(0, 5)
			);
	}

	return onMoving(dt, mDestinationPos);
}
开发者ID:kelyad,项目名称:SomeTD,代码行数:38,代码来源:AllyUnit.cpp

示例4: isCollisionTop

bool GameLayer::isCollisionTop(CCRect roleBox, CCRect collisionBox) {
    
    CCPoint targetPoint = ccp(roleBox.getMidX(), roleBox.getMaxY());
    return collisionBox.containsPoint(targetPoint);
}
开发者ID:DoubleHH,项目名称:FlappyBird,代码行数:5,代码来源:GameLayer.cpp


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