Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. 1.1156368
  2. -0.13125038
  3. -1.0500145
  4. 0.98439217
  5. -1.0500202
  6. 0.91877174
  7. -0.984396
  8. 0.9187679
  9. -0.98439026
  10. 0.9187641
  11. -0.13125038
  12.  
  13. public void pan (InputEvent event, float x, float y, float deltaX, float deltaY) {
  14. cam.translate(-deltaX, -deltaY);
  15.  
  16. cam.translate(-deltaX / 2, -deltaY / 2);
  17.  
  18. public void pan (InputEvent event, float x, float y, float deltaX, float deltaY) {
  19. camera.position.add((-x), (y), 0);
  20. camera.update();
  21. }
  22.  
  23. private Vector3 prevDragPos;
  24. addListener(new InputListener(){
  25. @Override
  26. public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
  27. return true;
  28. }
  29.  
  30. @Override
  31. public void touchDragged(InputEvent event, float x, float y, int pointer) {
  32. x = Gdx.input.getX(pointer);
  33. y = Gdx.input.getY(pointer);
  34. if(prevDragPos == null) prevDragPos = new Vector3(x, y, 0);
  35.  
  36. float scale = ((MapStage) getStage()).getScale();
  37. getStage().getCamera().position.add((prevDragPos.x - x)/scale, (y - prevDragPos.y)/scale, 0);
  38. System.out.println((prevDragPos.x - x)/scale + ", " + (y - prevDragPos.y)/scale);
  39. prevDragPos.set(x, y, 0);
  40. }
  41.  
  42. @Override
  43. public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
  44. prevDragPos = null ;
  45. }
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement