iMackshun

MainMenu.java

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