示例#1
0
  public static CustomLevel.LevelDef getGridDef() {
    TextureAtlas atlas = MainGame.assets.get("game.atlas", TextureAtlas.class);
    CustomLevel.LevelDef def = new CustomLevel.LevelDef();
    def.tX = 128;
    def.tY = 128;

    Array<TextureAtlas.AtlasRegion> regions = atlas.findRegions("map/grid");
    def.tiles = new TextureRegion[regions.size];
    for (int i = 0; i < regions.size; i++) {
      def.tiles[i] = regions.get(i);
    }

    def.width = 3072;
    def.height = 2048;
    def.seed = new Random();
    def.buildBoundraies(10);
    def.lights =
        new BaseLight[] {
          new DirectionalLight().set(0.6f, 0.6f, 0.6f, 0, 1, 0),
          new DirectionalLight().set(0.7f, 0.7f, 0.7f, 0, -1, 0),
          new DirectionalLight().set(0.1f, 0.1f, 0.1f, 0, 0, -1)
        };
    def.playerDef = MainGame.state.getPlayerDef();
    def.playerDef.position = new Vector2(def.width / 2, def.height / 2);
    return def;
  }
  public GameScreen() {
    leftWallAnimation = new Animation(1 / 15f, leftWallTextureAtlas.getRegions());
    rightWallAnimation = new Animation(1 / 15f, rightWallTextureAtlas.getRegions());
    pentagramAtlas = new TextureAtlas(Gdx.files.internal("data/pentagram.atlas"));
    stairsAtlas = new TextureAtlas(Gdx.files.internal("data/stairs.atlas"));
    stairsAnimation = new Animation(1, stairsAtlas.getRegions());

    // batch = new SpriteBatch();
    stage = new Stage();
    // TODO Auto-generated constructor stub
    stage = new Stage(new StretchViewport(WIDTH, HEIGHT));
    Gdx.input.setInputProcessor(stage);

    WIDTH = Gdx.graphics.getWidth();
    HEIGHT = Gdx.graphics.getHeight();

    batch = new SpriteBatch();

    // rightWall = new Texture(Gdx.files.internal("rightWall1.png"));
    // leftWall = new Texture(Gdx.files.internal("leftWall1.png"));
    perspectiveTexture = new Texture(Gdx.files.internal("perspective2.png"));
    rightFootprintTexture = new Texture(Gdx.files.internal("footprintWhite.png"));
    stairTexture = new Texture(Gdx.files.internal("stairs.png"));
    frontTexture = new Texture(Gdx.files.internal("whiteGradient.png"));
    smokeTexture = new Texture(Gdx.files.internal("smoke.jpg"));
  }
示例#3
0
 public void addPipe() {
   int r = config.random(0, 7);
   float dy = r * 10;
   r = config.random(0, 1);
   if (r == 0) {
     dy = -dy;
   }
   Pipe pipe1 = new Pipe(Atlas.findRegion("pipe1"), bird, true);
   pipe1.setZIndex(1);
   float x = Flappybird.VIEWPORT.x;
   float y =
       (Flappybird.VIEWPORT.y - config.KlandHeight) / 2
           + config.KlandHeight
           + config.KholeBetwenPipe / 2;
   pipe1.setPosition(x, y + dy);
   Pipe pipe2 = new Pipe(Atlas.findRegion("pipe2"), bird, false);
   pipe2.setZIndex(1);
   y =
       (Flappybird.VIEWPORT.y - config.KlandHeight) / 2
           + config.KlandHeight
           - pipe2.getHeight()
           - config.KholeBetwenPipe / 2;
   pipe2.setPosition(x, y + dy);
   stage.addActor(pipe1);
   stage.addActor(pipe2);
   labelScore.setZIndex(pipe1.getZIndex());
   land.setZIndex(pipe2.getZIndex());
   bird.setZIndex(pipe2.getZIndex());
 }
示例#4
0
  @Override
  public void onUse() {
    if (GemLord.getInstance().gameScreen.getBoard().getBoardState() != Board.BoardState.STATE_IDLE)
      return;
    if (!GemLord.getInstance().gameScreen.getBoard().isPlayerTurn()) return;

    if (currentCooldown <= 0) {
      GemLord.soundPlayer.playBow();
      int damage = random.nextInt(((35 - 20) + 1));
      damage += 20;

      Damage dmg = new Damage();
      dmg.damage = damage;
      GemLord.getInstance().gameScreen.getBoard().getEnemy().damage(dmg);
      addAction(Actions.sequence(Actions.scaleTo(2f, 2f, 0.15f), Actions.scaleTo(1f, 1f, 0.15f)));
      currentCooldown = cooldown;
      TextureAtlas atlas = GemLord.assets.get("data/textures/pack.atlas", TextureAtlas.class);
      Image projectile = new Image(atlas.findRegion("itemarrow"));
      projectile.setPosition(getX(), getY());

      float targetX = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getX();
      float targetY = GemLord.getInstance().gameScreen.getBoard().getEnemy().getImage().getY();

      projectile.addAction(
          Actions.sequence(
              Actions.moveTo(targetX, targetY, 0.25f),
              Actions.fadeOut(0.25f),
              Actions.removeActor()));

      GemLord.getInstance().gameScreen.getBoard().getEffectGroup().addActor(projectile);
    }
  }
示例#5
0
  public static void dispose() {
    texture.dispose();
    bgTexture.dispose();
    bgBackTexture.dispose();

    robotoLt.dispose();
    robotoBlk.dispose();
    panel.dispose();
    fontFilter.dispose();
    fontFilter2.dispose();
    menuBack.dispose();
    smoke.dispose();
    fbShare.dispose();

    collision.dispose();
    jump.dispose();
    jumpSound.dispose();
    dblJump.dispose();
    milestone50.dispose();
    run.dispose();
    hit.dispose();
    milestone.dispose();
    milestone50.dispose();
    select.dispose();
    highScore.dispose();

    smokeParticle.dispose();
    starParticle.dispose();
    platform.dispose();
    nanoRun.dispose();
    //		gpgsAtlas.dispose();

  }
示例#6
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();
  }
 public AssetLevelDecoration(TextureAtlas atlas) {
   cloud01 = atlas.findRegion("cloud01");
   cloud02 = atlas.findRegion("cloud02");
   cloud03 = atlas.findRegion("cloud03");
   mountainLeft = atlas.findRegion("mountain_left");
   mountainRight = atlas.findRegion("mountain_right");
   waterOverlay = atlas.findRegion("water_overlay");
 }
  @Override
  public void dispose() {
    if (cache != null) cache.dispose();

    for (TextureAtlas atlas : atlases.values()) atlas.dispose();

    watcher.removeListener(this);
  }
示例#9
0
  public Assets() {
    // Load all backgroundlayers into regionlist
    TextureAtlas assetatlas = new TextureAtlas("packedImgs/Starscroller.pack");

    regionlist = assetatlas.getRegions();

    iterator = regionlist.iterator();
  }
示例#10
0
  /**
   * Metodo que carga la animacion
   *
   * @return
   */
  private static TextureRegion[] cargarAnimacion() {
    TextureRegion[] animacion1 = new TextureRegion[4];
    animacion1[0] = animAtlas.findRegion("moneda_1_H");
    animacion1[1] = animAtlas.findRegion("moneda_2_H");
    animacion1[2] = animAtlas.findRegion("moneda_3_H");
    animacion1[3] = animAtlas.findRegion("moneda_4_H");

    return animacion1;
  }
示例#11
0
 public void addBird() {
   TextureRegion[] birdRegions =
       new TextureRegion[] {
         Atlas.findRegion("bird1"), Atlas.findRegion("bird2"), Atlas.findRegion("bird3")
       };
   bird = new Chim(birdRegions);
   bird.setPosition(Flappybird.VIEWPORT.x / 2 - bird.getWidth(), Flappybird.VIEWPORT.y / 2);
   stage.addActor(bird);
 }
示例#12
0
  @Override
  public void dispose() {
    batch.dispose();
    leftWallTextureAtlas.dispose();
    rightWallTextureAtlas.dispose();

    // batch.dispose();
    // texture.dispose();

  }
示例#13
0
 public Enemy(Body body) {
   super(body);
   TextureAtlas textureAtlas = new TextureAtlas(Constants.CHARACTERS_ATLAS_PATH);
   TextureRegion[] runningFrames = new TextureRegion[getUserData().getTextureRegions().length];
   for (int i = 0; i < getUserData().getTextureRegions().length; i++) {
     String path = getUserData().getTextureRegions()[i];
     runningFrames[i] = textureAtlas.findRegion(path);
   }
   animation = new Animation(0.1f, runningFrames);
   stateTime = 0f;
 }
示例#14
0
 public Animation(Character character, String name, int repeat, int framerate) {
   TextureAtlas atlas =
       SpriteSheetService.getInstance()
           .getSpriteSheet(character.getName().toLowerCase() + "_" + name);
   for (TextureRegion texture : atlas.getRegions()) {
     this.getTextures().add(texture);
     this.width = texture.getRegionWidth();
     this.height = texture.getRegionHeight();
   }
   this.framerate = framerate;
   this.repeat = repeat;
 }
示例#15
0
  private void init(TextureAtlas atlas, String caller, int framesPerSecond, GameObject parent) {
    this.atlas = atlas;
    this.caller = caller;
    this.parent = parent;

    currentTexture = 1;
    numTextures = atlas.getRegions().size;

    countDownTime = 1f / (float) framesPerSecond;
    timer = countDownTime;

    TextureRegion r = atlas.findRegion(caller + 1);
    parent.setRegion(r);
  }
  private TextureRegion getAtlasRegion(AtlasRegionAsset asset) {
    String relativePath = asset.getPath();

    TextureAtlas atlas = atlases.get(relativePath);
    if (atlas == null) return missingRegion;

    if (asset.getRegionName() == null) {
      return new TextureRegion(atlas.getTextures().first());
    } else {
      TextureRegion region = atlas.findRegion(asset.getRegionName());
      if (region == null) return missingRegion;
      return region;
    }
  }
  private void updateAtlas(FileHandle file) {
    String relativePath = fileAccess.relativizeToAssetsFolder(file);

    TextureAtlas atlas = atlases.get(relativePath);
    if (atlas != null) {
      atlases.remove(relativePath);
      atlas.dispose();
    }

    if (file.exists()) {
      atlases.put(relativePath, new TextureAtlas(file));
      App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURES));
      App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURE_ATLASES));
    }
  }
 @Override
 public void dispose() {
   stage.dispose();
   skin.dispose();
   atlas.dispose();
   font.dispose();
 }
示例#19
0
文件: Art.java 项目: wxxzy/rain
  /** 这部分资源需要立即载入,其他资源可以异步载入 */
  public static void init() {
    isLoaded = false;
    assetManager = new AssetManager();

    // 读取游戏绘图素材
    textureAtlas_background = new TextureAtlas(Gdx.files.internal("data/shoot_background.pack"));

    // Loading动画
    gameLoading = new TextureRegion[4];
    gameLoading[0] = new TextureRegion(textureAtlas_background.createSprite("game_loading1"));
    gameLoading[1] = new TextureRegion(textureAtlas_background.createSprite("game_loading2"));
    gameLoading[2] = new TextureRegion(textureAtlas_background.createSprite("game_loading3"));
    gameLoading[3] = new TextureRegion(textureAtlas_background.createSprite("game_loading4"));

    animation_gameLoading = new Animation(0.5f, gameLoading);
  }
示例#20
0
  public void show() {
    game.showAds(true);

    batch = new SpriteBatch();
    bitmap = game.getText();
    title = game.getTitle();
    layout = new GlyphLayout();

    backgroundTexture = new Texture(Gdx.files.internal("images/background.png"));
    backgroundSprite = new Sprite(backgroundTexture);
    backgroundSprite.setSize(game.WIDTH, game.HEIGHT * 2);

    textureAtlas = new TextureAtlas(Gdx.files.internal("images/m.txt"));
    meteorAnimation = new Animation(1 / 12f, textureAtlas.getRegions());

    width = (float) meteorAnimation.getKeyFrame(0f, true).getRegionWidth() * game.scaleWidth;
    height = (float) meteorAnimation.getKeyFrame(0f, true).getRegionHeight() * game.scaleWidth;

    secondsElapsed = 0f;

    if (game.MAXSCORE <= 60) {
      maxLevel = game.getBundle().get("beginner");
    } else if (game.MAXSCORE <= 120) {
      maxLevel = game.getBundle().get("advanced");
    } else if (game.MAXSCORE <= 240) {
      maxLevel = game.getBundle().get("expert");
    } else {
      maxLevel = game.getBundle().get("master");
    }
    Gdx.input.setInputProcessor(this);
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  }
示例#21
0
 public void init() {
   atlas = new TextureAtlas(Constants.TEXTURE_ATLAS_OBJECTS);
   for (Texture t : atlas.getTextures()) t.setFilter(TextureFilter.Linear, TextureFilter.Linear);
   // create game resource objects
   assetatlas = new AssetAtlats(atlas);
   fonts = new AssetFonts();
 }
示例#22
0
  @Override
  public void dispose() {
    super.dispose();

    res.dispose();
    textureAtlas.dispose();
    batch.dispose();
  }
示例#23
0
  public static void load() {
    cheifRunningAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-running-packed/cheif-running.atlas"));
    cheifRunning = new Animation(1 / 10f, cheifRunningAtlas.getRegions());

    cheifNeutralAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-neutral-packed/cheif-neutral.atlas"));
    cheifNeutral = new Animation(1 / 10f, cheifNeutralAtlas.getRegions());

    cheifAirborneAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-airborne-packed/cheif-airborne.atlas"));
    cheifAirborne = new Animation(1 / 10f, cheifAirborneAtlas.getRegions());

    cheifSlidingAtlas =
        new TextureAtlas(Gdx.files.internal("data/cheif-sliding-packed/cheif-sliding.atlas"));
    cheifSliding = new Animation(1 / 10f, cheifSlidingAtlas.getRegions());
  }
示例#24
0
 @Override
 public void dispose() {
   texture.dispose();
   batch.dispose();
   hero1Atlas.dispose();
   HUDBatch.dispose();
   font1.dispose();
 }
示例#25
0
  @Override
  public void create() {
    FileHandle fh = Gdx.files.internal("freud.txt");
    TextureAtlas atlas = new TextureAtlas(fh);
    stage = new Stage();

    // ======= フロイト ==========
    TextureAtlas.AtlasRegion fruedRegion = atlas.findRegion("nigaoe_freud");
    // Imageクラスにregionを食わせるらしい
    Image fruedImage = new Image(fruedRegion);
    fruedImage.setPosition(0, 0);

    // ステージにActorを突っ込む
    // Imageはextends Widget。
    // Widgetはextends Actor implementes Layout
    stage.addActor(fruedImage); // stageの直下に追加

    // ======= 始皇帝 ==========
    TextureAtlas.AtlasRegion shikouteiRegion = atlas.findRegion("nigaoe_shikoutei");
    Image shikouteiImage = new Image(shikouteiRegion);
    shikouteiImage.setPosition(200, 0);
    stage.addActor(shikouteiImage); // stageの直下に追加

    // グループを生成する
    // Groupもextends Actor implemnts Cullable
    // Cullableはよく分からん
    // 多分Groupのabilityなんだと思うんだが
    // 親子関係の描画操作かな
    Group group = new Group();
    group.setPosition(150, 200);
    group.setScale(0.5f);
    stage.addActor(group);

    // ======= 正岡子規 ==========
    TextureAtlas.AtlasRegion masaokaRegion = atlas.findRegion("nigaoe_masaoka_shiki");
    Image masaokaImage = new Image(masaokaRegion);
    masaokaImage.setPosition(0, 0);
    group.addActor(masaokaImage); // groupの下に追加

    // ======= 石川ゴエモン ==========
    TextureAtlas.AtlasRegion goemonRegion = atlas.findRegion("nigaoe_ishikawa_goemon");
    Image goemonImage = new Image(goemonRegion);
    goemonImage.setPosition(200, 0);
    group.addActor(goemonImage); // groupの下に追加
  }
示例#26
0
  public static void load() {
    textures = new TextureAtlas(Gdx.files.internal("gfx/textures.pack"));
    timerFont = new BitmapFont(Gdx.files.internal("timer.fnt"), textures.findRegion("timer"));
    fight = Gdx.audio.newSound(Gdx.files.internal("sounds/fight.mp3"));

    for (int i = 0; i < 7; i++) {
      hitSounds.add(Gdx.audio.newSound(Gdx.files.internal("sounds/hit" + i + ".mp3")));
    }
  }
示例#27
0
  public static void dispose() {
    textures.dispose();
    timerFont.dispose();
    fight.dispose();

    for (int i = 0; i < 7; i++) {
      hitSounds.get(i).dispose();
    }
  }
示例#28
0
  public void init() {
    //        camera = new OrthographicCamera();
    //        viewport = new FitViewport(SCENE_WIDTH, SCENE_HEIGHT, camera);

    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera();
    viewport = new FitViewport(SCENE_WIDTH, SCENE_HEIGHT, camera); // 設置鏡頭大小
    camera.setToOrtho(false, w, h); // y軸向上
    camera.update();

    batch = new SpriteBatch();
    deltaTime = 0.0f;
    xPosition = 0;

    // Load atlases and textures
    //        hero1Atlas = new TextureAtlas(Gdx.files.internal("hero/shana/RunningRight.pack"));
    hero1Atlas = new TextureAtlas(Gdx.files.internal("hero/shana/heroShana.pack"));

    TextureRegion[] frameWalkingRight = new TextureRegion[8];
    frameWalkingRight[0] = hero1Atlas.findRegion("RunningRight1");
    frameWalkingRight[1] = hero1Atlas.findRegion("RunningRight2");
    frameWalkingRight[2] = hero1Atlas.findRegion("RunningRight3");
    frameWalkingRight[3] = hero1Atlas.findRegion("RunningRight4");
    frameWalkingRight[4] = hero1Atlas.findRegion("RunningRight5");
    frameWalkingRight[5] = hero1Atlas.findRegion("RunningRight6");
    frameWalkingRight[6] = hero1Atlas.findRegion("RunningRight7");
    frameWalkingRight[7] = hero1Atlas.findRegion("RunningRight8");

    // Load animations
    //        animation = new Animation(FRAME_DURATION, hero1Atlas.getRegions(),
    // Animation.PlayMode.LOOP);
    animation = new Animation(FRAME_DURATION, frameWalkingRight);

    HUDBatch = new SpriteBatch();
    font1 = new BitmapFont();
    font1.setColor(Color.YELLOW);

    tiledMap = new TmxMapLoader().load("map/newmap2.tmx");

    tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
    foregroundLayer = (TiledMapTileLayer) tiledMap.getLayers().get("foreground");
  }
  private TextureRegion createBgIcon(String atlas, String region) {
    TextureAtlas a =
        new TextureAtlas(
            Gdx.files.absolute(
                Ctx.project.getProjectPath()
                    + "/"
                    + Project.ATLASES_PATH
                    + "/1/"
                    + atlas
                    + ".atlas"));
    AtlasRegion r = a.findRegion(region);
    FrameBuffer fbo =
        new FrameBuffer(
            Format.RGBA8888, 200, (int) (r.getRegionHeight() * 200f / r.getRegionWidth()), false);

    SpriteBatch fboBatch = new SpriteBatch();
    fboBatch.setColor(Color.WHITE);
    OrthographicCamera camera = new OrthographicCamera();
    camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight());
    fboBatch.setProjectionMatrix(camera.combined);

    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    fbo.begin();
    fboBatch.begin();
    fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight());
    fboBatch.end();

    TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight());
    //		tex.flip(false, true);

    fbo.end();
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

    fbo.dispose();
    a.dispose();
    fboBatch.dispose();

    return tex;
  }
示例#30
0
  public void update(float delta) {
    timer -= delta;
    if (timer <= 0) {
      currentTexture++;
      if (kill) if (currentTexture > numTextures) parent.setRemovable();
      currentTexture = currentTexture > numTextures ? 1 : currentTexture;

      TextureRegion r = atlas.findRegion(caller + (currentTexture));
      parent.setRegion(r);

      timer = countDownTime;
    }
  }