Guest User

Untitled

a guest
Feb 4th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public class Menu{
  2. private SpriteBatch menu;
  3. private int items = 1;
  4. Texture itemimg = new Texture("lucjan.jpg");
  5. private class Item{
  6. int x,y;
  7.  
  8. Item(int x, int y){
  9. this.x = x;
  10. this.y = y;
  11. menu.begin();
  12. menu.draw(itemimg, x,y);
  13. menu.end();
  14. }
  15.  
  16. public boolean Clicked(){
  17. if (Gdx.input.justTouched()) {
  18. Rectangle textureBounds=new Rectangle(this.x,this.y,itemimg.getWidth(),itemimg.getHeight());
  19. Vector3 tmp = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
  20. if(textureBounds.contains(tmp.x, tmp.y)){
  21. return true;
  22. }
  23. /*System.out.println(Gdx.input.getY()+" a obrazek zaczyna sie na "+this.y);
  24. if (Gdx.input.getX() > this.x && Gdx.input.getX()< this.x + itemimg.getWidth()) {
  25. if (Gdx.input.getY() > this.y && Gdx.input.getY() > (this.y + itemimg.getHeight())) {
  26. return true;
  27. }
  28. } */
  29.  
  30. }
  31. return false;
  32. }
  33. }
  34. Menu(){
  35. menu = new SpriteBatch();
  36. Item rozdzka = new Item(0,0);
  37. if (rozdzka.Clicked()){
  38. System.out.println("Kliknales rozdzke.");
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment