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


C++ Sprite::scale方法代码示例

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


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

示例1: main

int main() {
    sf::RenderWindow App(sf::VideoMode(imageWidth, imageHeight), 
        "SFML Graphics",sf::Style::Fullscreen);
    // This is the SFML application initialization with the app's parameters
    cx[0] = 255; cx[1] = 0; cx[2] = 0;
    // The initial colors for the shifting
    kradius = 0.1;
    imagen.create(imageWidth,imageHeight);
    mandtex.create(imageWidth,imageHeight);
    // The scaling factor, defined by the ranges in Real and Imaginary axis,
    // divided by the respective axis real length.
    mandelb.setOrigin(imageWidth/2,imageHeight/2);
    mandelb.setPosition(640,400);
    mandelb.scale(1.5,1.5);
    // Set the image positioning, centering and scaling.
    k.real = 0;
    k.imag = 0;
    // Original K seed values.
    dir = false;
    // Direction of scan over the complex plane
    mandel = false;
    // false if painting Julia Set, true if Mandelbrot Set.
    draw = true;
    // To tell the application to pause or continue drawing, its switched by
    // pressing the right click.
    while (App.isOpen()) {
        sf::Event Event;
        while (App.pollEvent(Event)) {
           // SFML works with an event loop
            if (Event.type == sf::Event::Closed){
            // If the window is closed, close the application
                App.close();
            }
            if( Event.type == Event.MouseButtonReleased
                && Event.mouseButton.button == sf::Mouse::Left){
            // If the left mouse is pressed and released, close the application
                App.close();
            }
            if( Event.type == Event.MouseButtonReleased
                && Event.mouseButton.button == sf::Mouse::Right){
            // If the right mouse is pressed and released, toggle randomness.
                draw = !draw;
            }
        }
        App.clear();
        if(!draw) continue;
        // If false, then stop animating and freeze in the last generated frame.
        resolve();
        //radialScan();
        horizontalScan();
        mandelb.setColor(sf::Color(cx[0], cx[1], cx[2]));
        // Shift the image hue.
        App.draw(mandelb);
        App.display();
    }
    return EXIT_SUCCESS;
}
开发者ID:zubie7a,项目名称:Shine_On_You_Crazy_Fractal,代码行数:57,代码来源:main.cpp

示例2: draw

void Graphics::draw(sf::Vector2f position, sf::Vector2f hitbox, sf::Sprite sprite)
{
    sprite.setOrigin(0, hitbox.y);
    sf::Vector2f roundedPosition = sf::Vector2f(position.x - 0.5, position.y - 0.5);

    //Translate position
    translatePosition(roundedPosition, window_);

    //Set Position
    sprite.setPosition(roundedPosition);

    //Scale if necessary
    sprite.scale(hitbox.x / sprite.getTextureRect().width, hitbox.y / sprite.getTextureRect().height);

    window_->draw(sprite);
    return;
}
开发者ID:AquaticStanley,项目名称:Engine,代码行数:17,代码来源:Graphics.cpp

示例3: display

    void display(sf::RenderWindow* window, std::string pathImage){
        open = true;
            t.loadFromFile(pathImage);
            s = sf::Sprite();
            s.setTexture(t);
            s.scale(window->getSize().y/s.getGlobalBounds().height,window->getSize().y/s.getGlobalBounds().height);
            s.setPosition(window->getSize().x/2 - s.getGlobalBounds().width/2, 0);
        while(open){
            
            sf::Event event;
            while (window->pollEvent(event)) {
                switch (event.type) {
                case sf::Event::Closed:
                    window->close();
                    break;
                case sf::Event::KeyPressed:
                    if (event.key.code == sf::Keyboard::Escape) window->close();
                    break;
                case sf::Event::MouseButtonPressed:
                    if (event.mouseButton.button == sf::Mouse::Left) {
                        open = false;
                    }
                    break;
                default:
                    break;
                }
                if( event.type == sf::Event::KeyPressed ||
                event.type == sf::Event::MouseButtonPressed||
                event.type == sf::Event::TouchEnded           )  open = false;
            }

            window->clear();
            window->draw(s);

            window->display();
                
        }
        
        sf::Clock timer;
        sf::Sprite dark;
        sf::Texture text;
        bool closing = true;
        text.loadFromFile("res/pics/black.png");
        
        dark.setTexture(text);
        dark.setOrigin(dark.getLocalBounds().width/2,dark.getLocalBounds().height/2);
        dark.setPosition(window->getSize().x/2,window->getSize().y/2);
        float scale = 1/dark.getGlobalBounds().width;;
        
        float time = 0;
        while(closing and wantAnimation){            
            dark.setScale(scale,scale);
            time += timer.restart().asSeconds();
            if(time > 0.1){
                scale *= 1.5;
                time = 0;
            }
            window->clear();
            window->draw(s);
            window->draw(dark);
            window->display();
            if(dark.getGlobalBounds().width > window->getSize().x) closing = false;
        }
        //clean events 
        sf::Event e; while (window->pollEvent(e)) { }
    }
开发者ID:kaitokidi,项目名称:AndroidWhoIsTheMonster,代码行数:66,代码来源:MenuSelection.hpp

示例4: scaleBanner

void ObjectStyle::scaleBanner(sf::Sprite & sprite)
{
	sf::Vector2i tile = Textures::tilesetUnits().getTileSize();
	sprite.scale(flag_size.x / tile.x, flag_size.y / tile.y);
}
开发者ID:LeszekGzik,项目名称:PK4-Projekt-Civilisation-,代码行数:5,代码来源:ObjectStyle.cpp


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