Camera for the storyboard can now do pan, bounce, dolly, and shake.
This commit is contained in:
parent
0d326089f7
commit
29409c54ce
5 changed files with 23 additions and 15 deletions
|
|
@ -39,7 +39,7 @@
|
|||
"_type": "Animation",
|
||||
"easing": 1,
|
||||
"motion": 0,
|
||||
"ease_rate": 0.5,
|
||||
"ease_rate": 1.0,
|
||||
"min_x": 0.8,
|
||||
"min_y": 0.8,
|
||||
"max_x": 1.0,
|
||||
|
|
@ -55,13 +55,13 @@
|
|||
},
|
||||
"bounce": {
|
||||
"_type": "Animation",
|
||||
"easing": 3,
|
||||
"easing": 4,
|
||||
"motion": 2,
|
||||
"ease_rate": 0.05,
|
||||
"min_x": -10,
|
||||
"min_y": -10,
|
||||
"max_x": 10,
|
||||
"max_y": 10,
|
||||
"ease_rate": 0.001,
|
||||
"min_x": 0,
|
||||
"min_y": -20,
|
||||
"max_x": 0,
|
||||
"max_y": 0,
|
||||
"simple": true,
|
||||
"frames": 1,
|
||||
"speed": 0.01,
|
||||
|
|
|
|||
17
camera.cpp
17
camera.cpp
|
|
@ -40,15 +40,22 @@ namespace cinematic {
|
|||
anim = MGR.animations.at(name);
|
||||
}
|
||||
|
||||
void Camera::position(float x, float y) {
|
||||
anim.min_x = x;
|
||||
anim.min_y = y;
|
||||
void Camera::focus(float x, float y) {
|
||||
position.x = x;
|
||||
position.y = y;
|
||||
}
|
||||
|
||||
void Camera::move(sf::RenderTexture& target, sf::Vector2f pos) {
|
||||
sf::View zoom;
|
||||
anim.max_x = pos.x;
|
||||
anim.max_y = pos.y;
|
||||
|
||||
// BUG: annoying special case
|
||||
if(anim.motion == ease::SLIDE) {
|
||||
anim.min_x = position.x;
|
||||
anim.min_y = position.y;
|
||||
anim.max_x = pos.x;
|
||||
anim.max_y = pos.y;
|
||||
}
|
||||
|
||||
anim.apply(zoom, pos, size);
|
||||
target.setView(zoom);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace cinematic {
|
|||
components::Animation anim;
|
||||
sf::View view;
|
||||
sf::Vector2f size;
|
||||
sf::Vector2f position;
|
||||
|
||||
Camera();
|
||||
|
||||
|
|
@ -14,7 +15,7 @@ namespace cinematic {
|
|||
void move(sf::RenderTexture& target, sf::Vector2f pos);
|
||||
bool playing();
|
||||
void play();
|
||||
void position(float x, float y);
|
||||
void focus(float x, float y);
|
||||
void style(const std::string &name);
|
||||
};
|
||||
|
||||
|
|
|
|||
2
main.cpp
2
main.cpp
|
|
@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
|
|||
cinematic::init();
|
||||
GameDB::init();
|
||||
|
||||
if(DEBUG_BUILD) sound::mute(true);
|
||||
sound::mute(true);
|
||||
|
||||
gui::FSM main;
|
||||
main.event(gui::Event::STARTED);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace storyboard {
|
|||
|
||||
bool UI::mouse(float x, float y, guecs::Modifiers mods) {
|
||||
auto& cell = $ui.cell_for($zoom_target);
|
||||
$camera.position(cell.mid_x, cell.mid_y);
|
||||
$camera.focus(cell.mid_x, cell.mid_y);
|
||||
|
||||
$zoom_target = *$ui.$parser.hit(x, y);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue