Created
August 5, 2016 09:09
-
-
Save underdoeg/743afb0769272a480781976c0d54a853 to your computer and use it in GitHub Desktop.
Simple property animation with cluttermm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cluttermm.h> | |
#include <gdkmm/wrap_init.h> | |
#include <gdkmm/pixbuf.h> | |
#include <iostream> | |
int main(int argc, char *argv[]) | |
{ | |
Glib::init(); //Otherwise Gdk::wrap_init() will fail. | |
Gdk::wrap_init(); //TODO: Add a Gdk::init() in gtkmm? | |
try | |
{ | |
// initialize the C++ wrapper types | |
Clutter::init(&argc, &argv); | |
} | |
catch(const Glib::Exception& ex) | |
{ | |
std::cerr << "Failed to initialize clutter: " << ex.what() << std::endl; | |
return -1; | |
} | |
auto stage = Clutter::Stage::create(); | |
stage->set_size(1920, 1080); | |
stage->set_title("Actors Test"); | |
auto actor = Clutter::Actor::create(); | |
actor->set_geometry(Clutter::Geometry(200, 200, 500, 500)); | |
actor->set_background_color(Clutter::Color(20, 20, 20, 255)); | |
stage->add_child(actor); | |
stage->show(); | |
//animate with a transition | |
auto transition = Clutter::PropertyTransition::create("x"); | |
transition->set_duration(500); | |
transition->set_to(1500); | |
transition->set_from(0); | |
transition->set_auto_reverse(true); | |
transition->set_loop(true); | |
actor->add_transition("test", transition); | |
transition->start(); | |
/* | |
timeline->start(); | |
actor->save_easing_state(); | |
actor->set_position(1000, 0); | |
actor->restore_easing_state(); | |
*/ | |
// TODO: wrap clutter_main ? | |
Clutter::main(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment