Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.iMackshun.Games.Pixelformer.Screens;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Screen;
- import com.badlogic.gdx.graphics.GL10;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.Animation;
- import com.badlogic.gdx.graphics.g2d.Sprite;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.graphics.g2d.TextureAtlas;
- import com.badlogic.gdx.graphics.g2d.TextureRegion;
- import com.iMackshun.Games.Pixelformer.PixelFormer;
- import com.iMackshun.Games.Pixelformer.Objects.FallingBackground;
- import com.iMackshun.Games.Pixelformer.Objects.ScrollingBackground;
- public class MainMenu implements Screen{
- //Declarations
- PixelFormer game;
- int stateTime;
- TextureRegion ScrollTexture, TitleTexture, PressStart0, PressStart1;
- TextureAtlas GUI = new TextureAtlas("packs/PixelformerGUI.pack");
- Sprite ScrollSprite1,ScrollSprite2, TitleSprite;
- ScrollingBackground Scroll1,Scroll2;
- FallingBackground TitleFallbg;
- SpriteBatch batch;
- Animation anim;
- //Constructor
- public MainMenu(PixelFormer game){
- this.game = game;
- }
- @Override
- public void render(float delta) {
- Gdx.app.log(PixelFormer.LOG, "BGY is" + Scroll1.getYToLoop());
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
- stateTime += Gdx.graphics.getDeltaTime();
- Scroll1.update();
- Scroll2.update();
- TitleFallbg.update();
- TitleSprite.setPosition(TitleFallbg.getBgX(), TitleFallbg.getBgY());
- ScrollSprite1.setPosition(Scroll1.getBgX(), Scroll1.getBgY());
- ScrollSprite2.setPosition(Scroll2.getBgX(), Scroll2.getBgY());
- batch.begin();
- ScrollSprite1.draw(batch);
- ScrollSprite2.draw(batch);
- TitleSprite.draw(batch);
- batch.draw(anim.getKeyFrame(stateTime), 0, 0);
- batch.end();
- }
- @Override
- public void resize(int width, int height) {
- Gdx.app.log(PixelFormer.LOG, "MainMenu. Awesome!!!!!");
- }
- @Override
- public void show() {
- Scroll1 = new ScrollingBackground(0, 0, 854, 480, 0, -5, "Down");
- Scroll2 = new ScrollingBackground(0, 480, 854, 480, 0, -5, "Down");
- TitleFallbg = new FallingBackground(0, 480, 0, 6, 0, 0);
- ScrollTexture = new TextureRegion(GUI.findRegion("TitleScroll"));
- TitleTexture = new TextureRegion(GUI.findRegion("TitleText"));
- PressStart0 = new TextureRegion(GUI.findRegion("PressStart0"));
- PressStart1 = new TextureRegion(GUI.findRegion("PressStart1"));
- TitleSprite = new Sprite(TitleTexture);
- ScrollSprite1 = new Sprite(ScrollTexture);
- ScrollSprite2 = new Sprite(ScrollTexture);
- batch = new SpriteBatch();
- anim = new Animation(0.5f, PressStart0, PressStart1);
- }
- @Override
- public void hide() {
- }
- @Override
- public void pause() {
- }
- @Override
- public void resume() {
- }
- @Override
- public void dispose() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment