Tag Archives: Intervals

Android frame Animation

By | April 23, 2011

A series of frames is drawn one after the other at regular intervals. For this create a xml which contains ImageView for showing the animation [xml] <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="#FFFFFF" android:gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/Image" android:layout_gravity="center_horizontal" android:layout_width="wrap_content" android:background="@drawable/d1" android:layout_height="wrap_content"/> <Button android:id="@+id/startFAButtonId" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="wrap_content" android:text="Start Animation" /> </LinearLayout> [/xml] The main java file is… Read More »

How to rotate a body manually in Box2D?

By | January 24, 2011

The below code helps you to rotate a body in Box2D manually. [java] -(void) start { rot_sprite = [CCSprite spriteWithFile:[NSString stringWithFormat:@"rot_sprite.png" ]]; [self addChild: rot_sprite]; b2BodyDef bodyDef; b2Vec2 initVel; b2PolygonShape shape; b2CircleShape circleShape; b2FixtureDef fd; b2Body * rotating_body; b2RevoluteJointDef revJointDef; b2DistanceJointDef jointDef; b2Vec2 pos; bodyDef.position.Set(11.043825f, 4.984064f); bodyDef.angle = 0.000000f; bodyDef.userData = rot_sprite; rotating_body = world-&gt;CreateBody(&amp;bodyDef;); initVel.Set(0.000000f, 0.000000f); rotating_body-&gt;SetLinearVelocity(initVel);… Read More »