Back to project page SpaceGame.
The source code is released under:
Copyright (c) 2012 ??ukasz Patalas Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the So...
If you think the Android project SpaceGame listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.lpatalas.spacegame; //w w w .j a va2 s.co m import com.badlogic.gdx.Gdx; import com.badlogic.gdx.InputAdapter; import com.badlogic.gdx.math.Vector2; /** * User: Lukasz * Date: 11.08.12 */ class PlayerInputProcessor extends InputAdapter { private final GameplayScreen game; private final Player player; public PlayerInputProcessor(GameplayScreen game, Player player) { this.game = game; this.player = player; } @Override public boolean touchDown(int x, int y, int pointer, int button) { if (game.isRunning()) { movePlayerToPosition(x, y); } else { game.resetGame(); } return true; } @Override public boolean touchDragged(int x, int y, int pointer) { if (game.isRunning()) { movePlayerToPosition(x, y); return true; } return super.touchDragged(x, y, pointer); } private void movePlayerToPosition(int x, int y) { Vector2 position = transformPosition(x, y); player.moveTo(position); } private static Vector2 transformPosition(float x, float y) { return new Vector2(x, Gdx.graphics.getHeight() - y); } }