本文整理汇总了C++中RectangleShape类的典型用法代码示例。如果您正苦于以下问题:C++ RectangleShape类的具体用法?C++ RectangleShape怎么用?C++ RectangleShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RectangleShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onRender
void UIComponentImage::onRender(GraphicsDevice* renderer, UIView* view)
{
RectangleShape backgroundRect;
backgroundRect.setRect(view->getBounds());
if(mTexture) backgroundRect.setTexture(mTexture);
renderer->draw(backgroundRect);
}
示例2: if
void UIComponentTreeView::onRender(Renderer* renderer, UIView* view)
{
// Draw a black background on the ROOT tree view
if(mSubTreeLevel == 0)
{
RectangleShape back;
back.setRect(view->getBounds());
back.setColor(Color(36,36,36));
renderer->draw(back);
}
/*else if(mSubTreeLevel == 1)
{
RectangleShape back;
back.setRect(view->getBounds());
back.setColor(Color::Grass);
renderer->draw(back);
}
else if(mSubTreeLevel == 2)
{
RectangleShape back;
back.setRect(view->getBounds());
back.setColor(Color::Bittersweet);
renderer->draw(back);
}
else if(mSubTreeLevel == 3)
{
RectangleShape back;
back.setRect(view->getBounds());
back.setColor(Color::Lavender);
renderer->draw(back);
}*/
}
示例3: draw
void RenderSystem::draw(GameObject* gameObject)
{
RenderComponent* render = gameObject->getComponent<RenderComponent>();
if (render != nullptr)
{
RectangleShape shape = *render->getDrawable();
TransformComponent* transform = gameObject->getComponent<TransformComponent>();
if (transform != nullptr)
{
shape.setPosition(transform->getPosition());
}
else
{
BoardComponent* boardComp = gameObject->getComponent<BoardComponent>();
if (boardComp != nullptr && mBoard != nullptr)
{
Vector2i boardPos = boardComp->getPosition();
shape.setPosition(mBoard->getTilePosition(boardPos.x, boardPos.y));
}
}
mWindow->draw(shape);
}
}
示例4: isCancelClicked
/*
Determine si le bouton de la boite de dialogue selectionné par le clic
de la souris est celui d'annulation.
*/
bool MainTool::isCancelClicked(int x, int y)
{
Text ok;
ok.setFont(font);
ok.setString("Sauver");
ok.setCharacterSize(12);
FloatRect fro = ok.getLocalBounds();
Text cancel;
cancel.setFont(font);
cancel.setString("Annuler");
cancel.setCharacterSize(12);
FloatRect frc = cancel.getLocalBounds();
cancel.setPosition((400 - 40 - fro.width - frc.width) / 2 + 30 + fro.width, 70);
RectangleShape buttonCancel;
buttonCancel.setSize(Vector2f(frc.width + 10, frc.height + 10));
buttonCancel.setPosition(cancel.getPosition().x - 5, cancel.getPosition().y);
if (buttonCancel.getGlobalBounds().contains(x, y))
return true;
else
return false;
}
示例5:
void GameEngine::_initWall(RectangleShape &wall, const unsigned int size,
Color const &color, const Vector2f &pos)
{
wall.setSize(Vector2f(25, size));
wall.setOrigin(0, size);
wall.setFillColor(color);
wall.setPosition(pos);
}
示例6: onRender
void UIComponentScrollBar::onRender(Renderer* renderer, UIView* view)
{
RectangleShape scrollBarBackground;
scrollBarBackground.setSize(17.f, view->getSize().y);
scrollBarBackground.setPosition(view->getPosition().x + view->getSize().y - 17.f, view->getPosition().y);
scrollBarBackground.setColor(Color::Blue);
renderer->draw(scrollBarBackground);
renderer->draw(scrollBarPaddle);
}
示例7: Check
//Точка входит в квадрат?
bool Check(RectangleShape rect, CircleShape shape){
Vector2f coordrect = rect.getPosition();
Vector2f coordshape = shape.getPosition();
if (coordrect.x <= coordshape.x &&
coordrect.y <= coordshape.y &&
coordrect.x + rect.getSize().x >= coordshape.x &&
coordrect.y + rect.getSize().y >= coordshape.y)
{
return true;
}
else { return false; }
}
示例8: RectangleShape
KShape *RectangleShapeFactory::createDefaultShape(KResourceManager *) const
{
RectangleShape *rect = new RectangleShape();
rect->setBorder(new KLineBorder(1.0));
rect->setShapeId(KoPathShapeId);
QLinearGradient *gradient = new QLinearGradient(QPointF(0,0), QPointF(1,1));
gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
gradient->setColorAt(0.0, Qt::white);
gradient->setColorAt(1.0, Qt::green);
rect->setBackground(new KGradientBackground(gradient));
return rect;
}
示例9: afficher
void Snake::afficher(sf::RenderWindow * _window){
int colorByQuad = 200/corps.size();
for(int i=0;i<corps.size();i++){
partCorps.setFillColor(Color(10,255-(i*colorByQuad),10));
partCorps.setPosition(Vector2f(corps[i].x*partSize,corps[i].y*partSize));
_window->draw(partCorps);
}
_window->draw(partFood);
if(loose){
RectangleShape tmp;
tmp.setFillColor(Color(50,0,0,127));
tmp.setPosition(0,0);
tmp.setSize(Vector2f(largeur,hauteur));
_window->draw(tmp);
_window->draw(text);
_window->draw(text2);
}
}
示例10: step_five
void step_five(RectangleShape &rectangle, float time, int number_block, float &x, float &y, int &step, float &size_y)
{
if (x > RECTANGLES_SIZE.x / 2)
x -= time * 0.1;
else {
step = MOVE_DOWN;
rectangle.setFillColor(Color::Blue);
}
}
示例11: step_one
void step_one(RectangleShape &rectangle, float time, float &y, int &step)
{
if (y > WINDOW_SIZE.y - RECTANGLES_SIZE.y / 2) {
rectangle.setFillColor(Color::Magenta);
step = MOVE_RIGHT_AND_UP;
}
else
y += time * 0.1;
}
示例12: resetBall
void resetBall() {
FloatRect p = player.getGlobalBounds();
FloatRect b = ball.getGlobalBounds();
ball.setPosition(p.left + p.width/2 + 5, p.top);
ballSpeed.x = 0.1f;
ballSpeed.y = -0.3f;
}
示例13:
Wire(float mX, float mY)
{
line.setSize(Vector2f(5, 5));
line.setPosition(mX, mY);
line.setFillColor(Color::Red);
}
示例14:
// The constructor is almost identical to the `Paddle` one.
Brick(float mX, float mY)
{
shape.setPosition(mX, mY);
shape.setSize({blockWidth, blockHeight});
shape.setFillColor(Color::Yellow);
shape.setOrigin(blockWidth / 2.f, blockHeight / 2.f);
}
示例15: updatePlayer
void updatePlayer() {
if (Keyboard::isKeyPressed(Keyboard::Left)) {
player.move(-moveDistance * updateTime/50.0, 0);
} else if (Keyboard::isKeyPressed(Keyboard::Right)) {
player.move(moveDistance * updateTime/50.0, 0);
}
}