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


C++ string::Move方法代码示例

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


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

示例1: Render

    /// Renders the credits screen.
    /// @param[in,out]  renderer - The renderer to use for rendering.
    void CreditsScreen::Render(GRAPHICS::Renderer& renderer) const
    {
        // CALCULATE THE OFFSET OF THE TOP OF THE CREDITS BASED ON THE ELAPSED TIME.
        // This helps implement scrolling of the credits text upward.
        const float SCROLL_RATE_IN_PIXELS_PER_SECOND = -4.0f;
        float elapsed_time_in_seconds = ElapsedTime.asSeconds();
        float credits_text_top_offset_in_pixels = SCROLL_RATE_IN_PIXELS_PER_SECOND * elapsed_time_in_seconds;

        // RENDER TEXT INDICATING THE PURPOSE OF THIS SCREEN.
        const GRAPHICS::Color CREDITS_TEXT_COLOR = GRAPHICS::Color::WHITE;
        
        MATH::FloatRectangle screen_rectangle = renderer.Screen->GetBoundingRectangle<float>();
        float screen_left_x_position = screen_rectangle.GetLeftXPosition();
        float screen_top_y_position = screen_rectangle.GetTopYPosition();
        float screen_width_in_pixels = screen_rectangle.GetWidth();
        float screen_height_in_pixels = screen_rectangle.GetHeight();
        const float SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS = static_cast<float>(GRAPHICS::GUI::Glyph::DEFAULT_HEIGHT_IN_PIXELS);
        float credits_text_start_top_y_position = screen_top_y_position + credits_text_top_offset_in_pixels;
        MATH::FloatRectangle credits_title_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions(
            screen_left_x_position,
            credits_text_start_top_y_position,
            screen_width_in_pixels,
            SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS);

        renderer.RenderCenteredText(
            "CREDITS",
            RESOURCES::AssetId::FONT_TEXTURE,
            credits_title_text_screen_rectangle,
            CREDITS_TEXT_COLOR);

        // RENDER TEXT CREDITING GOD.
        const std::string GOD_CREDIT_TEXT = R"(Him by whom "all things were created" and "all things consist" - from Colossians 1:16-17 (KJV))";

        // Some additional spacing is added to help offset this credit text from previous text.
        float start_of_credits_top_y_position_in_pixels = 2 * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS + credits_text_start_top_y_position;

        // This text takes multiple lines to render using the current font.
        const unsigned int GOD_CREDIT_TEXT_LINE_COUNT = 4;
        const float GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS = static_cast<float>(GOD_CREDIT_TEXT_LINE_COUNT * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS);
        MATH::FloatRectangle current_credit_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions(
            screen_left_x_position,
            start_of_credits_top_y_position_in_pixels,
            screen_width_in_pixels,
            GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS);

        renderer.RenderCenteredText(
            GOD_CREDIT_TEXT,
            RESOURCES::AssetId::FONT_TEXTURE,
            current_credit_text_screen_rectangle,
            CREDITS_TEXT_COLOR);

        // RENDER ADDITIONAL CREDITS FOR INDIVIDUAL PEOPLE.
        // Some additional spacing is added to help offset this credit text from other text.
        const float SPACING_BEFORE_REMAINING_CREDITS = (2 * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS);
        float current_credits_text_top_y_position_in_pixels = 
            start_of_credits_top_y_position_in_pixels +
            GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS +
            SPACING_BEFORE_REMAINING_CREDITS;
        current_credit_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions(
            screen_left_x_position,
            current_credits_text_top_y_position_in_pixels,
            screen_width_in_pixels,
            SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS);
        renderer.RenderCenteredText(
            "Programming - Jacob Pike",
            RESOURCES::AssetId::FONT_TEXTURE,
            current_credit_text_screen_rectangle,
            CREDITS_TEXT_COLOR);

        const MATH::Vector2f MOVE_DOWN_SINGLE_LINE(0, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS);
        current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE);        
        renderer.RenderCenteredText(
            "Graphics - Jacob Pike",
            RESOURCES::AssetId::FONT_TEXTURE,
            current_credit_text_screen_rectangle,
            CREDITS_TEXT_COLOR);

        current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE);
        renderer.RenderCenteredText(
            "Music - Chad Pike",
            RESOURCES::AssetId::FONT_TEXTURE,
            current_credit_text_screen_rectangle,
            CREDITS_TEXT_COLOR);

        // RENDER ADDITIONAL CREDITS FOR SOUND EFFECTS.
        current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE);
        current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE);
        renderer.RenderCenteredText(
            "ANIMAL SOUNDS",
            RESOURCES::AssetId::FONT_TEXTURE,
            current_credit_text_screen_rectangle,
            CREDITS_TEXT_COLOR);

        current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE);
        renderer.RenderCenteredText(
            "soundbible.com",
            RESOURCES::AssetId::FONT_TEXTURE,
            current_credit_text_screen_rectangle,
//.........这里部分代码省略.........
开发者ID:jpike,项目名称:noah_ark,代码行数:101,代码来源:CreditsScreen.cpp


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