Search in sources :

Example 11 with PhysicsComponent

use of com.gemserk.commons.artemis.components.PhysicsComponent in project commons-gdx by gemserk.

the class AntiGravitySystem method process.

@Override
protected void process(Entity e) {
    PhysicsComponent physicsComponent = Components.getPhysicsComponent(e);
    Body body = physicsComponent.getPhysics().getBody();
    Vector2 gravity = body.getWorld().getGravity();
    tmp.set(gravity).mul(-body.getMass());
    body.applyForceToCenter(tmp);
}
Also used : PhysicsComponent(com.gemserk.commons.artemis.components.PhysicsComponent) Vector2(com.badlogic.gdx.math.Vector2) Body(com.badlogic.gdx.physics.box2d.Body)

Aggregations

PhysicsComponent (com.gemserk.commons.artemis.components.PhysicsComponent)11 Body (com.badlogic.gdx.physics.box2d.Body)4 ImmediateModePhysicsListener (com.gemserk.commons.artemis.components.PhysicsComponent.ImmediateModePhysicsListener)3 Vector2 (com.badlogic.gdx.math.Vector2)2 Entity (com.artemis.Entity)1 Fixture (com.badlogic.gdx.physics.box2d.Fixture)1 HitComponent (com.gemserk.commons.artemis.components.HitComponent)1 LinearVelocityLimitComponent (com.gemserk.commons.artemis.components.LinearVelocityLimitComponent)1 Trigger (com.gemserk.commons.artemis.triggers.Trigger)1 Contacts (com.gemserk.commons.gdx.box2d.Contacts)1 Contact (com.gemserk.commons.gdx.box2d.Contacts.Contact)1