Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. package com.mygdx.slider;
  2.  
  3. import com.badlogic.gdx.ApplicationAdapter;
  4. import com.badlogic.gdx.Gdx;
  5. import com.badlogic.gdx.graphics.GL20;
  6. import com.badlogic.gdx.graphics.Texture;
  7. import com.badlogic.gdx.graphics.g2d.BitmapFont;
  8. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  9. import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
  10.  
  11. public class Main extends ApplicationAdapter {
  12. private SpriteBatch batch;
  13. private Texture img;
  14. private ShapeRenderer shape;
  15. private MySlider slider;
  16. private BitmapFont text;
  17.  
  18. @Override
  19. public void create() {
  20. text = new BitmapFont();
  21. shape = new ShapeRenderer();
  22. // not work min -10, max -30
  23. slider = new MySlider(100, 100, 320, 100, -10, 33);
  24. batch = new SpriteBatch();
  25. img = new Texture("badlogic.jpg");
  26. }
  27.  
  28. @Override
  29. public void render() {
  30.  
  31. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  32. Gdx.gl.glEnable(GL20.GL_BLEND);
  33. batch.begin();
  34. batch.draw(img, 0, 0);
  35. text();
  36. batch.end();
  37.  
  38. shape.setAutoShapeType(true);
  39. shape.begin();
  40. slider.showSlider(shape);
  41. shape.end();
  42.  
  43. slider.dragSlider();
  44. }
  45.  
  46. private void text() {
  47. float x = 20;
  48. float y = Gdx.graphics.getHeight();
  49. float jump = y / 30;
  50. y -= jump;
  51. text.draw(batch, "Min = " + slider.getMin(), x, y);
  52. y -= jump;
  53. text.draw(batch, "Max = " + slider.getMax(), x, y);
  54. y -= jump;
  55. text.draw(batch, "Current position = " + slider.getCurrent(), x, y);
  56. }
  57.  
  58. @Override
  59. public void dispose() {
  60. batch.dispose();
  61. img.dispose();
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement