Example usage for com.badlogic.gdx.physics.box2d Contact isTouching

List of usage examples for com.badlogic.gdx.physics.box2d Contact isTouching

Introduction

In this page you can find the example usage for com.badlogic.gdx.physics.box2d Contact isTouching.

Prototype

public boolean isTouching() 

Source Link

Usage

From source file:com.me.main.startgame.java

License:Apache License

private boolean isPlayerGrounded(float deltaTime) {
    Array<Contact> contactList = world.getContactList();
    for (int i = 0; i < contactList.size; i++) {
        Contact contact = contactList.get(i);
        if (contact.isTouching() && (contact.getFixtureA() == playerSensorFixture
                || contact.getFixtureB() == playerSensorFixture)) {

            Vector2 pos = player.getPosition();
            WorldManifold manifold = contact.getWorldManifold();
            boolean below = true;
            for (int j = 0; j < manifold.getNumberOfContactPoints(); j++) {
                below &= (manifold.getPoints()[j].y < pos.y - 0.1f);
            }//from   ww w .ja  v a 2 s  .c  o  m
            if (below) {
                return true;
            }
            return false;
        }
    }
    return false;
}