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


C++ RectangleShape::setSize方法代码示例

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


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

示例1: TestBox

    TestBox(bool isCollidable) :
        sg::Entity(isCollidable)
    {

        r0.setSize(sf::Vector2f(100.0f, 50.0f));
        r0.setOrigin(50.0f, 25.0f);
        this->addDrawable(r0, false);
        bs.addShape(r0);
        r1.setRadius(40.0f);
        r1.setOrigin(40.0f, 40.0f);
        r1.move(100.0f, 0.0f);
        r1.scale(2.0f, 1.0f);
        this->addDrawable(r1, false);
        bs.addShape(r1);
        r2.setSize(sf::Vector2f(250.0f, 10.0f));
        r2.setOrigin(125.0f, 5.0f);
        r2.rotate(-90.0f);
        this->addDrawable(r2, false);
        bs.addShape(r2);
        r3.setRadius(40.0f);
        r3.setOrigin(40.0f, 40.0f);
        r3.move(-100.0f, 0.0f);
        this->addDrawable(r3, false);
        bs.addShape(r3);
        //bs.rotate(-45.0f);
        this->addTransformable(bs);
        //this->rotate(45.0f);

    }
开发者ID:klinginE,项目名称:Shogun-GameEngine,代码行数:29,代码来源:TestBox.hpp

示例2: gameWindow

	Pong() : gameWindow(sf::VideoMode(600, 480), "Pong")
	{
		ball.setFillColor(sf::Color::Cyan);
		ball.setPosition(100.0, 100.0);
		ball.setRadius(10.f);

		p1Paddle.setFillColor(sf::Color::Green);
		p1Paddle.setPosition(10.0, 100.0);
		p1Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p2Paddle.setFillColor(sf::Color::Red);
		p2Paddle.setPosition(580.0, 100.0);
		p2Paddle.setSize(sf::Vector2f(10.0, 100.0));

		p1MovingUp = false;
		p1MovingDown = false;
		p2MovingUp = false;
		p2MovingDown = false;

		ballMovement = sf::Vector2f(ballSpeed, ballSpeed);
		font.loadFromFile("arial.ttf");

		p1ScoreText.setPosition(150, 10);
		p1ScoreText.setFont(font);
		p1ScoreText.setString(std::to_string(p1Score));
		p1ScoreText.setColor(sf::Color::Red);
		p1ScoreText.setCharacterSize(24);

		p2ScoreText.setPosition(450, 10);
		p2ScoreText.setFont(font);
		p2ScoreText.setString(std::to_string(p2Score));
		p2ScoreText.setColor(sf::Color::Red);
		p2ScoreText.setCharacterSize(24);
	}
开发者ID:minhoolee,项目名称:id-Tech-Files,代码行数:34,代码来源:Main.cpp

示例3: set_info

 // Post battle update
 inline void set_info(int str)
 {
     info_str.setString(std::to_string(str));
     health_bar_bg.setSize(sf::Vector2f(get_max_hp()/scale, 10));
     health_bar_bg.setOutlineColor(sf::Color(125,125,125));
     health_bar_bg.setOutlineThickness(1);
     health_bar_current.setSize(sf::Vector2f(str/scale, 10));
     health_bar_current.setFillColor(get_life_color(str));
 }
开发者ID:dvbuntu,项目名称:ogre,代码行数:10,代码来源:ogre_obj.hpp

示例4: init

void WindowCreateThing::init(sf::RenderWindow &window) {

    rectTitle.setSize(sf::Vector2f(window.getSize().x*0.45, window.getSize().y*0.07));
    rectTitle.setPosition(sf::Vector2f(window.getSize().x/2-(rectTitle.getSize().x/2), window.getSize().x/4-(rectTitle.getSize().y/2)));
    rectTitle.setFillColor(sf::Color(158, 158, 158));
    rectTitle.setOutlineColor(sf::Color::Black);
    rectTitle.setOutlineThickness(1.f);

    rectMain.setSize(sf::Vector2f(window.getSize().x*0.45,window.getSize().y*0.45));
    rectMain.setPosition(sf::Vector2f(rectTitle.getPosition().x, rectTitle.getPosition().y+rectTitle.getSize().y));
    rectMain.setFillColor(sf::Color::White);
    rectMain.setOutlineColor(sf::Color::Black);
    rectMain.setOutlineThickness(1.f);

    load();


    starting_position = sf::Mouse::getPosition(window);



    textTitle.setFont(font);
    textTitle.setString("CreateThings.txt");
    textTitle.setCharacterSize(24);
    textTitle.setColor(sf::Color::White);
    textTitle.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x*0.3, rectTitle.getPosition().y+rectTitle.getSize().y*0.1));
    //textTitle.setPosition(sf::Vector2f(400,10));

    textClose.setFont(font);
    textClose.setString("X");
    textClose.setStyle(sf::Text::Bold);
    textClose.setCharacterSize(35);
    textClose.setColor(sf::Color::White);
    textClose.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x-30, rectTitle.getPosition().y+rectTitle.getSize().y*0.05));


    ///// FOLDER ICONE
    textureFolder.setSmooth(true);
    spriteFodler.setTexture(textureFolder);
    sf::Vector2f targetSize(25.0f, 25.0f);
    spriteFodler.setScale(
        targetSize.x / spriteFodler.getLocalBounds().width,
        targetSize.y / spriteFodler.getLocalBounds().height);
    spriteFodler.setPosition(sf::Vector2f(textTitle.getPosition().x-targetSize.x, textTitle.getPosition().y));




    ///// CLOSE ICONE
    /*textureClose.setSmooth(true);
    spriteClose.setTexture(textureClose);
    sf::Vector2f targetSize2(window.getSize().y*0.07, window.getSize().y*0.07);
    spriteClose.setScale(
        targetSize2.x / spriteClose.getLocalBounds().width,
        targetSize2.y / spriteClose.getLocalBounds().height);
    spriteClose.setPosition(rectTitle.getPosition().x+rectTitle.getSize().x-targetSize2.x, rectTitle.getPosition().y);*/
}
开发者ID:3991,项目名称:Game-25486,代码行数:57,代码来源:WindowCreateThing.hpp

示例5: draw

void Sprited::draw(sf::RenderWindow *window)
{
    // Scroll sprite
    sf::Vector2i shift = this->currentAnimation->frames[this->currentFrame];
    this->sprite.setTextureRect(sf::IntRect(shift.x, shift.y, this->width, this->height));

    this->sprite.setRotation((this->getWRotation() - this->camera->getWRotation()) / (2 * M_PI) * 360); // + this->wRotation / (2 * M_PI) * 360);

    if (this->camera) {
        // Transform sprite wPosition based on camera wPosition & wRotation
        this->sprite.setPosition(this->applyCameraTransformation(this->getWPosition()));
    } else {
        // No camera set, meaning this object's wPosition is not affected by camera.
        this->sprite.setPosition(this->getWPosition().x, this->getWPosition().y);
    }

    window->draw(this->sprite);

    Movable::draw(window);

#ifdef DEBUG
    static sf::RectangleShape origin;
    origin.setOrigin(2, 2);
    origin.setSize(sf::Vector2f(5, 5));
    origin.setPosition(this->sprite.getPosition());
    origin.setFillColor(sf::Color(255, 0, 0, 128));
    window->draw(origin);

    static sf::RectangleShape rect;
    rect.setFillColor(sf::Color::Transparent);
    rect.setOutlineThickness(1);
    rect.setOutlineColor(sf::Color::Blue);
    rect.setOrigin(this->sprite.getOrigin());
    rect.setPosition(this->sprite.getPosition());
    rect.setRotation(this->sprite.getRotation());
    rect.setSize(sf::Vector2f(this->sprite.getTextureRect().width, this->sprite.getTextureRect().height));
    window->draw(rect);

    sf::FloatRect wHitbox = this->getWHitbox();
    static sf::RectangleShape hitboxRect;
    hitboxRect.setFillColor(sf::Color::Transparent);
    hitboxRect.setOutlineThickness(1);
    hitboxRect.setOutlineColor(sf::Color::Red);
    hitboxRect.setOrigin(sf::Vector2f(wHitbox.width / 2, wHitbox.height / 2));
    hitboxRect.setSize(sf::Vector2f(wHitbox.width, wHitbox.height));
    hitboxRect.setPosition(this->applyCameraTransformation(this->getWPosition()));
    hitboxRect.setRotation(-this->camera->getWRotation() / M_PI * 180);
    window->draw(hitboxRect);
#endif
}
开发者ID:and3rson,项目名称:campfire,代码行数:50,代码来源:Sprited.cpp

示例6: TextSquare

 inline TextSquare(Ctx& mCtx, const Vec2f& mPos) : Base{mCtx, mPos}
 {
     text = &create<Text>(ssvs::zeroVec2f);
     bg.setSize(Vec2f{65, 65});
     bg.setOutlineColor(sf::Color::White);
     bg.setOutlineThickness(3);
 }
开发者ID:SuperV1234,项目名称:Experiments,代码行数:7,代码来源:Widgets.hpp

示例7: Paddle

 // As with the ball, we construct the paddle with
 // arguments for the initial position and initialize
 // the SFML rectangle shape.
 Paddle(float mX, float mY)
 {
     shape.setPosition(mX, mY);
     shape.setSize({defWidth, defHeight});
     shape.setFillColor(defColor);
     shape.setOrigin(defWidth / 2.f, defHeight / 2.f);
 }
开发者ID:Boza-s6,项目名称:cppcon2014,代码行数:10,代码来源:p04.cpp

示例8: setUpBall

void PongGame::setUpBall(int const mainWindowWidth, int const mainWindowHeight, sf::RectangleShape &ball) {
    ball.setPosition(mainWindowWidth / 2, mainWindowHeight / 2);
    ball.setSize(sf::Vector2f(20, 20));
    ball.setFillColor(sf::Color::Red);
    ball.setOutlineColor(sf::Color::Yellow);
    ball.setOutlineThickness(2);
}
开发者ID:Yves-T,项目名称:SFML_Pong,代码行数:7,代码来源:PongGame.cpp

示例9: Board

    Board(int n, sf::Vector2f pos){

        boardSprite.setSize(sf::Vector2f(n, 2));
        boardSprite.setFillColor(sf::Color::Blue);
        boardSprite.setPosition(pos);

    }
开发者ID:2Def,项目名称:JumpSimulation,代码行数:7,代码来源:jump.cpp

示例10:

	Player(sf::Vector2f position, sf::Vector2f size)
	{
		once = true;
		rect.setPosition(position);
		rect.setSize(size);
		rect.setFillColor(sf::Color::Green);
	}
开发者ID:Nicholas-Swift,项目名称:Early-Work,代码行数:7,代码来源:Fortress+Survival+Alpha+0.0.4.cpp

示例11: obstacle

 obstacle(sf::Vector2f p)
 {
     pos = p;
     r.setPosition(p);
     r.setSize(sf::Vector2f(50,50));
     r.setFillColor(sf::Color(255, 205, 210));
 }
开发者ID:Nineshadow,项目名称:Snake-in-C---and-SFML,代码行数:7,代码来源:snake.cpp

示例12: el

 el(sf::Vector2f p)
 {
     r.setSize(sf::Vector2f(50,50));
     r.setFillColor(sf::Color(2,136,209));
     pos = p;
     r.setPosition(pos);
 }
开发者ID:Nineshadow,项目名称:Snake-in-C---and-SFML,代码行数:7,代码来源:snake.cpp

示例13: Particle

 Particle(sf::Vector2i position)
 {
     rect.setSize(sf::Vector2f(2,2));
     rect.setOrigin( sf::Vector2f(1,1) );
     rect.setFillColor( sf::Color::Red );
     rect.setPosition( (sf::Vector2f)position );
     velocity = sf::Vector2f(0,0);
 }
开发者ID:Knayder,项目名称:Earth-Editor,代码行数:8,代码来源:particle.cpp

示例14: food

    food()
    {
        srand(time(NULL));
        r.setSize(sf::Vector2f(50,50));
        r.setFillColor(sf::Color(255,193,7));
        generatePos();

    }
开发者ID:Nineshadow,项目名称:Snake-in-C---and-SFML,代码行数:8,代码来源:snake.cpp

示例15: shapeRealBorder

sf::RectangleShape Spriteeditor::shapeRealBorder(Sprite * sprite, sf::RectangleShape shape)
{
	shape.setPosition(sprite->getPosition().x, sprite->getPosition().y);
	sf::Rect<float> border = sprite->getLocalBounds();
	shape.setSize(sf::Vector2f(border.width, border.height));
	shape.setScale(sprite->getScale());
	shape.setRotation(sprite->getRotation());
	return shape;
}
开发者ID:niccnacc,项目名称:Unified_Map_Editor,代码行数:9,代码来源:Spriteeditor.cpp


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