public void createPlayer() { // Get our character images to create animations. TextureRegion[][] tmp = getAtlas().findRegion("char-sprites/shura_spritesheet").split(64, 64); setWidth(64); setHeight(64); // Create our animations Animation standUp = new Animation(1f, new TextureRegion[] {tmp[0][0]}); Animation standLeft = new Animation(1f, new TextureRegion[] {tmp[1][0]}); Animation standDown = new Animation(1f, new TextureRegion[] {tmp[2][0]}); Animation standRight = new Animation(1f, new TextureRegion[] {tmp[3][0]}); Animation walkUp = new Animation( 0.1f, new TextureRegion[] { tmp[0][1], tmp[0][2], tmp[0][3], tmp[0][4], tmp[0][5], tmp[0][6], tmp[0][7], tmp[0][8] }); Animation walkLeft = new Animation( 0.1f, new TextureRegion[] { tmp[1][8], tmp[1][7], tmp[1][6], tmp[1][5], tmp[1][4], tmp[1][3], tmp[1][2], tmp[1][1] }); Animation walkDown = new Animation( 0.1f, new TextureRegion[] { tmp[2][1], tmp[2][2], tmp[2][3], tmp[2][4], tmp[2][5], tmp[2][6], tmp[2][7], tmp[2][8] }); Animation walkRight = new Animation( 0.1f, new TextureRegion[] { tmp[3][1], tmp[3][2], tmp[3][3], tmp[3][4], tmp[3][5], tmp[3][6], tmp[3][7], tmp[3][8] }); // Set the playmode standUp.setPlayMode(Animation.LOOP); standLeft.setPlayMode(Animation.LOOP); standDown.setPlayMode(Animation.LOOP); standRight.setPlayMode(Animation.LOOP); walkUp.setPlayMode(Animation.LOOP); walkLeft.setPlayMode(Animation.LOOP); walkDown.setPlayMode(Animation.LOOP); walkRight.setPlayMode(Animation.LOOP); // Fill our map containing all animations with the animations. animations.put("stand_up", standUp); animations.put("stand_left", standLeft); animations.put("stand_down", standDown); animations.put("stand_right", standRight); animations.put("walk_up", walkUp); animations.put("walk_left", walkLeft); animations.put("walk_down", walkDown); animations.put("walk_right", walkRight); }
public Player(float x, float y) { hp = 500; tex = new Texture(Gdx.files.internal("textures/player.png")); position = new Vector2(x, y); size = new Vector2(64, 64); deltaPos = new Vector2(0, 0); AABB = new Rectangle( x + (7 * (size.x / 32)), y + (7 * (size.y / 32)), 18 * (size.x / 32), 18 * (size.y / 32)); angle = 0; animTime = 0; TextureRegion[] idleFrame = new TextureRegion[1]; idleFrame[0] = new TextureRegion(tex, 0, 0, 32, 32); idle = new Animation(0.7f, idleFrame); TextureRegion[] walkingFrames = new TextureRegion[6]; for (int i = 0; i < walkingFrames.length; i++) { walkingFrames[i] = new TextureRegion(tex, 32 + (i * 32), 0, 32, 32); } walking = new Animation(0.1f, walkingFrames); walking.setPlayMode(PlayMode.LOOP); TextureRegion[] shootingFrames = new TextureRegion[2]; for (int i = 0; i < shootingFrames.length; i++) { shootingFrames[i] = new TextureRegion(tex, 224 + (i * 32), 0, 32, 32); } shooting = new Animation(0.09f, shootingFrames); shooting.setPlayMode(PlayMode.LOOP); bulletTex = new TextureRegion(tex, 288, 0, 32, 32); currentAnimation = idle; shootInterval = 150; attack = 25; shootDeviation = 25; }
public Pete(Texture texture) { TextureRegion[] regions = TextureRegion.split(texture, WIDTH, HEIGHT)[0]; walking = new Animation(0.25F, regions[0], regions[1]); walking.setPlayMode(Animation.PlayMode.LOOP); standing = regions[0]; jumpUp = regions[2]; jumpDown = regions[3]; }
public ClientFly(short id, float x, float y, WorldRenderer renderer) { super(id, x, y, renderer); markForDispose = false; Texture texture = AssetLoader.instance.getTexture("sprites/fly.png"); sprite = new Sprite(texture); walk = new Animation( 0.25f, TextureRegion.split(texture, texture.getWidth() / 2, texture.getHeight())[0]); walk.setPlayMode(Animation.PlayMode.LOOP); sprite.setSize(ServerBlob.WIDTH + 5f, ServerFly.HEIGHT); }
/** * Constructeur * * @param res Resource qui correspond au personnage * @param textures TextureRegions qui ont ete decoupees */ public AnimationProvider(ResourceAnimated res, TextureRegion[][] textures) { mResource = res; mAnimationMatrix = textures; mCurrentAnimation = "idle"; mAnimationMap = new HashMap<String, Animation>(); // On lit les animations depuis le fichier resource et on cree toutes les // classes Animation necessaires. Iterator<AnimationDef> iter = mResource.anims.iterator(); while (iter.hasNext()) { // Pour chaque animation... AnimationDef anim = iter.next(); // On calcule le nombre d'images dans l'animation int frameCount = (anim.end_col - anim.start_col + 1) + (anim.end_line - anim.start_line) * res.columns; // On cree un tableau avec chaque image de l'animation, dans l'ordre TextureRegion[] frames = new TextureRegion[frameCount]; int frameIndex = 0; for (int line = anim.start_line; line <= anim.end_line; line++) { for (int col = anim.start_col; col <= anim.end_col; col++) { frames[frameIndex] = mAnimationMatrix[line][col]; frameIndex++; } } Animation gdxAnim = new Animation(0.05f, frames); if (anim.loop) { gdxAnim.setPlayMode(Animation.LOOP_PINGPONG); } else { gdxAnim.setPlayMode(Animation.NORMAL); } mAnimationMap.put(anim.name, gdxAnim); } }
@Override public void create() { shapeRenderer = new ShapeRenderer(); batch = new SpriteBatch(); camera = new OrthographicCamera(); camera.setToOrtho(false, 800, 480); uiCamera = new OrthographicCamera(); uiCamera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); uiCamera.update(); font = new BitmapFont(Gdx.files.internal("arial.fnt")); background = new Texture("background.png"); ground = new TextureRegion(new Texture("ground.png")); ceiling = new TextureRegion(ground); ceiling.flip(true, true); rock = new TextureRegion(new Texture("rock.png")); rockDown = new TextureRegion(rock); rockDown.flip(false, true); Texture frame1 = new Texture("plane1.png"); frame1.setFilter(TextureFilter.Linear, TextureFilter.Linear); Texture frame2 = new Texture("plane2.png"); Texture frame3 = new Texture("plane3.png"); ready = new TextureRegion(new Texture("ready.png")); gameOver = new TextureRegion(new Texture("gameover.png")); plane = new Animation( 0.05f, new TextureRegion(frame1), new TextureRegion(frame2), new TextureRegion(frame3), new TextureRegion(frame2)); plane.setPlayMode(PlayMode.LOOP); music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3")); music.setLooping(true); music.play(); explode = Gdx.audio.newSound(Gdx.files.internal("explode.wav")); resetWorld(); }
public Health(ShooterGame g) { lifeManager = new LifeManager(3); game = g; lifeManager.setGame(game); backBarTexture = new Texture(Gdx.files.internal("hud/health/backbar2.png")); backBarDangerTexture = new Texture(Gdx.files.internal("hud/health/backbar-danger.png")); backBarSprite = new Sprite(backBarTexture); backBarWarningSprite = new Sprite(backBarTexture); healthBarTexture = new Texture(Gdx.files.internal("hud/health/healthbar.png")); healthBarSprite = new Sprite(healthBarTexture); setHealthBarSprite(healthBarSprite); topLeftWingTexture = new Texture(Gdx.files.internal("hud/health/topleftwing.png")); topLeftWingSprite = new Sprite(topLeftWingTexture); bottomLeftWingTexture = new Texture(Gdx.files.internal("hud/life/bottomleftwing.png")); bottomLeftWingSprite = new Sprite(bottomLeftWingTexture); // Initial Positions backBarSprite.setPosition(50, 688); healthBarSprite.setPosition(50, 688); topLeftWingSprite.setPosition(10, 670); bottomLeftWingSprite.setPosition(64, 640); // Set up animated health bar when health goes below 20 animationFrames = new TextureRegion[DANGER_HEALTH_FRAMES]; TextureRegion[][] tmpFrames = TextureRegion.split(backBarDangerTexture, 454, 15); int index = 0; for (int i = 0; i < 2; i++) { for (int j = 0; j < 11; j++) { animationFrames[index++] = tmpFrames[i][j]; } } backbarAnimation = new Animation(1f / 22f, animationFrames); backbarAnimation.setPlayMode(Animation.PlayMode.LOOP); }
public Nemici() { batch = new SpriteBatch(); // nemiciText = new Texture (); rectNemici = new Rectangle(); shapeRenderer = new ShapeRenderer(); nemiciAnimation = new Animation( 1 / 10f, new TextureRegion(new Texture("nemici/e_f1.png")), new TextureRegion(new Texture("nemici/e_f2.png")), new TextureRegion(new Texture("nemici/e_f3.png")), new TextureRegion(new Texture("nemici/e_f4.png")), new TextureRegion(new Texture("nemici/e_f5.png")), new TextureRegion(new Texture("nemici/e_f6.png"))); nemiciAnimation.setPlayMode(Animation.PlayMode.LOOP); }
public static void load() { texture = new Texture(Gdx.files.internal("data/texture.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); bg = new TextureRegion(texture, 0, 0, 136, 43); bg.flip(false, true); grass = new TextureRegion(texture, 0, 43, 143, 11); grass.flip(false, true); birdDown = new TextureRegion(texture, 136, 0, 17, 12); birdDown.flip(false, true); bird = new TextureRegion(texture, 153, 0, 17, 12); bird.flip(false, true); birdUp = new TextureRegion(texture, 170, 0, 17, 12); birdUp.flip(false, true); TextureRegion[] birds = {birdDown, bird, birdUp}; birdAnimation = new Animation(0.06f, birds); birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG); skullUp = new TextureRegion(texture, 192, 0, 24, 14); skullDown = new TextureRegion(skullUp); skullDown.flip(false, true); bar = new TextureRegion(texture, 136, 16, 22, 3); bar.flip(false, true); prefs = Gdx.app.getPreferences("ZombieBird"); if (!prefs.contains("highScore")) { prefs.putInteger("highScore", 0); } font = new BitmapFont(Gdx.files.internal("data/text.fnt")); shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt")); dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav")); flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav")); coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav")); }
/** * 0 = gray. 1 = blue. 2 = red. 3 = green. * * @param color */ public PoisonDart(TextureAtlas atlas, int color, float speed, BattleEntity entity) { super(speed, 0, entity); AtlasRegion atlasRegion = atlas.findRegion("battle/entities/fireball"); TextureRegion[][] spriteSheet = atlasRegion.split(34, 25); TextureRegion[] frames = new TextureRegion[3]; frames[0] = spriteSheet[color][0]; frames[1] = spriteSheet[color][1]; frames[2] = spriteSheet[color][2]; Animation attacking = new Animation(0.1f, frames); attacking.setPlayMode(Animation.LOOP); this.animations.put("attacking", attacking); this.setState(BattleEntity.stateAttacking); this.setHeight(30); this.setWidth(30); offsetX = (int) entity.getWidth() - 120; offsetY = 0; this.addAction(color(Color.MAGENTA)); this.setGrid(entity.getGridXInt() - 1, entity.getGridYInt()); }
public static void load() { drop_img = new Texture("droplet.png"); bucket_img = new Texture("bucket.png"); kitchen_img = new Texture("kitchen.png"); dropsAnimation = new Texture("drop_anim.png"); dropsAnimation.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); TextureRegion drop_f1 = new TextureRegion(dropsAnimation, 0, 0, 64, 64), drop_f2 = new TextureRegion(dropsAnimation, 64, 0, 64, 64), drop_f3 = new TextureRegion(dropsAnimation, 128, 0, 64, 64), drop_f4 = new TextureRegion(dropsAnimation, 0, 64, 64, 64), drop_f5 = new TextureRegion(dropsAnimation, 64, 64, 64, 64), drop_f6 = new TextureRegion(dropsAnimation, 128, 64, 64, 64); TextureRegion[] drops = {drop_f1, drop_f2, drop_f3, drop_f4, drop_f5, drop_f6}; drops_animation = new Animation(0.1f, drops); drops_animation.setPlayMode(Animation.PlayMode.LOOP); font_StartScreen = new BitmapFont(Gdx.files.internal("DropGameFont.fnt")); font_EndGameScore = new BitmapFont(Gdx.files.internal("EndGameFont.fnt")); font_InGameScore = new BitmapFont(Gdx.files.internal("InGameFont.fnt")); }
public static void load() { logoTexture = new Texture(Gdx.files.internal("data/logo.png")); logoTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); logo = new TextureRegion(logoTexture, 0, 0, 512, 114); texture = new Texture(Gdx.files.internal("data/texture.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); playButtonUp = new TextureRegion(texture, 0, 83, 29, 16); playButtonDown = new TextureRegion(texture, 29, 83, 29, 16); playButtonUp.flip(false, true); playButtonDown.flip(false, true); ready = new TextureRegion(texture, 59, 83, 34, 7); ready.flip(false, true); retry = new TextureRegion(texture, 59, 110, 33, 7); retry.flip(false, true); gameOver = new TextureRegion(texture, 59, 92, 46, 7); gameOver.flip(false, true); scoreboard = new TextureRegion(texture, 111, 83, 97, 37); scoreboard.flip(false, true); star = new TextureRegion(texture, 152, 70, 10, 10); noStar = new TextureRegion(texture, 165, 70, 10, 10); star.flip(false, true); noStar.flip(false, true); highScore = new TextureRegion(texture, 59, 101, 48, 7); highScore.flip(false, true); zbLogo = new TextureRegion(texture, 0, 55, 135, 24); zbLogo.flip(false, true); bg = new TextureRegion(texture, 0, 0, 136, 43); bg.flip(false, true); grass = new TextureRegion(texture, 0, 43, 143, 11); grass.flip(false, true); birdDown = new TextureRegion(texture, 136, 0, 17, 12); birdDown.flip(false, true); bird = new TextureRegion(texture, 153, 0, 17, 12); bird.flip(false, true); birdUp = new TextureRegion(texture, 170, 0, 17, 12); birdUp.flip(false, true); // creates an array of TextureRegions TextureRegion[] birds = {birdDown, bird, birdUp}; // Creates a new Animation in which each frame is 0.06 seconds long, using the above array. birdAnimation = new Animation(0.06f, birds); // Sets play mode to be ping pong, in which we will see a bounce. birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG); skullUp = new TextureRegion(texture, 192, 0, 24, 14); // Create by flipping existing skullUp skullDown = new TextureRegion(skullUp); skullDown.flip(false, true); bar = new TextureRegion(texture, 136, 16, 22, 3); bar.flip(false, true); dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav")); flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav")); coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav")); fall = Gdx.audio.newSound(Gdx.files.internal("data/fall.wav")); font = new BitmapFont(Gdx.files.internal("data/text.fnt")); font.getData().setScale(.25f, -.25f); whiteFont = new BitmapFont(Gdx.files.internal("data/whitetext.fnt")); whiteFont.getData().setScale(.1f, -.1f); shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt")); shadow.getData().setScale(.25f, -.25f); // Create (or retrieve existing) preferences file prefs = Gdx.app.getPreferences("Zombie Bird"); // Provide default high score of 0 if (!prefs.contains("highScore")) { prefs.putInteger("highScore", 0); } }
private boolean showerActive(Entity shower) { final Anim anim = mAnim.get(shower); final Animation animation = abstractAssetSystem.get(anim.id); animation.setPlayMode(Animation.PlayMode.LOOP); return animation.getKeyFrameIndex(anim.age) == 4; }
public Ringo(float maxHealth, float x, float y) { super(maxHealth, x, y); int chunkHeight = 160; int chunkWidth = 128; Texture sprite = Loader.texture(FOLDER.child("anm.png")); sprite.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest); Sprite fbs = new Sprite(Loader.texture(FOLDER.child("fbs.png"))); fbs.setScale(2F); TextureRegion nameTag = new TextureRegion(Loader.texture(FOLDER.child("nametag.png"))); Animation idle = ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 1, 2, 3, 4, 5); idle.setPlayMode(PlayMode.LOOP); Animation left = new MovementAnimation( ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 11, 12), ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 13, 14, 15), 8f); Animation right = new MovementAnimation( ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 6, 7), ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 8, 9, 10), 8f); Animation special = new StartupLoopAnimation( ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 16, 17), ImageSplitter.getAnimationFromSprite(sprite, chunkHeight, chunkWidth, 8F, 18, 19, 20), 8f); special.setPlayMode(PlayMode.NORMAL); Music bgm = new J2hMusic(Gdx.audio.newMusic(FOLDER.child("bgm.mp3"))); bgm.setLooping(true); setAuraColor(AllStarUtil.from255RGB(104, 19, 52).mul(6f)); setBgAuraColor(AllStarUtil.from255RGB(40, 40, 40)); set(nameTag, bgm); set(fbs, idle, left, right, special); backgroundSpawner = new Setter<BackgroundBossAura>() { @Override public void set(final BackgroundBossAura t) { final Background bg = new Background(Loader.texture(FOLDER.child("bg.png"))) { @Override public void onDraw() { setBlendFunc(GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_COLOR); super.onDraw(); }; }; bg.setFrameBuffer(t.getBackgroundBuffer()); bg.setVelV(0.05d); bg.setVelU(-0.05d); bg.getSprite().setScale(0.75f); bg.getSprite().setAlpha(1f); bg.setZIndex(bg.getZIndex() - 20); game.spawn(bg); float speed = 10; // Layer 1 final Background bge = new Background(Loader.texture(FOLDER.child("bge.png"))) { @Override public void onDraw() { setBlendFunc(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_SRC_COLOR); super.onDraw(); }; }; bge.setFrameBuffer(t.getBackgroundBuffer()); bge.getSprite().setScale(1.5f); bge.setRotationDegs(speed); bge.getSprite().setAlpha(1f); bge.setZIndex(bg.getZIndex() - 2); game.spawn(bge); // Layer 2 { Background bgeTwo = new Background(Loader.texture(FOLDER.child("bge.png"))) { @Override public void onDraw() { setBlendFunc(GL20.GL_SRC_COLOR, GL20.GL_ZERO); super.onDraw(); }; }; bgeTwo.getSprite().setScale(1.5f); bgeTwo.setFrameBuffer(t.getBackgroundBuffer()); bgeTwo.setRotationDegs(-speed); bgeTwo.getSprite().setAlpha(1f); bgeTwo.setZIndex(bg.getZIndex() - 4); game.spawn(bgeTwo); } Game.getGame() .spawn( new ClearBackground(bg.getZIndex() - 10) { { setFrameBuffer(t.getBackgroundBuffer()); } }); } }; }
public static void load(NanoCat nano) { pref = Gdx.app.getPreferences("NanoGameState"); if (!pref.getBoolean("hdState")) { if (nano.getTime() < 15 && nano.getTime() >= 5) { bgTexture = new Texture(Gdx.files.internal("data/bg_1_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() < 20 && nano.getTime() >= 15) { bgTexture = new Texture(Gdx.files.internal("data/bg_2_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() >= 20) { bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else { bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } } else if (pref.getBoolean("hdState")) { if (nano.getTime() < 15 && nano.getTime() >= 5) { bgTexture = new Texture(Gdx.files.internal("data/bg_1.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() < 20 && nano.getTime() >= 15) { bgTexture = new Texture(Gdx.files.internal("data/bg_2.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else if (nano.getTime() >= 20) { bgTexture = new Texture(Gdx.files.internal("data/bg_3.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } else { bgTexture = new Texture(Gdx.files.internal("data/bg_3.png")); bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png")); bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); } } bgBack = new TextureRegion(bgBackTexture, 0, 0, 4096, 580); // Particle Stuff smoke = new Texture(Gdx.files.internal("data/smoke_particle.png")); smokeSprite = new Sprite(smoke); smokeEmitter = new ParticleEmitter(); smokeParticle = new ParticleEffect(); smokeParticle.load(Gdx.files.internal("data/particlesmoke"), Gdx.files.internal("data")); smokeParticle.findEmitter("smoke").getScale().setHigh(50f); starEmitter = new ParticleEmitter(); starParticle = new ParticleEffect(); starParticle.load(Gdx.files.internal("data/particles"), Gdx.files.internal("data")); starParticle.findEmitter("star").getScale().setHigh(5f); starParticle.findEmitter("star2").getScale().setHigh(5f); // smokeParticle.getScale().setHigh(5f); // End Particle Stuff texture = new Texture(Gdx.files.internal("data/nano_region.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); nanoRun = new TextureAtlas(Gdx.files.internal("data/nanorun.atlas")); platform = new TextureAtlas(Gdx.files.internal("data/platform.atlas")); catRun1 = nanoRun.findRegion("nanorun0001"); catRun2 = nanoRun.findRegion("nanorun0005"); catRun3 = nanoRun.findRegion("nanorun0009"); catRun4 = nanoRun.findRegion("nanorun0013"); catRun5 = nanoRun.findRegion("nanorun0017"); catRun6 = nanoRun.findRegion("nanorun0021"); catRun7 = nanoRun.findRegion("nanorun0025"); catRun8 = nanoRun.findRegion("nanorun0029"); catRun9 = nanoRun.findRegion("nanorun0033"); catRun10 = nanoRun.findRegion("nanorun0037"); catRun11 = nanoRun.findRegion("nanorun0041"); catRun12 = nanoRun.findRegion("nanorun0045"); catRun13 = nanoRun.findRegion("nanorun0049"); catRun14 = nanoRun.findRegion("nanorun0053"); catRun15 = nanoRun.findRegion("nanorun0057"); catCollide1 = nanoRun.findRegion("nanocollide0080"); catCollide2 = nanoRun.findRegion("nanocollide0084"); catCollide3 = nanoRun.findRegion("nanocollide0088"); catCollide4 = nanoRun.findRegion("nanocollide0092"); catCollide5 = nanoRun.findRegion("nanocollide0096"); catCollide6 = nanoRun.findRegion("nanocollide0100"); catCollide7 = nanoRun.findRegion("nanocollide0104"); catCollide8 = nanoRun.findRegion("nanocollide0108"); case0 = platform.findRegion("case0"); case1 = platform.findRegion("case1"); case2 = platform.findRegion("case2"); case3 = platform.findRegion("case3"); case4 = platform.findRegion("case4"); case5 = platform.findRegion("case5"); case6 = platform.findRegion("case6"); caseDefault = platform.findRegion("default"); TextureRegion[] catRun = { catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun10, catRun11, catRun12, catRun13, catRun14, catRun15 }; catRunAnim = new Animation(.015f, catRun); catRunAnim.setPlayMode(Animation.PlayMode.LOOP); TextureRegion[] catJump = { catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun9, catRun9, catRun9, catRun9, catRun9, catRun9, catRun9 }; catJumpAnim = new Animation(.04f, catJump); catJumpAnim.setPlayMode(Animation.PlayMode.LOOP); TextureRegion[] catCollide = { catCollide1, catCollide2, catCollide3, catCollide4, catCollide5, catCollide6, catCollide7, catCollide8 }; catCollideAnim = new Animation(.02f, catCollide); catCollideAnim.setPlayMode(Animation.PlayMode.NORMAL); fontFilter = new Texture(Gdx.files.internal("data/roboto_lt.png")); fontFilter.setFilter(TextureFilter.Linear, TextureFilter.Linear); robotoLt = new BitmapFont( Gdx.files.internal("data/roboto_lt.fnt"), new TextureRegion(fontFilter), false); robotoLt.setScale(.5f, .5f); fontFilter2 = new Texture(Gdx.files.internal("data/roboto_blk.png")); fontFilter2.setFilter(TextureFilter.Linear, TextureFilter.Linear); robotoBlk = new BitmapFont( Gdx.files.internal("data/roboto_blk.fnt"), new TextureRegion(fontFilter2), false); robotoBlk.setScale(.5f, .5f); panel = new Texture(Gdx.files.internal("data/panelcolor.png")); panel.setFilter(TextureFilter.Linear, TextureFilter.Linear); panelSprite = new Sprite(panel, 500, 300); fbShare = new Texture(Gdx.files.internal("data/fbshare.png")); fbShare.setFilter(TextureFilter.Linear, TextureFilter.Linear); fbShareSprite = new Sprite(fbShare, 199, 57); menuBack = new Texture(Gdx.files.internal("data/menu_back.png")); menuBack.setFilter(TextureFilter.Linear, TextureFilter.Linear); menuBackSprite = new Sprite(menuBack, 320, 50); collision = Gdx.audio.newSound(Gdx.files.internal("data/audio/collide.wav")); milestone = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone.wav")); milestone50 = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone50.wav")); jump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump.wav")); jumpSound = Gdx.audio.newSound(Gdx.files.internal("data/audio/jump_sound.wav")); dblJump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump2.wav")); hit = Gdx.audio.newSound(Gdx.files.internal("data/audio/hit.wav")); select = Gdx.audio.newSound(Gdx.files.internal("data/audio/select.wav")); run = Gdx.audio.newSound(Gdx.files.internal("data/audio/run.wav")); highScore = Gdx.audio.newSound(Gdx.files.internal("data/audio/highscore.wav")); // Scoring score = Gdx.app.getPreferences("NanoCat"); if (!score.contains("distance")) { score.putFloat("distance", 0); } if (!score.contains("highScore")) { score.putFloat("highScore", 0); } if (!score.contains("totalFall")) { score.putInteger("totalFall", 0); } }
/** update 更新 */ public void update() { // 描画位置セット Vector2 cameraPosition = new Vector2(GameMain.camera.position.x, GameMain.camera.position.y); scroll.setPosition( cameraPosition.x - 64 - (ScrollNinja.window.x * 0.5f * ScrollNinja.scale - 6.4f), cameraPosition.y - 64 + (ScrollNinja.window.y * 0.5f * ScrollNinja.scale - 6.4f)); hp.setPosition( cameraPosition.x - 256 - (ScrollNinja.window.x * 0.5f * ScrollNinja.scale - 25.6f) - transrateX, cameraPosition.y - 64 + (ScrollNinja.window.y * 0.5f * ScrollNinja.scale - 6.4f)); scrollRight.setPosition( cameraPosition.x - 64 - (ScrollNinja.window.x * 0.5f * ScrollNinja.scale - 6.4f) + 44.5f - transrateX, cameraPosition.y - 64 + (ScrollNinja.window.y * 0.5f * ScrollNinja.scale - 6.4f)); /* hyoutan.setPosition(scroll.getX() + 51.2f, scroll.getY()); chakra.setPosition(hyoutan.getX(), hyoutan.getY()); */ // HPに変動があれば計算 if (calculateHP) calculateHP(); // チャクラに変動があれば計算 if (calculateChakra) calculateChakra(); // HP回復 1フレームで0.01ずつ増加 if (!stopHP && countHP < 0) { countHP += 0.01f; hp.scroll(0.0085f, 0); transrateX -= 0.45f; stateTime += 1; scrollAnimation.setPlayMode(Animation.LOOP_REVERSED); nowFrame = scrollAnimation.getKeyFrame(stateTime, true); scroll.setRegion(nowFrame); if (countHP > 0) stopHP = true; } // HP減る 1フレームで0.01ずつ減少 if (!stopHP && countHP > 0) { countHP -= 0.01f; hp.scroll(-0.0085f, 0); transrateX += 0.45f; stateTime += 1; scrollAnimation.setPlayMode(Animation.LOOP); nowFrame = scrollAnimation.getKeyFrame(stateTime, true); scroll.setRegion(nowFrame); if (countHP < 0) stopHP = true; } // チャクラ増える 1フレームで0.01ずつ増加 if (!stopChakra && countChakra < 0) { countChakra += 0.01f; chakra.scroll(0, -0.01f); if (countChakra > 0) stopChakra = true; } // チャクラ減る 1フレームで0.01ずつ減少 if (!stopChakra && countChakra > 0) { countChakra -= 0.01f; chakra.scroll(0, 0.01f); if (countChakra < 0) stopChakra = true; } if (stateTime > 60) stateTime = 0; }
public static void load() { // TEXTURES has to be in Formtat: 2^x * 2^y loadNumbers(); loadBlocks(); loadPlayerTextures(); logoTexture = new Texture(Gdx.files.internal("data/logo.png")); logoTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); logo = new TextureRegion(logoTexture, 0, 0, 512, 114); texture = new Texture(Gdx.files.internal("data/texture.png")); texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest); FileHandle test = Gdx.files.internal("data/touchBackground.png"); System.out.println(test.exists()); touchKnob = new Texture(test); touchKnob.setFilter(TextureFilter.Linear, TextureFilter.Nearest); playButtonUp = new TextureRegion(texture, 0, 83, 29, 16); playButtonUp.flip(false, true); playButtonDown = new TextureRegion(texture, 29, 83, 29, 16); playButtonDown.flip(false, true); playerFace = new Texture(Gdx.files.internal("data/playerLogo.png")); playerLogo = new TextureRegion(playerFace, 0, 0, playerFace.getWidth(), playerFace.getHeight()); playerLogo.flip(false, true); ready = new TextureRegion(texture, 59, 83, 34, 7); ready.flip(false, true); retry = new TextureRegion(texture, 59, 110, 33, 7); retry.flip(false, true); gameOver = new TextureRegion(texture, 59, 92, 46, 7); gameOver.flip(false, true); scoreboard = new TextureRegion(texture, 111, 83, 97, 37); scoreboard.flip(false, true); star = new TextureRegion(texture, 152, 70, 10, 10); noStar = new TextureRegion(texture, 165, 70, 10, 10); star.flip(false, true); noStar.flip(false, true); highScore = new TextureRegion(texture, 59, 101, 48, 7); highScore.flip(false, true); zbLogo = new TextureRegion(texture, 0, 55, 135, 24); zbLogo.flip(false, true); bg = new TextureRegion(texture, 0, 0, 136, 43); bg.flip(false, true); block = new TextureRegion(texture, 0, 100, 34, 25); block.flip(false, true); grass = new TextureRegion(texture, 0, 43, 143, 11); grass.flip(false, false); birdDown = new TextureRegion(texture, 136, 0, 17, 12); birdDown.flip(false, true); bird = new TextureRegion(texture, 153, 0, 17, 12); bird.flip(false, true); birdUp = new TextureRegion(texture, 170, 0, 17, 12); birdUp.flip(false, true); TextureRegion[] birds = {birdDown, bird, birdUp}; birdAnimation = new Animation(0.06f, birds); birdAnimation.setPlayMode(Animation.LOOP_PINGPONG); skullUp = new TextureRegion(texture, 192, 0, 24, 14); // Create by flipping existing skullUp skullDown = new TextureRegion(skullUp); skullDown.flip(false, true); bar = new TextureRegion(texture, 136, 16, 22, 3); bar.flip(false, true); // dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav")); // flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav")); // coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav")); // fall = Gdx.audio.newSound(Gdx.files.internal("data/fall.wav")); font = new BitmapFont(Gdx.files.internal("data/text.fnt")); font.setScale(.25f, -.25f); whiteFont = new BitmapFont(Gdx.files.internal("data/whitetext.fnt")); whiteFont.setScale(.1f, -.1f); shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt")); shadow.setScale(.25f, -.25f); // Create (or retrieve existing) preferences file prefs = Gdx.app.getPreferences("ZombieBird"); if (!prefs.contains("highScore")) { prefs.putInteger("highScore", 0); } }