iMackshun

World1Story.java

Mar 17th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.46 KB | None | 0 0
  1. package com.iMackshun.Games.Pixelformer.Screens;
  2.  
  3. import com.badlogic.gdx.Gdx;
  4. import com.badlogic.gdx.InputProcessor;
  5. import com.badlogic.gdx.Screen;
  6. import com.badlogic.gdx.Input.Keys;
  7. import com.badlogic.gdx.graphics.GL10;
  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.Worlds.World1_1;
  14.  
  15. public class World1Story implements Screen, InputProcessor{
  16.     //Declarations
  17.     PixelFormer game;
  18.     TextureAtlas GUI = new TextureAtlas("packs/PixelFormerGUI.pack");
  19.     TextureRegion Story1, Story2, Story3, Story4, Story5;
  20.     Sprite Story;
  21.     int WhichStory = 1;
  22.     SpriteBatch batch;
  23.    
  24.     //Constructor
  25.     public World1Story(PixelFormer game){
  26.         this.game = game;
  27.     }
  28.  
  29.     @Override
  30.     public void render(float delta) {
  31.         checkStory();
  32.         Gdx.gl.glClearColor(0, 0, 0, 1);
  33.         Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
  34.         batch.begin();
  35.         Story.draw(batch);
  36.         batch.end();
  37.        
  38.     }
  39.  
  40.     private void checkStory() {
  41.         if (WhichStory == 1){
  42.             Story.setRegion(Story1);
  43.         }
  44.         if (WhichStory == 2){
  45.             Story.setRegion(Story2);
  46.         }
  47.         if (WhichStory == 3){
  48.             Story.setRegion(Story3);
  49.         }
  50.         if (WhichStory == 4){
  51.             Story.setRegion(Story4);
  52.         }
  53.         if (WhichStory == 5){
  54.             Story.setRegion(Story5);
  55.         }
  56.         if (WhichStory == 6){
  57.             game.setScreen(new World1_1(game));
  58.         }
  59.        
  60.     }
  61.  
  62.     @Override
  63.     public void resize(int width, int height) {
  64.         Gdx.app.log(PixelFormer.LOG, "Menu. Awesome!!!!!");
  65.         Gdx.input.setInputProcessor(this);
  66.     }
  67.  
  68.     @Override
  69.     public void show() {
  70.         //Resources
  71.         batch = new SpriteBatch();
  72.         Story1 = new TextureRegion(GUI.findRegion("Story1to1"));
  73.         Story2 = new TextureRegion(GUI.findRegion("Story1to2"));
  74.         Story3 = new TextureRegion(GUI.findRegion("Story1to3"));
  75.         Story4 = new TextureRegion(GUI.findRegion("Story1to4"));
  76.         Story5 = new TextureRegion(GUI.findRegion("Story1to5"));
  77.         Story = new Sprite(Story2);
  78.     }
  79.  
  80.     @Override
  81.     public void hide() {
  82.         // TODO Auto-generated method stub
  83.        
  84.     }
  85.  
  86.     @Override
  87.     public void pause() {
  88.         // TODO Auto-generated method stub
  89.        
  90.     }
  91.  
  92.     @Override
  93.     public void resume() {
  94.         // TODO Auto-generated method stub
  95.        
  96.     }
  97.  
  98.     @Override
  99.     public void dispose() {
  100.         // TODO Auto-generated method stub
  101.        
  102.     }
  103.  
  104.     @Override
  105.     public boolean keyDown(int keycode) {
  106.         // TODO Auto-generated method stub
  107.         return false;
  108.     }
  109.  
  110.     @Override
  111.     public boolean keyUp(int keycode) {
  112.          if(keycode == Keys.DPAD_CENTER){
  113.             WhichStory += 1;
  114.          }
  115.          if(keycode == Keys.ENTER){
  116.                 WhichStory += 1;
  117.              }
  118.          return false;
  119.     }
  120.  
  121.     @Override
  122.     public boolean keyTyped(char character) {
  123.         // TODO Auto-generated method stub
  124.         return false;
  125.     }
  126.  
  127.     @Override
  128.     public boolean touchDown(int screenX, int screenY, int pointer, int button) {
  129.         WhichStory += 1;
  130.         return false;
  131.     }
  132.  
  133.     @Override
  134.     public boolean touchUp(int screenX, int screenY, int pointer, int button) {
  135.         // TODO Auto-generated method stub
  136.         return false;
  137.     }
  138.  
  139.     @Override
  140.     public boolean touchDragged(int screenX, int screenY, int pointer) {
  141.         // TODO Auto-generated method stub
  142.         return false;
  143.     }
  144.  
  145.     @Override
  146.     public boolean mouseMoved(int screenX, int screenY) {
  147.         // TODO Auto-generated method stub
  148.         return false;
  149.     }
  150.  
  151.     @Override
  152.     public boolean scrolled(int amount) {
  153.         // TODO Auto-generated method stub
  154.         return false;
  155.     }
  156.  
  157. }
Advertisement
Add Comment
Please, Sign In to add comment