Can now apply a shader using the animation's timer but not sure if there should be shaders on animations or outside or both.
This commit is contained in:
parent
0d481a5ab7
commit
80f100f223
5 changed files with 29 additions and 10 deletions
|
|
@ -38,11 +38,10 @@ namespace animator {
|
|||
$window.setPosition({0,0});
|
||||
|
||||
$ui.init($sprite_name, $background, new_size.x, new_size.y);
|
||||
$sprite = $ui.get_sprite();
|
||||
|
||||
// need to keep these around
|
||||
$pos = $sprite->getPosition();
|
||||
$scale = $sprite->getScale();
|
||||
$pos = $ui.sprite->getPosition();
|
||||
$scale = $ui.sprite->getScale();
|
||||
|
||||
if(YES_SYNC) {
|
||||
$window.setVerticalSyncEnabled(VSYNC);
|
||||
|
|
@ -95,6 +94,9 @@ namespace animator {
|
|||
$ui.update_status($anim);
|
||||
state(State::START);
|
||||
break;
|
||||
case Event::TEST_SHADER:
|
||||
$ui.effect = $ui.effect == nullptr ? shaders::get("flame") : nullptr;
|
||||
break;
|
||||
default:
|
||||
state(State::START);
|
||||
}
|
||||
|
|
@ -129,8 +131,9 @@ namespace animator {
|
|||
void FSM::run_animation() {
|
||||
if($anim.playing) {
|
||||
$anim.update();
|
||||
$anim.apply(*$sprite);
|
||||
$anim.motion(*$sprite, $pos, $scale);
|
||||
$anim.apply(*$ui.sprite);
|
||||
if($ui.effect != nullptr) $anim.apply_effect($ui.effect);
|
||||
$anim.motion(*$ui.sprite, $pos, $scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +212,8 @@ namespace animator {
|
|||
} else if($router.scancode == KEY::M) {
|
||||
$mute = !$mute;
|
||||
sound::mute($mute);
|
||||
} else if($router.scancode == KEY::S) {
|
||||
event(Event::TEST_SHADER);
|
||||
}
|
||||
break;
|
||||
case MOUSE_CLICK:
|
||||
|
|
@ -246,9 +251,13 @@ namespace animator {
|
|||
}
|
||||
|
||||
auto viewer = $ui.entity("viewer");
|
||||
$ui.set<guecs::Sprite>(viewer, { sprite_name, 0, false});
|
||||
|
||||
// BUG: this is some jank bullshit but it works
|
||||
$ui.set<guecs::Sprite>(viewer, {sprite_name, 0, false});
|
||||
$ui.init();
|
||||
sprite = $ui.get<guecs::Sprite>(viewer).sprite;
|
||||
dbc::check(sprite != nullptr, "failed to initialize $ui.sprite");
|
||||
|
||||
$ui.remove<guecs::Sprite>(viewer);
|
||||
|
||||
$overlay.position(0, 0, width/4, height/4);
|
||||
$overlay.layout(
|
||||
|
|
@ -264,6 +273,7 @@ namespace animator {
|
|||
|
||||
void UI::render(sf::RenderWindow& window, bool debug) {
|
||||
$ui.render(window);
|
||||
window.draw(*sprite, effect.get());
|
||||
$overlay.render(window);
|
||||
|
||||
if(debug) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue