• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ cocos2d::Rect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cocos2d::Rect的典型用法代码示例。如果您正苦于以下问题:C++ Rect类的具体用法?C++ Rect怎么用?C++ Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: placeRectToRect

         cocos2d::Rect placeRectToRect(const cocos2d::Rect& placedRect, const cocos2d::Rect& placeToRect)
         {
            cocos2d::Rect result = placedRect;

            bool bCanBePlacedInside = isRectCanBePlacesInsideRect(placedRect, placeToRect);

            if (true == bCanBePlacedInside)
            {
               auto rectInsideResult = isRectInsideRect(placedRect, placeToRect);
               if (false == rectInsideResult.bResult)
               {
                  result.origin = placedRect.origin;

                  if (false == rectInsideResult.bMinX || false == rectInsideResult.bMinY)
                  {
                     Vec2 movePoint(placedRect.getMinX(), placedRect.getMinY());
                     movePoint = placePointToRect(movePoint, placeToRect) - movePoint;
                     result.origin += movePoint;
                     result = placeRectToRect(result, placeToRect);
                  }
                  else if (false == rectInsideResult.bMaxX || false == rectInsideResult.bMaxY)
                  {
                     Vec2 movePoint(placedRect.getMaxX(), placedRect.getMaxY());
                     movePoint = placePointToRect(movePoint, placeToRect) - movePoint;
                     result.origin += movePoint;
                     result = placeRectToRect(result, placeToRect);
                  }
               }
            }

            return result;
         }
开发者ID:svlad-90,项目名称:theWorld,代码行数:32,代码来源:Helper.cpp


示例2: A

cocos2d::Vec2 GameLayer::getIntersection_NPC_and_SPELayerRect(cocos2d::Rect rect ,cocos2d::Point p)
{

	/*
			D---------C
			|		 |
			A---------B
	*/
	Vec2 A(rect.getMinX(),rect.getMinY());
	Vec2 B(rect.getMaxX(),rect.getMinY());
	Vec2 C(rect.getMaxX(),rect.getMaxY());
	Vec2 D(rect.getMinX(),rect.getMaxY());

	Vec2 PlayerP = getChildByTag(kTagPlayer)->getPosition();
	Vec2 npcP = p;

	Vec2 point;
	if ( Vec2::isSegmentIntersect(A, B, PlayerP,p)){
		point = Vec2::getIntersectPoint(A,B,PlayerP,p);
	}
	else if (Vec2::isSegmentIntersect(B, C, PlayerP, p)){
		point = Vec2::getIntersectPoint(B,C, PlayerP, p);
	}
	else if (Vec2::isSegmentIntersect(C, D, PlayerP, p)){
		point = Vec2::getIntersectPoint(C, D, PlayerP, p);
	}
	else if (Vec2::isSegmentIntersect(A, D, PlayerP, p)){
		point = Vec2::getIntersectPoint(A, D, PlayerP, p);
	}

	return point;
}
开发者ID:zuokaihuang,项目名称:MyFlow,代码行数:32,代码来源:GameLayer.cpp


示例3: rect_adjustPointInside

 cocos2d::Vec2 rect_adjustPointInside(const cocos2d::Rect& rect, const cocos2d::Vec2& pt)
 {
     cocos2d::Point result;
     result.x = letBetween(pt.x, rect.getMinX(), rect.getMaxX());
     result.y = letBetween(pt.y, rect.getMinY(), rect.getMaxY());
     return result;
 }
开发者ID:adroitly,项目名称:boom,代码行数:7,代码来源:Geometry.cpp


示例4: calculateCircleByRect

nav::Circle DelaunayAlgorithm::calculateCircleByRect(const cocos2d::Rect&rect)
{
	CCASSERT(rect.size.width > 0 && rect.size.height > 0, "create circle must rect");
	cocos2d::Point center(rect.getMidX(), rect.getMidY());
	cocos2d::Point topright(rect.getMaxX(), rect.getMaxY());
	float distance = center.getDistance(topright);
	nav::Circle circle(center, distance);
	return circle;
}
开发者ID:spzktshow,项目名称:BigDipper,代码行数:9,代码来源:NVDelaunayAlgorithm.cpp


示例5: placePointToRect

         cocos2d::Vec2 placePointToRect(const cocos2d::Vec2& point, const cocos2d::Rect& rect)
         {
            cocos2d::Vec2 result = point;

            {
               if (point.x < rect.getMinX())
               {
                  result.x = rect.getMinX();
               }
            }

            {
               if (point.y < rect.getMinY())
               {
                  result.y = rect.getMinY();
               }
            }

            {
               if (point.x > rect.getMaxX())
               {
                  result.x = rect.getMaxX();
               }
            }

            {
               if (point.y > rect.getMaxY())
               {
                  result.y = rect.getMaxY();
               }
            }

            return result;
         }
开发者ID:svlad-90,项目名称:theWorld,代码行数:34,代码来源:Helper.cpp


示例6: checkChildType

bool TeachLayer::checkChildType(cocos2d::Node *pNode, cocos2d::Rect stencilRect)
{
    if (!pNode) return false;
    if (0 >= pNode->getChildrenCount()) return false;
    
    for (auto child : pNode->getChildren())
    {
        if (dynamic_cast<SpriteButton*>(child))
        {
            auto spriteButton = dynamic_cast<SpriteButton*>(child);
            Rect btnRect = getNodeRect(spriteButton);
            if (stencilRect.intersectsRect(btnRect))
            {
                removeFromParent();
//                spriteButton->execCallBackEvent();
                return true;
            }
        }
    }
    
    for (auto child : pNode->getChildren())
    {
        if (checkChildType(child, stencilRect))
            return true;
    }
    return false;
}
开发者ID:LeeWei92,项目名称:CocosGui,代码行数:27,代码来源:TeachLayer.cpp


示例7: createCheckerWithRect

APTouchChecker APTouchManager::createCheckerWithRect(const cocos2d::Rect& rect) {

	return [rect](cocos2d::Touch* touch)->bool{
		return rect.containsPoint(touch->getLocation());

	};
}
开发者ID:EzKorry,项目名称:testunit36,代码行数:7,代码来源:apTouchManager.cpp


示例8: isRectInsideRect

         tRectInRectResult isRectInsideRect(const cocos2d::Rect & lhs, const cocos2d::Rect & rhs)
         {
            bool bMinX = lhs.getMinX() >= rhs.getMinX();
            bool bMinY = lhs.getMinY() >= rhs.getMinY();
            bool bMaxX = lhs.getMaxX() <= rhs.getMaxX();
            bool bMaxY = lhs.getMaxY() <= rhs.getMaxY();

            return tRectInRectResult(bMinX, bMinY, bMaxX, bMaxY);
         }
开发者ID:svlad-90,项目名称:theWorld,代码行数:9,代码来源:Helper.cpp


示例9:

void Pipe2::MakePipeBody(cocos2d::Layer *layer, b2World *world, cocos2d::Rect rect){
 
	auto Pipe = Sprite::create("pipe.png", rect);
	Pipe->setPosition(rect.getMidX(),rect.getMidY());
	layer->addChild(Pipe);
	//Pipe->setScale(0.5);
		
	
	b2BodyDef PipeBodyDef;

	PipeBodyDef.type = b2_kinematicBody;	//gravitity is not for pipes

	PipeBodyDef.position.Set(rect.getMidX()/SCALE_RATIO, rect.getMidY()/SCALE_RATIO);

	PipeBodyDef.userData = Pipe;

	auto PipeBody = world->CreateBody(&PipeBodyDef);

	
	float a = Pipe->getContentSize().width;//*0.7;
	float b = Pipe->getContentSize().height;//*0.9;
	float sizeX = a/(2*SCALE_RATIO);
	float sizeY = b/(2*SCALE_RATIO);

	b2PolygonShape polygon;
	polygon.SetAsBox(sizeX, sizeY); //a 4x2 rectangle !!может округлять в большую сторону; ORIGINY слишком большой OrigiinX маленький(

	//polygon.SetAsBox(1, sizeY);

	b2FixtureDef PipeShapeDef;

	PipeShapeDef.shape = &polygon;

	PipeShapeDef.density = 0;

	PipeShapeDef.friction = 0;

	PipeShapeDef.restitution = 0;

	PipeBody->CreateFixture(&PipeShapeDef);

	PipeBody->SetLinearVelocity( b2Vec2(-3,0));



}
开发者ID:valkoz,项目名称:FlappyClone,代码行数:46,代码来源:PipeBox.cpp


示例10: setTextureRect

void Scale9Sprite::setTexture(cocos2d::Texture2D *texture, const cocos2d::Rect &rect) {
	_contentSizeDirty = true;
	DynamicBatchNode::setTexture(texture);
	if (rect.equals(cocos2d::Rect::ZERO)) {
		setTextureRect(cocos2d::Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height));
	} else {
		setTextureRect(rect);
	}
}
开发者ID:SBKarr,项目名称:stappler,代码行数:9,代码来源:SPScale9Sprite.cpp


示例11: getPosition

void BlueParticles::SetArea(cocos2d::Rect rect, bool draw)
{
	m_area = rect;
	m_area.origin += getPosition();
	if (draw)
	{
		cocos2d::DrawNode* draw = cocos2d::DrawNode::create();
		draw->drawRect(cocos2d::Vec2::ZERO, cocos2d::Vec2(m_area.size.width, m_area.size.height), cocos2d::Color4F(1.0f, 0.0f, 0.0f, 0.5f));
		addChild(draw);
	}
	cocos2d::Rect textRect = cocos2d::Rect(rect.getMidX(), rect.getMidY(), rect.getMaxX() - rect.getMinX(), rect.getMaxY() - rect.getMinY());
	this->setTextureRect(rect);
	cocos2d::Texture2D::TexParams params = cocos2d::Texture2D::TexParams();
	params.magFilter = GL_LINEAR;
	params.minFilter = GL_LINEAR;
	params.wrapS = GL_REPEAT;
	params.wrapT = GL_REPEAT;
	getTexture()->setTexParameters(params);
}
开发者ID:tofurama3000,项目名称:The-Obscurity-Project,代码行数:19,代码来源:BlueParticles.cpp


示例12: getShowCells

void TableView::getShowCells(const cocos2d::Rect& area, std::vector<uint16_t>* dst)
{
	Rect _cellRect;
	for (int i = 0; i < m_totalCnt; ++i)
	{
		getCellRect(i, &_cellRect);
		if (!area.intersectsRect(_cellRect))
			continue;
		dst->push_back(i);
	}
}
开发者ID:wjezxujian,项目名称:Android_VS,代码行数:11,代码来源:TableView.cpp


示例13: getTexture

void DynamicSprite::setTextureRect(const cocos2d::Rect &rect) {
	auto tex = getTexture();
	if (rect.equals(cocos2d::Rect::ZERO) && tex) {
		_textureRect = cocos2d::Rect(0, 0, tex->getPixelsHigh(), tex->getPixelsWide());
		_contentSizeDirty = true;
	} else {
		if (!_textureRect.equals(rect)) {
			_textureRect = rect;
			_contentSizeDirty = true;
		}
	}
	if (_autofit == Autofit::None) {
		setContentSize(cocos2d::Size(_textureRect.size.width / _density, _textureRect.size.height / _density));
	}
}
开发者ID:SBKarr,项目名称:stappler,代码行数:15,代码来源:SPDynamicSprite.cpp


示例14: getTexture

bool Scale9Sprite::init(cocos2d::Texture2D *tex, cocos2d::Rect rect, cocos2d::Rect capInsets) {
	if (!DynamicBatchNode::init(tex)) {
		return false;
	}

	if (rect.equals(cocos2d::Rect::ZERO)) {
		rect.size = getTexture()->getContentSize();
	}
	_textureRect = rect;
	_capInsets = capInsets;
	_contentSize = _textureRect.size;
	
	setCascadeColorEnabled(true);
	setCascadeOpacityEnabled(true);
	
	return true;
}
开发者ID:SBKarr,项目名称:stappler,代码行数:17,代码来源:SPScale9Sprite.cpp


示例15: GetTileInfoByGid

bool TMXFile::GetTileInfoByGid(uint32_t iGid, const char*& outTexPath, cocos2d::Rect& outRect, const TMXCustomPropertyList*& outPropertyList)const
{
    for (auto& p : m_vecTileSet)
    {
        if (p->GetFirstGid() <= iGid && p->GetFirstGid() + p->GetTileMaxCount() > iGid)
        {
            uint32_t iIndex = iGid - p->GetFirstGid();
            
            outTexPath = p->GetTexturePath().c_str();
            outPropertyList = p->GetTileCustomPropertyList(iIndex);
            
            uint32_t x = iIndex % p->GetWidthCount();
            uint32_t y = iIndex / p->GetWidthCount();
            outRect.setRect(x * p->GetTileWidth(), y * p->GetTileHeight(), p->GetTileWidth(), p->GetTileHeight());
            return true;
        }
    }
    return false;
}
开发者ID:9chu,项目名称:cocos2dx-sokoban,代码行数:19,代码来源:TMXFile.cpp


示例16: rect_getMiddle

 cocos2d::Point rect_getMiddle(const cocos2d::Rect& rect)
 {
     return cocos2d::Point(rect.getMidX(), rect.getMidY());
 }
开发者ID:adroitly,项目名称:boom,代码行数:4,代码来源:Geometry.cpp


示例17: isCollisionWithRight

bool RunnerSprite::isCollisionWithRight(cocos2d::Rect box){
    auto manBox = mRunner->boundingBox();
    Vec2 manPoint = Vec2(manBox.getMaxX(),manBox.getMidY());
    return box.containsPoint(manPoint);
}
开发者ID:whtoo,项目名称:RunCPP,代码行数:5,代码来源:Runner.cpp


示例18: addOval

void Path::addOval(const cocos2d::Rect& oval) {
	moveTo(oval.getMaxX(), oval.getMidY());
	arcTo(oval.getMidX(), oval.getMidY(), oval.size.width/2, oval.size.height/2, 0.0f, 360.0_to_rad, 0.0f);
	closePath();
}
开发者ID:SBKarr,项目名称:stappler,代码行数:5,代码来源:SPDrawPath.cpp


示例19: addArc

void Path::addArc(const cocos2d::Rect& oval, float startAngle, float sweepAngle) {
	arcTo(oval.getMidX(), oval.getMidY(), oval.size.width/2, oval.size.height/2, startAngle, sweepAngle, 0.0f);
}
开发者ID:SBKarr,项目名称:stappler,代码行数:3,代码来源:SPDrawPath.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cocosdenshion::SimpleAudioEngine类代码示例发布时间:2022-05-31
下一篇:
C++ cocos2d::PhysicsContact类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap