Android Open Source - acceptableLosses Gesture Detector Controller






From Project

Back to project page acceptableLosses.

License

The source code is released under:

MIT License

If you think the Android project acceptableLosses listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package acceptableLosses.controls;
//from www .  ja va 2s  .c o  m
import acceptableLosses.map.MapTools;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.math.Vector2;

public class GestureDetectorController implements GestureDetector.GestureListener {

    private OrthographicCamera camera;

    private InputManager inputManager;


    public GestureDetectorController(OrthographicCamera camera, InputManager inputManager) {
        this.camera = camera;
        this.inputManager = inputManager;
    }

    @Override
    public boolean touchDown(float x, float y, int pointer, int button) {
        return false;
    }

    @Override
    public boolean tap(float x, float y, int count, int button) {

        inputManager.tapCommand(MapTools.window2world(Gdx.input.getX(), Gdx.input.getY(), camera));

        return false;
    }


    @Override
    public boolean longPress(float x, float y) {
        //TODO: Should pop open spell and special ability menu
        return false;
    }

    @Override
    public boolean fling(float velocityX, float velocityY, int button) {
        //TODO: movement?  of camera or player?
        return false;
    }

    @Override
    public boolean pan(float x, float y, float deltaX, float deltaY) {

        camera.translate(-deltaX * camera.zoom, deltaY * camera.zoom);
        return false;
    }

    @Override
    public boolean panStop(float x, float y, int pointer, int button) {
        return false;
    }

    @Override
    public boolean zoom(float initialDistance, float distance) {
        //TODO: this zooms to fast when zoomed in, should change by a percentage
        float dd = (initialDistance - distance) * 0.0001f;
        if (dd > 0f && camera.zoom < 1f)
            camera.zoom += dd * camera.zoom;
        else if (dd < 0f && camera.zoom > 0.1f) {
            camera.zoom += dd * camera.zoom;
        }
        return false;
    }

    @Override
    public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) {
        return false;
    }


}




Java Source Code List

acceptableLosses.AcceptableLossesGame.java
acceptableLosses.android.AndroidLauncher.java
acceptableLosses.assets.AssetLoader.java
acceptableLosses.assets.FurnitureType.java
acceptableLosses.assets.TileType.java
acceptableLosses.components.Appearance.java
acceptableLosses.components.Cargo.java
acceptableLosses.components.Citizen.java
acceptableLosses.components.Destination.java
acceptableLosses.components.Health.java
acceptableLosses.components.Path.java
acceptableLosses.components.Position.java
acceptableLosses.components.Resume.java
acceptableLosses.components.Sentience.java
acceptableLosses.components.Task.java
acceptableLosses.controls.GestureDetectorController.java
acceptableLosses.controls.InputManager.java
acceptableLosses.controls.ZoomInputProcessor.java
acceptableLosses.controls.commands.Command.java
acceptableLosses.controls.commands.TapCommand.java
acceptableLosses.desktop.DesktopLauncher.java
acceptableLosses.desktop.ImagePacker.java
acceptableLosses.map.AsteroidGenerator.java
acceptableLosses.map.Chunk.java
acceptableLosses.map.Furniture.java
acceptableLosses.map.MapTools.java
acceptableLosses.map.Region.java
acceptableLosses.map.Spawner.java
acceptableLosses.pathing.FastNonOptimalHeuristic.java
acceptableLosses.screens.GameScreen.java
acceptableLosses.screens.SplashScreen.java
acceptableLosses.systems.AiSystem.java
acceptableLosses.systems.AppearanceRenderSystem.java
acceptableLosses.systems.ElevationSystem.java
acceptableLosses.systems.FurnitureRenderSystem.java
acceptableLosses.systems.JobAssignerSystem.java
acceptableLosses.systems.MapRenderSystem.java
acceptableLosses.systems.MovementSystem.java
acceptableLosses.systems.PathFinderSystem.java
acceptableLosses.work.CivilianMover.java
acceptableLosses.work.jobs.DigJob.java
acceptableLosses.work.jobs.Job.java