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


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

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


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

示例1:

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

示例2: 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

示例3: SetArea

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

示例4: rect_getMiddle

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

示例5: 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

示例6: 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


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