示例#1
0
  public GameScreen(int level) {
    instance = this;

    levelNum = level;

    atlas = new TextureAtlas(Gdx.files.internal("textures/nerdshooter.pack"));

    font = new BitmapFont();

    if (level == -1) {
      GameScreen.useGameDebugRenderer = true;
    } else {
      GameScreen.useGameDebugRenderer = false;
    }

    controlLeft = atlas.findRegion("HUDLeft");
    controlRight = atlas.findRegion("HUDRight");
    controlUp = atlas.findRegion("HUDJump");

    world = new World(level);
    blocks = world.getBlocks(world.getLevel().getWidth(), world.getLevel().getHeight());

    button = new ShapeRenderer();
    batch = new SpriteBatch();

    left = new Rectangle();
    right = new Rectangle();

    jump = new Rectangle();
  }
示例#2
0
 public static void load() {
   if (MainActivity.mAct.isFinishing()) return;
   atlas = new TextureAtlas(5, 1024, 256);
   atlas.insert(link = new Texture("link.png", 9, 1));
   atlas.insert(dpad = new Texture("dpad.png"));
   atlas.insert(topTransUI = new Texture("topTransUI.png"));
   atlas.insert(map01 = new Texture("map01_tiles.png", 4, 1));
   atlas.complete();
 }
  public void clear() {
    TextureItem.releaseAll(mTexture);
    mAtlas.clear();
    items = null;

    // mTexture.bitmap.eraseColor(Color.TRANSPARENT);
    mTexture = TextureItem.get(true);
    mCanvas.setBitmap(mTexture.bitmap);
  }
示例#4
0
 public void loadEmitterImages(TextureAtlas atlas) {
   for (int i = 0, n = emitters.size; i < n; i++) {
     ParticleEmitter emitter = emitters.get(i);
     String imagePath = emitter.getImagePath();
     if (imagePath == null) continue;
     String imageName = new File(imagePath.replace('\\', '/')).getName();
     int lastDotIndex = imageName.lastIndexOf('.');
     if (lastDotIndex != -1) imageName = imageName.substring(0, lastDotIndex);
     Sprite sprite = atlas.createSprite(imageName);
     if (sprite == null)
       throw new IllegalArgumentException("SpriteSheet missing image: " + imageName);
     emitter.setSprite(sprite);
   }
 }
  public Sprite addItem(T item, int width, int height) {
    Rect r = mAtlas.getRegion(width, height);
    if (r == null) {
      // create new atlas
      return null;
    }
    Sprite sprite = new Sprite(item, mAtlas, r);

    items = Inlist.append(items, sprite);

    draw(item, r);

    return sprite;
  }
示例#6
0
  public BuggySprite(
      TextureAtlas myTextures,
      TiledMapTileLayer pTiles,
      TiledMapTileLayer lTiles,
      ArrayList<PlatformSprite> platforms,
      GameInputManager inputManager,
      int lives,
      World world,
      MainGameLayer gameLayer) {

    super(myTextures.findRegion("buggy_F1"), pTiles, lTiles);
    standRegion = myTextures.findRegion("buggy_F1");
    m_walkAnimation =
        new AnimateSpriteFrame(myTextures, new String[] {"buggy_F1", "buggy_F2"}, 0.3f, -1);
    m_standAnimation = new AnimateSpriteFrame(myTextures, new String[] {"buggy_F1"}, 1.0f, -1);

    m_attackAnimation = new AnimateSpriteFrame(myTextures, new String[] {"man_stand_F1"}, 0.3f, 1);

    m_hitAnimation = null;
    m_tutorialAnimation = new AnimateSpriteFrame(myTextures, new String[] {"buggy_F1"}, 0.5f, -1);
    m_idleAnimation = new AnimateSpriteFrame(myTextures, new String[] {"buggy_F1"}, 0.5f, -1);

    m_throughDoorAnimation = new AnimateFadeOut(0.5f);
    m_floatAnimation =
        new AnimateSpriteFrame(myTextures, new String[] {"man_jump_F3", "man_jump_F3"}, 0.65f, -1);

    m_teleportIn = new AnimateFadeIn(0.35f);
    m_teleportOut = new AnimateFadeOut(0.35f);

    AnimateTranslateVertical f1 = new AnimateTranslateVertical(1.0f, 0f, -3f, 1);
    AnimateTranslateVertical f2 = new AnimateTranslateVertical(3.0f, 1.0f, -1f, 1);
    GameAnimateable[] af = {f1, f2};

    m_floatAnimation2 = new GameAnimationSequence(af, -1);

    AnimateFade fo = new AnimateFade(0.2f, 0.9f, 0.2f);
    AnimateDelay delay = new AnimateDelay(0.25f);
    AnimateFade fi = new AnimateFade(0.2f, 0.2f, 0.9f);
    AnimateFade ff = new AnimateFade(0.25f, 0.2f, 1.0f);
    GameAnimateable[] a = {fo, fi, delay, fo, fi, delay, fo, ff};

    m_invincibleAnimation = new GameAnimationSequence(a, 1);
    m_invincibleAnimation.setIgnoreStop(true);

    m_inputManager = inputManager;
    m_platforms = platforms;

    m_activeWeapon = null;

    maxSpeedX = 6.0f;
    defaultMaxSpeedX = 6.0f;
    maxSpeedY = 4.0f;
    maxFallVelocity = 20.0f;
    m_horizontalDragFactor = 1.0f;
    m_climbingDragFactor = 0.25f;
    m_gravity = 0.8f;

    m_jumping = false;
    m_climbing = false;
    m_currDir = 1;

    m_lives = lives;
    m_boundingBox.width = this.getBoundingRectangle().width / 4;
    m_boundOffX = this.getBoundingRectangle().width / 2;
    m_boundingBox.height = this.getBoundingRectangle().height / 5;

    m_gameLayer = gameLayer;

    this.runAnimation(m_standAnimation);

    if (gameLayer.m_stage > 1)
      pLight = gameLayer.createConeLight(new Color(0.8f, 0.8f, 0.5f, 0.75f), 1100, 0, 0, 0, 25);
    else pLight = gameLayer.createConeLight(new Color(0.8f, 0.8f, 0.5f, 0.35f), 700, 0, 0, 0, 25);

    pLight.setXray(true);
    pLight.setActive(false);
    m_lightX = this.getWidth() - 20;
  }
示例#7
0
 @Override
 public void dispose() {
   atlas.dispose();
 }