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


C++ RenderWindow::getSize方法代码示例

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


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

示例1: pause

void System::pause(sf::RenderWindow &window, sf::Event event, sf::RectangleShape background) {
    std::cout << "Pause started." << std::endl;

    sf::Font font = loadFont();
    sf::Text pause("PAUSE", font, 75);
    pause.setColor(sf::Color(0, 0, 0, 200));
    pause.move(window.getSize().x / 2 - pause.getCharacterSize() * 1.5, window.getSize().y / 2 - pause.getCharacterSize());

    bool stop(false);
    while (window.waitEvent(event) && !stop) {
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::LControl) && sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) {
            window.close();
        }
        switch (event.type) {
            case sf::Event::Closed:
                window.close();
                break;
            case sf::Event::KeyPressed:
                switch(event.key.code) {
                    case sf::Keyboard::Escape:
                        stop = true;
                        break;
                }
                break;
        }
        window.clear();
        window.draw(background);
        window.draw(pause);
        window.display();
    }
    std::cout << "Pause is finished." << std::endl;
}
开发者ID:JoBrLesAmis,项目名称:Utilitaires,代码行数:32,代码来源:System.cpp

示例2: DrawTheMinimap

void Minimap::DrawTheMinimap(sf::RenderWindow& window, Game& game, sf::View view)
{
	if (ShouldBeUpdated)
	{
		UpdateTheMinimap(game.map);
		ShouldBeUpdated = false;
	}

	MinimapSprite.setPosition(sf::Vector2f(window.getSize().x - 200.f, 50.f));
	window.draw(MinimapSprite);

	MinimapBackground.setPosition(sf::Vector2f(window.getSize().x - 200.f, 50.f));
	

	window.draw(MinimapBackground);
	
	for (int j = 0; j < game.MOBs.size(); j++)
	{
		AllyMobSprite.setPosition(sf::Vector2f(game.MOBs[j]->position.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + window.getSize().x - 200.f - 4, game.MOBs[j]->position.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + 50.f));
		window.draw(AllyMobSprite);
	}
	for (int j = 0; j < game.structures.size(); j++)
	{
		AllyPlantSprite.setPosition(sf::Vector2f(game.structures[j].position.x * MINIMAP_WIDTH / MAP_DIM + window.getSize().x - 200.f - 4, game.structures[j].position.y * MINIMAP_WIDTH / MAP_DIM + 50.f));
		window.draw(AllyPlantSprite);
	}

	sf::Vector2f ViewSize = view.getSize();
	sf::Vector2f ViewCornerPosition = view.getCenter() - ViewSize / 2.0f;
	MinimapFOVIndicator.setPosition(ViewCornerPosition.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + window.getSize().x - 200.f, ViewCornerPosition.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + 50.f);
	MinimapFOVIndicator.setSize(sf::Vector2f(ViewSize.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM, ViewSize.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM));
	window.draw(MinimapFOVIndicator);

}
开发者ID:choltfo,项目名称:RTSGame,代码行数:34,代码来源:Minimap.cpp

示例3: Update

void EnemyFormation::Update(sf::RenderWindow &window, float elapsedTime){
	m_xPos = sprite.getPosition().x;
	m_yPos = sprite.getPosition().y;

	if (m_yPos <= window.getSize().y) {
		if (m_yPos <= window.getSize().y / 3){
			m_yPos += (m_speed / 3) * elapsedTime;
		}
		else{
			m_yPos += m_speed * elapsedTime;
		}
	}
	else{
		m_active = false;
	}
	
	//Update Healthbar
	UpdateHealthBar();

	//do the rest
	sprite.setPosition(m_xPos, m_yPos);

	//see if death should be initialized
	m_scale = sprite.getScale();
	initDeath();
}
开发者ID:nebula2,项目名称:Pew,代码行数:26,代码来源:EnemyFormation.cpp

示例4: loadWidgets

void loadWidgets(tgui::Gui& gui, tgui::Gui& gui2, sf::RenderWindow& window)
{
	tgui::Picture::Ptr picture(gui2);
	picture->load("images/xubuntu_bg_aluminium.jpg");
	picture->setCallbackId(3);

	//would be nice to get below to work, but OpenGL covers it
	//picture->bindCallbackEx(onBackClick, tgui::Picture::LeftMouseClicked);
	
	tgui::Label::Ptr instructions1(gui);
	instructions1->setText("Use up and down arrow keys");
	instructions1->setPosition(0, 0);
	tgui::Label::Ptr instructions2(gui);
	instructions2->setText("to control speed of spin");
	instructions2->setPosition(0, 32);

	// Create check box for pausing
	tgui::Checkbox::Ptr checkbox(gui);
	checkbox->load("widgets/Black.conf");
	checkbox->setPosition(window.getSize().x - 128, 30);
	checkbox->setText("Paused");
	checkbox->setSize(32, 32);
	checkbox->setCallbackId(1);
	checkbox->bindCallbackEx(pauseCallback, tgui::Checkbox::LeftMouseClicked);

	// Create the quit button
	tgui::Button::Ptr quit(gui);
	quit->load("widgets/Black.conf");
	quit->setSize(128, 30);
	quit->setPosition(window.getSize().x - 128, 0);
	quit->setText("Quit");
	quit->setCallbackId(2);
	quit->bindCallbackEx(quitCallback, tgui::Button::LeftMouseClicked);
}
开发者ID:WendyHanzer,项目名称:4s,代码行数:34,代码来源:main.cpp

示例5: initMap

void MainMenu::initMap(sf::RenderWindow &window, TextureManager &textureManager)
{
	//hardcoded positions

	backgroundSprite.setTexture(*textureManager.getResource("Config/Content/Images/Menus/Backgrounds/MainMenuBackground.png"));

	sf::RectangleShape playButton;
	playButton.setSize(sf::Vector2f(143.0f, 72.0f));
	playButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/playButton.png"));
	playButton.setPosition(window.getSize().x / 2 - playButton.getSize().x / 2, 210);

	sf::RectangleShape creditsButton;
	creditsButton.setSize(sf::Vector2f(213.0f, 72.0f));
	creditsButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/creditsButton.png"));
	creditsButton.setPosition(window.getSize().x / 2 - creditsButton.getSize().x / 2, 295);

	sf::RectangleShape highScoresButton;
	highScoresButton.setSize(sf::Vector2f(338.0f,72.0f));
	highScoresButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/highScoreButton.png"));
	highScoresButton.setPosition(window.getSize().x / 2 - highScoresButton.getSize().x / 2, 380);

	sf::RectangleShape exitButton;
	exitButton.setSize(sf::Vector2f(134.0f,72.0f));
	exitButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/exitButton.png"));
	exitButton.setPosition(window.getSize().x / 2 - exitButton.getSize().x / 2, 465);

	menuItems[PLAY] = playButton;
	menuItems[CREDITS] = creditsButton;
	menuItems[HIGHSCORES] = highScoresButton;
	menuItems[EXIT] = exitButton;
}
开发者ID:Kerswill,项目名称:Bacterium,代码行数:31,代码来源:MainMenu.cpp

示例6: Draw

void Client::Draw(sf::RenderWindow& window, Mission& mission)
{
    window.setView(multiview);
    multiview.setCenter(sf::Vector2f(x, window.getSize().y/2));
    multiview.setSize(sf::Vector2f(window.getSize().x, window.getSize().y));

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
    {
        player1.move(-1,0);
    }

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
    {
        player1.move(1,0);
    }

    player1.y = window.getSize().y-50;
    player2.y = window.getSize().y-50;

    x = player1.x;
    y = player1.y;

    //player2.draw(window,pata);
    //player1.draw(window,pata);

    text1.setPosition(x-50,y-50);
    text2.setPosition(player2.x-50,player2.y-50);
    window.draw(text1);
    window.draw(text2);
}
开发者ID:MaciekP42,项目名称:Patafour,代码行数:30,代码来源:client.cpp

示例7: create

void Player::create(sf::RenderWindow &window, sf::Texture &playerText)
{
	AnimatedSprite placeHolder(sf::seconds(0.2), true, false);
	sprite = placeHolder;

	movingUpAnimation.setSpriteSheet(playerText);
	movingUpAnimation.addFrame(sf::IntRect(0, 96, 32, 32));
	movingUpAnimation.addFrame(sf::IntRect(32, 96, 32, 32));

	movingDownAnimation.setSpriteSheet(playerText);
	movingDownAnimation.addFrame(sf::IntRect(0, 32, 32, 32));
	movingDownAnimation.addFrame(sf::IntRect(32, 32, 32, 32));

	movingRightAnimation.setSpriteSheet(playerText);
	movingRightAnimation.addFrame(sf::IntRect(0, 0, 32, 32));
	movingRightAnimation.addFrame(sf::IntRect(32, 0, 32, 32));

	movingLeftAnimation.setSpriteSheet(playerText);
	movingLeftAnimation.addFrame(sf::IntRect(0, 64, 32, 32));
	movingLeftAnimation.addFrame(sf::IntRect(32, 64, 32, 32));

	currentAnimation = &movingRightAnimation;
	sprite.play(*currentAnimation);
	m_Velocity = 100.f;
	m_VelocityVector.x = m_Velocity;
	m_VelocityVector.y = 0;
	amountOfCollectablesCollected = 0;
	
	sprite.setOrigin(sf::Vector2f(sprite.getGlobalBounds().width / 2, sprite.getGlobalBounds().height / 2));
	sprite.setPosition(window.getSize().x / 2, window.getSize().y / 2);
}
开发者ID:eric556,项目名称:Pacman,代码行数:31,代码来源:player.cpp

示例8: screenRect

Space::Space (sf::RenderWindow &window)
    : window (window)
    , view (window.getDefaultView())
    , screenRect ()
    , spaceBounds (0.f, 0.f, view.getSize().x, view.getSize().y)
    , shape () // testing
{
    // load textures
    // init scene
    // build scene

    // Set view based on window size
    view.setCenter (sf::Vector2f (window.getSize().x/2, window.getSize().y/2));
    view.setSize (sf::Vector2f (window.getSize().x, window.getSize().y));
    view.setViewport (sf::FloatRect (0.f, 0.f, 1.f, 1.f)); // One view for entire window
    sf::FloatRect screenRect (sf::Vector2f (view.getCenter().x - (view.getSize().x)/2,
                                            view.getCenter().y - (view.getSize().y)/2)
                              , view.getSize());

    //window.setView (view);


    // ScreenRect Tests
//    std::cout << screenRect.top << std::endl;
//    std::cout << screenRect.left << std::endl;
//    std::cout << screenRect.height << std::endl;
//    std::cout << screenRect.width << std::endl;
//    shape.setFillColor (sf::Color::Blue);
//    shape.setPosition (sf::Vector2f (100, 100));
//    shape.setSize (sf::Vector2f (100, 100));


} // Space:Space
开发者ID:jantzeno,项目名称:BMO,代码行数:33,代码来源:space.cpp

示例9: System

GraphicsSystem::GraphicsSystem(Engine& engine, sf::RenderWindow& window, tgui::Gui& layer0, tgui::Gui& layer1, tgui::Gui& layer2, Camera& camera) :
    System(engine),
    projection(glm::perspective(45.0f, float(window.getSize().x)/float(window.getSize().y), .01f, 100.0f)),
    //view(glm::lookAt(glm::vec3(0.0, 16.0, 16.0), glm::vec3(0.0, 0.0, 0.0), glm::vec3(0.0, 1.0, 0.0))),			//temp
    camera(camera),
    layer0(layer0),
    layer1(layer1),
    layer2(layer2),
    window(window),
    program(NULL)
{
    GLenum status = glewInit();
    if(status != GLEW_OK)
    {
        std::cerr << "[F] GLEW NOT INITIALIZED: ";
        std::cerr << glewGetErrorString(status) << std::endl;

        window.close();

        throw 1;
    } //if

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
    //glDepthFunc(GL_LESS);
    //glDepthMask(GL_TRUE);
    //glFrontFace(GL_CW);
    glEnable(GL_CULL_FACE);
    //glCullFace(GL_BACK);
    glClearDepth(1.f);
    glShadeModel(GL_SMOOTH);

    glViewport(0, 0, window.getSize().x, window.getSize().y);
} //GraphicsSystem
开发者ID:WendyHanzer,项目名称:4s,代码行数:34,代码来源:GraphicsSystem.cpp

示例10: update

void GuiBottomRight::update(float dt, sf::RenderWindow &window, vector<int> enemyTypes, int timer, int goldTimer, int gold)
{
	window_->SetPosition(sf::Vector2f(window.getSize().x-window_->GetRequisition().x, window.getSize().y-window_->GetRequisition().y));
	
	string previewString;
	previewString="";
	stringstream zombies;
	zombies << enemyTypes[Enemy::EnemyType::Zombie];
	previewString+=zombies.str();
	previewString+=" Zombies ";
	stringstream ghosts;
	ghosts << enemyTypes[Enemy::EnemyType::Ghost];
	previewString+=ghosts.str();
	previewString+=" Ghosts ";
	stringstream godzillas;
	godzillas << enemyTypes[Enemy::EnemyType::Godzilla];
	previewString+=godzillas.str();
	previewString+=" Godzillas";
	preview_->SetText(previewString);

	stringstream timerString;
	timerString << timer;
	timer_->SetText("Next wave: " +timerString.str()+ " seconds |");
	
	stringstream goldTimerString;
	goldTimerString << goldTimer;
	goldTimer_->SetText("More Gold: " +goldTimerString.str()+ " seconds |");
	
	stringstream goldString;
	goldString << gold;
	gold_->SetText(goldString.str()+ " Gold");
}
开发者ID:fuerchter,项目名称:22Jams02,代码行数:32,代码来源:GuiBottomRight.cpp

示例11: GameState

GameStatePlayingLevel::GameStatePlayingLevel(const string &levelToLoad, vector<shared_ptr<Player> > &players, sf::RenderWindow &window) :
    GameState(false),
    world(window),
    levelName(levelToLoad),
    playerStats(sf::Vector2f(0, 0), "font.ttf")
    {
        world.players.insert(world.players.end(), players.begin(), players.end());
        playerStats.setTargetPlayer(players[0]);

        //when the level starts, the players should all be spawned at their initial position
        for(auto &player : world.players) {

            player->spawn(world.initialPlayerSpawnPoint);
        }

        playerStats.handleScreenResize(sf::Vector2f(window.getSize().x, window.getSize().y));

        //do some level loading
        //what if levle loading fails? i dunno, throwing exceptions aren't a good idea in constructors or destructors
        //most likely you should just crash the game
        loadWorld(levelToLoad, world);

        //camera should be updated that way if this state is created and another state draws on top of this one, the camera is correctly setup to draw the world
        vector<glm::vec2> playerPositions;
        playerPositions.push_back(world.initialPlayerSpawnPoint);

        updateCameraProperties(world, playerPositions, 0);
    }
开发者ID:Irelevance,项目名称:Contra,代码行数:28,代码来源:GameStatePlayingLevel.cpp

示例12: initialize

    void initialize(sf::RenderWindow &mainWindow, sf::Font &mainFont)
    {
        titleText.setFont(mainFont);
        titleText.setString("Triangle Super");
        titleText.setCharacterSize(72);
        titleText.setPosition(mainWindow.getSize().x/2 - titleText.getGlobalBounds().width/2.f,
                              mainWindow.getSize().y/2 - titleText.getGlobalBounds().height/2.f);

        playText.setFont(mainFont);
        playText.setString("Play!");
        playText.setCharacterSize(30);
        playText.setPosition(mainWindow.getSize().x/3 - playText.getGlobalBounds().width/2.f,
                             mainWindow.getSize().y/3 *2 - playText.getGlobalBounds().height/2.f);

        quitText.setFont(mainFont);
        quitText.setString("Quit.");
        quitText.setCharacterSize(30);
        quitText.setPosition(mainWindow.getSize().x/3 *2 - quitText.getGlobalBounds().width/2.f,
                             mainWindow.getSize().y/3*2-quitText.getGlobalBounds().height/2.f);

        scoreText.setFont(mainFont);
        scoreText.setCharacterSize(30);
        scoreText.setPosition(mainWindow.getSize().x/2 - scoreText.getGlobalBounds().width/2.f,
                              mainWindow.getSize().y/3-scoreText.getGlobalBounds().height/2.f);
    }
开发者ID:Mischa-Alff,项目名称:TriangleSuper,代码行数:25,代码来源:Utils.hpp

示例13: draw

void Tile::draw(Position p, sf::RenderWindow& rw) {
  std::cout << p.x << ','<< p.y << ' ' << rw.getSize().x << ',' << rw.getSize().y << std::endl;
  assert(p.x >= 0 && p.x <= rw.getSize().x);
  assert(p.y >= 0 && p.y <= rw.getSize().y);
  
  _base.setPosition(p.x, p.y);
  rw.draw(_base);
}
开发者ID:DForshner,项目名称:TileRPGEngineProto,代码行数:8,代码来源:Tile.cpp

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

示例15: Update

void MovableBackground::Update(sf::RenderWindow &window, float &elapsedTime, float &speed){
	if (bgY < window.getSize().y)
		bgY -= speed * elapsedTime;
	else
	{
		bgY = 0;
	}
	mbgSprite.setTextureRect(sf::IntRect(0, (int)bgY, (int)window.getSize().x, (int)window.getSize().y));
}
开发者ID:nebula2,项目名称:Pew,代码行数:9,代码来源:GUI.cpp


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