private Entity buildPuffin(World world) { Entity e = engine.createEntity(); e.add(new PuffinComponent()); AnimationComponent a = new AnimationComponent(); a.animations.put( "DEFAULT", new Animation(1f / 16f, Assets.getPuffinArray(), Animation.PlayMode.LOOP)); a.animations.put( "RUNNING", new Animation(1f / 16f, Assets.getPuffinRunArray(), Animation.PlayMode.LOOP)); e.add(a); StateComponent state = new StateComponent(); state.set("DEFAULT"); e.add(state); TextureComponent tc = new TextureComponent(); e.add(tc); TransformComponent tfc = new TransformComponent(); tfc.position.set(10f, 10f, 1f); tfc.rotation = 15f; tfc.scale.set(0.25f, 0.25f); e.add(tfc); BodyComponent bc = new BodyComponent(); BodyDef bodyDef = new BodyDef(); // We set our body to dynamic, for something like ground which doesn't move we would set it to // StaticBody bodyDef.type = BodyDef.BodyType.DynamicBody; // Set our body's starting position in the world bodyDef.position.set(10f, 23f); // Create our body in the world using our body definition bc.body = world.createBody(bodyDef); bc.body.applyAngularImpulse(50f, true); // Create a circle shape and set its radius to 6 CircleShape circle = new CircleShape(); circle.setRadius(2f); // Create a fixture definition to apply our shape to FixtureDef fixtureDef = new FixtureDef(); fixtureDef.shape = circle; fixtureDef.density = 20f; fixtureDef.friction = 0.4f; fixtureDef.restitution = 0.6f; // Make it bounce a little bit // Create our fixture and attach it to the body bc.body.createFixture(fixtureDef); // Remember to dispose of any shapes after you're done with them! // BodyDef and FixtureDef don't need disposing, but shapes do. circle.dispose(); e.add(bc); return e; }