38 const math::fvec2 viewport_center = viewport_size * 0.5f;
43 credits_text.
set_color({1.0f, 1.0f, 1.0f, 0.0f});
47 const auto& credits_aabb = credits_text.
get_bounds();
48 float credits_w = credits_aabb.
max.
x() - credits_aabb.min.x();
49 float credits_h = credits_aabb.max.y() - credits_aabb.min.y();
53 const float credits_fade_in_duration = 0.5;
54 const float credits_scroll_duration = 5.0;
56 auto set_credits_opacity = [
this](
int channel,
const float& opacity)
58 this->credits_text.
set_color({1.0f, 1.0f, 1.0f, opacity});
65 credits_fade_in_opacity_channel->
insert_keyframe({credits_fade_in_duration, 1.0f});
69 ctx.
animator->add_animation(&credits_fade_in_animation);
72 credits_fade_in_animation.
play();
75 window_resized_subscription =
ctx.
window->get_resized_channel().subscribe
77 [&](
const auto&
event)
80 const math::fvec2 viewport_center = viewport_size * 0.5f;
81 const auto& credits_aabb = credits_text.
get_bounds();
82 float credits_w = credits_aabb.
max.
x() - credits_aabb.min.x();
83 float credits_h = credits_aabb.max.y() - credits_aabb.min.y();
89 auto skip = [&](
const auto&
event)
103 input_mapped_subscriptions.emplace_back
110 input_mapped_subscriptions.emplace_back
117 input_mapped_subscriptions.emplace_back
145 input_mapped_subscriptions.clear();
151 ctx.
animator->remove_animation(&credits_fade_in_animation);
void play()
Plays the animation.
Single channel in a keyframe animation.
void insert_keyframe(const keyframe &k)
Adds a keyframe to the animation.
void set_interpolator(interpolator_type interpolator)
Sets the frame interpolator function object.
channel * add_channel(int id)
Adds a channel to the animation.
void set_frame_callback(std::function< void(int, const T &)> callback)
Sets the callback that's executed on each frame of animation.
credits_state(::game &ctx)
Abstract base class for game states.
std::unique_ptr< scene::collection > ui_scene
hsm::state_machine< game_state > state_machine
std::unique_ptr< animator > animator
type::bitmap_font menu_font
std::shared_ptr< app::window > window
std::queue< std::function< void()> > function_queue
std::shared_ptr< render::material > menu_font_material
input::mapper input_mapper
std::unique_ptr< app::input_manager > input_manager
void set_translation(const vector_type &translation)
Sets the translation of the object.
void set_content(const std::string &content)
Sets the text content.
void set_color(const math::fvec4 &color)
Sets the text color.
const aabb_type & get_bounds() const noexcept override
Returns the bounds of the object.
void set_material(std::shared_ptr< render::material > material)
Sets the text material.
void set_font(const type::bitmap_font *font)
Sets the text font.
log_message< log_message_severity::trace, Args... > log_trace
Formats and logs a trace message.
Publish-subscribe messaging.
constexpr vector< T, N > round(const vector< T, N > &x)
Performs a element-wise round operation.
std::string get_string(const ::game &ctx, hash::fnv1a32_t key)
Returns a localized string.
Container for templated easing functions.
vector_type max
Maximum extent of the hyperrectangle.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.