iMackshun

MainMenu.java

Feb 16th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.79 KB | None | 0 0
  1. package com.iMackshun.Games.Pixelformer.Screens;
  2.  
  3. import com.badlogic.gdx.Gdx;
  4. import com.badlogic.gdx.Screen;
  5. import com.badlogic.gdx.graphics.GL10;
  6. import com.badlogic.gdx.graphics.Texture;
  7. import com.badlogic.gdx.graphics.g2d.Animation;
  8. import com.badlogic.gdx.graphics.g2d.Sprite;
  9. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  10. import com.badlogic.gdx.graphics.g2d.TextureAtlas;
  11. import com.badlogic.gdx.graphics.g2d.TextureRegion;
  12. import com.iMackshun.Games.Pixelformer.PixelFormer;
  13. import com.iMackshun.Games.Pixelformer.Objects.FallingBackground;
  14. import com.iMackshun.Games.Pixelformer.Objects.ScrollingBackground;
  15.  
  16. public class MainMenu implements Screen{
  17.  
  18.     //Declarations
  19.     PixelFormer game;
  20.     int stateTime;
  21.     TextureRegion ScrollTexture, TitleTexture, PressStart0, PressStart1;
  22.     TextureAtlas GUI = new TextureAtlas("packs/PixelformerGUI.pack");
  23.     Sprite ScrollSprite1,ScrollSprite2, TitleSprite;
  24.     ScrollingBackground Scroll1,Scroll2;
  25.     FallingBackground TitleFallbg;
  26.     SpriteBatch batch;
  27.     Animation anim;
  28.        
  29.     //Constructor
  30.     public MainMenu(PixelFormer game){
  31.         this.game = game;
  32.     }
  33.    
  34.     @Override
  35.     public void render(float delta) {
  36.         Gdx.app.log(PixelFormer.LOG, "BGY is" + Scroll1.getYToLoop());
  37.         Gdx.gl.glClearColor(0, 0, 0, 1);
  38.         Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  39.         stateTime += Gdx.graphics.getDeltaTime();
  40.         Scroll1.update();
  41.         Scroll2.update();
  42.         TitleFallbg.update();
  43.         TitleSprite.setPosition(TitleFallbg.getBgX(), TitleFallbg.getBgY());
  44.         ScrollSprite1.setPosition(Scroll1.getBgX(), Scroll1.getBgY());
  45.         ScrollSprite2.setPosition(Scroll2.getBgX(), Scroll2.getBgY());
  46.         batch.begin();     
  47.         ScrollSprite1.draw(batch);
  48.         ScrollSprite2.draw(batch);
  49.         TitleSprite.draw(batch);
  50.         batch.draw(anim.getKeyFrame(stateTime), 0, 0);
  51.         batch.end();
  52.     }
  53.  
  54.     @Override
  55.     public void resize(int width, int height) {
  56.         Gdx.app.log(PixelFormer.LOG, "MainMenu. Awesome!!!!!");
  57.     }
  58.  
  59.     @Override
  60.     public void show() {
  61.         Scroll1 = new ScrollingBackground(0, 0, 854, 480, 0, -5, "Down");
  62.         Scroll2 = new ScrollingBackground(0, 480, 854, 480, 0, -5, "Down");
  63.         TitleFallbg = new FallingBackground(0, 480, 0, 6, 0, 0);
  64.         ScrollTexture = new TextureRegion(GUI.findRegion("TitleScroll"));
  65.         TitleTexture = new TextureRegion(GUI.findRegion("TitleText"));
  66.         PressStart0 = new TextureRegion(GUI.findRegion("PressStart0"));
  67.         PressStart1 = new TextureRegion(GUI.findRegion("PressStart1"));
  68.         TitleSprite = new Sprite(TitleTexture);
  69.         ScrollSprite1 = new Sprite(ScrollTexture);
  70.         ScrollSprite2 = new Sprite(ScrollTexture);
  71.         batch = new SpriteBatch();
  72.         anim = new Animation(0.5f, PressStart0, PressStart1);
  73.     }
  74.  
  75.     @Override
  76.     public void hide() {
  77.        
  78.     }
  79.  
  80.     @Override
  81.     public void pause() {
  82.        
  83.     }
  84.  
  85.     @Override
  86.     public void resume() {
  87.        
  88.     }
  89.  
  90.     @Override
  91.     public void dispose() {
  92.        
  93.     }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment