Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public class GameScreen implements Screen
  2. {
  3. private Stage stage;
  4. private Dino dino;
  5. private SpaceMonster spaceMonster;
  6. private Sound spacebarSound;
  7.  
  8. public GameScreen(final ScreenManager gam)
  9. {
  10. this.game = gam;
  11.  
  12. stage = new Stage(new FitViewport(800, 480));
  13. Gdx.input.setInputProcessor(stage);
  14.  
  15. dino = new Dino();
  16. spaceMonster = new SpaceMonster();
  17.  
  18. stage.addActor(dino);
  19. stage.addActor(spaceMonster);
  20.  
  21. spacebarSound = Gdx.audio.newSound(Gdx.files.internal("data/spacebarSound.mp3"));
  22. }
  23.  
  24. @Override
  25. public void resize(int width, int height)
  26. {
  27. }
  28.  
  29. @Override
  30. public void render(float delta)
  31. {
  32. Gdx.gl.glClearColor(0, 0, 0, 0);
  33. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  34. stage.act(Gdx.graphics.getDeltaTime());
  35. stage.draw();
  36.  
  37. for (Rectangle spacebarRectangle : spacebar.getSpacebarRectangles()) // section of code
  38. if (spacebarRectangle.overlaps(dino.getDinoRectangle()))
  39. spacebarSound.play();
  40. }
  41.  
  42. @Override
  43. public void pause()
  44. {
  45. }
  46.  
  47. @Override
  48. public void resume()
  49. {
  50. }
  51.  
  52. @Override
  53. public void show()
  54. {
  55. }
  56.  
  57. @Override
  58. public void hide()
  59. {
  60. }
  61.  
  62. @Override
  63. public void dispose()
  64. {
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement