本文整理汇总了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));
}
示例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;
}
示例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);
}
示例4: rect_getMiddle
cocos2d::Point rect_getMiddle(const cocos2d::Rect& rect)
{
return cocos2d::Point(rect.getMidX(), rect.getMidY());
}
示例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);
}
示例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();
}