Search in sources :

Example 11 with RigidBody

use of ilargia.egdx.logicbricks.component.game.RigidBody in project Entitas-Java by Rubentxu.

the class PointerOverSensorSystem method isOver.

private boolean isOver(PointerOverSensor sensor, int pointer) {
    PointerState<Vector2, Vector3> touchState = inputManager.getTouchState(pointer);
    if (touchState.down) {
        Set<GameEntity> targets = Indexed.getTagEntities(sensor.targetTag);
        for (GameEntity target : targets) {
            TextureView view = target.getTextureView();
            RigidBody rigidBody = target.getRigidBody();
            if (view != null && rigidBody != null) {
                testRectangle.setPosition(rigidBody.body.getPosition().x, rigidBody.body.getPosition().y);
                testRectangle.setSize(view.bounds.extentsX * 2, view.bounds.extentsY * 2);
                return testRectangle.contains(touchState.coordinates.x, touchState.coordinates.y);
            }
        }
    }
    return false;
}
Also used : GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) Vector2(com.badlogic.gdx.math.Vector2) Vector3(com.badlogic.gdx.math.Vector3) TextureView(ilargia.egdx.logicbricks.component.game.TextureView) RigidBody(ilargia.egdx.logicbricks.component.game.RigidBody)

Aggregations

RigidBody (ilargia.egdx.logicbricks.component.game.RigidBody)11 GameEntity (ilargia.egdx.logicbricks.gen.game.GameEntity)9 Transform (com.badlogic.gdx.physics.box2d.Transform)4 Vector3 (com.badlogic.gdx.math.Vector3)3 Vector2 (com.badlogic.gdx.math.Vector2)2 FixtureDef (com.badlogic.gdx.physics.box2d.FixtureDef)2 CameraActuator (ilargia.egdx.logicbricks.component.actuator.CameraActuator)2 ParticleEffectActuator (ilargia.egdx.logicbricks.component.actuator.ParticleEffectActuator)2 VelocityActuator (ilargia.egdx.logicbricks.component.actuator.VelocityActuator)2 SensorEntity (ilargia.egdx.logicbricks.gen.sensor.SensorEntity)2 TextureView (ilargia.egdx.logicbricks.component.game.TextureView)1 NearSensor (ilargia.egdx.logicbricks.component.sensor.NearSensor)1 RadarSensor (ilargia.egdx.logicbricks.component.sensor.RadarSensor)1