On Sun, Mar 8, 2009 at 7:31 PM, Steve Starr <[email protected]> wrote:
> This is another request for a simple clutter-box2d example.
> Something easy like a rectangle falling would be great. The provided
> examples are just to involved for newbs to start with and moblin doesn't
> have any examples for clutter-box2d anymore.
A minimal sample with a static and a dynamic actor follows, at the
moment there is no way to apply force or torque to an actor
programatically (it only happens as a consequence of manipulation or
indirectly when colliding with another actor that has had its linear
velocity set.) See bug #1146 in the clutter bugzilla, patches are
welcome.)
#include <clutter/clutter.h>
#include <clutter-box2d.h>
gint main (gint argc, gchar **argv)
{
ClutterColor black = {0,0,0,0xff};
ClutterColor green = {0,0,0,0xff};
ClutterActor *stage;
ClutterActor *box2d;
ClutterActor *box;
gint i;
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &black);
clutter_actor_show (stage);
/* create a new box2d container and add it to the stage */
box2d = clutter_box2d_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box2d);
/* create a dynamic actor */
box = clutter_rectangle_new ();
clutter_actor_set_size (box, 42, 42);
clutter_actor_set_position (box, 50 + i, 20);
clutter_container_add_actor (CLUTTER_CONTAINER (box2d), box);
/* ser child properties, that the actor have as a consequence of
* being in the box2d container
*/
clutter_container_child_set (CLUTTER_CONTAINER (box2d), box,
"mode", CLUTTER_BOX2D_DYNAMIC,
"manipulatable", TRUE,
NULL);
/* create a static actor */
box = clutter_rectangle_new ();
clutter_actor_set_size (box, 300, 23);
clutter_actor_set_position (box, 0, 250);
clutter_container_add_actor (CLUTTER_CONTAINER (box2d), box);
clutter_container_child_set (CLUTTER_CONTAINER (box2d), box,
"mode", CLUTTER_BOX2D_STATIC,
NULL);
/* start simulating */
clutter_box2d_set_simulating (CLUTTER_BOX2D (box2d), TRUE);
/* enter clutters main loop */
clutter_main ();
return 0;
}
--
Øyvind Kolås, Intel Open Source Technology Center
--
To unsubscribe send a mail to [email protected]