Commits

josemaria.alkala committed 6b81ec9

Animation based on state

Comments (0)

Files changed (1)

clutter_animation.rst

-Clutter: animation
-==================
+Clutter: animations
+===================
 
 Simple implicit animations
 --------------------------
 
       Clutter.main()
 
+more information about `Implicit animations <http://docs.clutter-project.org/docs/clutter/stable/clutter-Implicit-Animations.html>`_.
+
+Animation based on state
+------------------------
+
+The following code is failing for some reason (any help is welcomed)::
+
+  #!/usr/bin/env python
+  #! -*- coding: utf-8 -*-
+
+  from gi.repository import Clutter
+  import sys
+
+  def keyPress(self, event, _transitions):
+      Clutter.State.set_state(_transitions, "move-down")
+
+  if __name__ == '__main__':
+      Clutter.init( sys.argv )
+
+      # Create Stage
+      _stage = Clutter.Stage()
+      _stage.set_title( "Animation using states" )
+      _stage.set_size( 400, 400 )
+
+      # Create Actor
+      _red = Clutter.Color().new(255, 0, 0, 255) # R,G,B,alpha
+      _actor = Clutter.Text().new_full( 
+		    "Mono 10", 
+		    "Press any key...", 
+		    _red )
+
+      _actor.set_position( 100.0,100.0 )
+
+      # Transition
+      # - State creation
+      _transitions = Clutter.State()
+
+
+
+      # - Defines de behaviour of a number of actors 
+      _transitions.set_key( None, "move-down",  # source_state, target_state
+	    _actor, "x", Clutter.AnimationMode.EASE_OUT_CUBIC, 300,
+	    pre_delay=0.0, post_delay=0.0)
+
+      # - All state transitions take 250ms
+      _transitions.set_duration(None,None,3000) 
+
+      # Add Actor to the Stage
+      _stage.add_actor( _actor )
+      _stage.connect("destroy", lambda w: Clutter.main_quit() )    
+      _stage.connect('key-press-event', keyPress, _transitions)
+
+      _stage.show_all()
+
+      # Create animation
+
+
+      Clutter.main()
+