public class TempScreen extends Screen
{
Game game; // the class which is implementing the InputProcessor
SpriteBatch batcher;
Vector3 touchPoint;
OrthographicCamera cam;
InputMultiplexer multiplexer;
GestureListener listener=new GestureListener()
{
@Override
public boolean zoom(float initialDistance, float distance)
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean touchDown(float x, float y, int pointer, int button)
{
cam.unproject(touchPoint.set(x, y, 0));
System.out.println(touchPoint);
return false;
}
@Override
public boolean tap(float x, float y, int count, int button)
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
Vector2 pointer1, Vector2 pointer2)
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean panStop(float x, float y, int pointer, int button)
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean pan(float x, float y, float deltaX, float deltaY)
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean longPress(float x, float y)
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean fling(float velocityX, float velocityY, int button)
{
// TODO Auto-generated method stub
return false;
}
};
GestureDetector detector=new GestureDetector(listener)
{
public boolean touchUp(float x, float y, int pointer, int button)
{
cam.unproject(touchPoint.set(x, y, 0));
System.out.println(touchPoint);
return false;
}
};
public TempScreen(Game game,SpriteBatch batcher)
{
super(game);
this.batcher=batcher;
this.game=game;
touchPoint = new Vector3();
cam = new OrthographicCamera(GameConstants.CAMERA_WIDTH,GameConstants.CAMERA_HEIGHT);
cam.position.set(GameConstants.CAMERA_WIDTH/2,GameConstants.CAMERA_HEIGHT/2, 0);
multiplexer = new InputMultiplexer();
multiplexer.addProcessor(game);
multiplexer.addProcessor(detector);
Gdx.input.setInputProcessor(multiplexer);
}
@Override
public void render(float deltaTime)
{
update(deltaTime);
GLCommon gl = Gdx.gl;
gl.glClearColor(0, 0f, 1f, 0.1f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
cam.update();
batcher.setProjectionMatrix(cam.combined);
batcher.enableBlending();
batcher.begin();
draw(deltaTime);
batcher.end();
}
@Override
public void draw(float deltaTime)
{
// TODO Auto-generated method stub
}
@Override
public void update(float deltaTime)
{
// TODO Auto-generated method stub
}
@Override
public void backKeyPressed()
{
// TODO Auto-generated method stub
}
}
РАСЧ может иметь широкий спектр классов, так что вы можете изменить их внутри метода –
это один для родной андроида? – Vineet
Я не делал андроид через год или 2, но из памяти это должно работать –