Android Open Source - ninja-trials Run Bg






From Project

Back to project page ninja-trials.

License

The source code is released under:

Apache License

If you think the Android project ninja-trials listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.madgear.ninjatrials.trials.run;
//from   w  ww .  jav a 2s. com
import org.andengine.entity.Entity;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.AutoParallaxBackground;
import org.andengine.entity.scene.background.ParallaxBackground.ParallaxEntity;
import org.andengine.entity.sprite.Sprite;

import com.madgear.ninjatrials.managers.ResourceManager;


/**
 * Class load Background to run trial.
 */
public class RunBg extends Entity {

  private ParallaxEntity parallaxEntityFloor;
  private ParallaxEntity parallaxEntityTreesFront;
  private ParallaxEntity parallaxEntityTreesBack;

  private AutoParallaxBackground autoParallaxBg;

    /**
     * Contructor. Create backgroung to run trial using parallax backgroung.
     *
     * @param speed general speed of parallax backgroung
     * @param speedFloor floor speed of parallax background
     * @param speedTreesFront trees front speed of parallax background
     * @param speedTreesBack trees back speed of parallax background
     *
     * @return RunBg object
     */
    public RunBg(float speed, float speedFloor, float speedTreesFront, float speedTreesBack) {
    final Scene scene = new Scene();
    autoParallaxBg = new AutoParallaxBackground(0, 0, 0, 5);
    scene.setBackground(autoParallaxBg);
    this.attachChild(scene);

    final Sprite parallaxBackSprite = new Sprite(0, 306,
                ResourceManager.getInstance().runBgTreesBack,
                ResourceManager.getInstance().engine.getVertexBufferObjectManager());
        parallaxBackSprite.setOffsetCenter(0, 0);
        parallaxEntityTreesBack = new ParallaxEntity(speedTreesBack, parallaxBackSprite);
    autoParallaxBg.attachParallaxEntity(parallaxEntityTreesBack);

    final Sprite parallaxFloorSprite = new Sprite(0, 0,
                ResourceManager.getInstance().runBgFloor,
                ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    parallaxFloorSprite.setOffsetCenter(0, 0);
        parallaxEntityFloor = new ParallaxEntity(speedFloor, parallaxFloorSprite);
    autoParallaxBg.attachParallaxEntity(parallaxEntityFloor);

    final Sprite parallaxFrontSprite = new Sprite(0,
                ResourceManager.getInstance().cameraHeight -
                    ResourceManager.getInstance().runBgTreesFront.getHeight(),
                ResourceManager.getInstance().runBgTreesFront,
                ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    parallaxFrontSprite.setOffsetCenter(0, 0);
        parallaxEntityTreesFront = new ParallaxEntity(speedTreesFront, parallaxFrontSprite);
    autoParallaxBg.attachParallaxEntity(parallaxEntityTreesFront);

    autoParallaxBg.setParallaxChangePerSecond(speed);
  }

    /**
     * Update speed.
     *
     * @param speed float with new speed.
     */
    public void updateSpeed(int speed) {
        autoParallaxBg.setParallaxChangePerSecond(speed);
  }
}




Java Source Code List

com.madgear.ninjatrials.AchievementsScene.java
com.madgear.ninjatrials.CharacterIntroScene.java
com.madgear.ninjatrials.ControllerOptionsScene.java
com.madgear.ninjatrials.DummyMenu.java
com.madgear.ninjatrials.GameScene.java
com.madgear.ninjatrials.IUserInput.java
com.madgear.ninjatrials.MainMenuScene.java
com.madgear.ninjatrials.MainOptionsScene.java
com.madgear.ninjatrials.ManagedLayer.java
com.madgear.ninjatrials.ManagedScene.java
com.madgear.ninjatrials.MapScene.java
com.madgear.ninjatrials.NinjaTrials.java
com.madgear.ninjatrials.PlayerSelectionScene.java
com.madgear.ninjatrials.RecordsScene.java
com.madgear.ninjatrials.ResultLoseScene.java
com.madgear.ninjatrials.ResultTrial.java
com.madgear.ninjatrials.ResultWinScene.java
com.madgear.ninjatrials.achievements.AchievementSetNinjaTrial.java
com.madgear.ninjatrials.achievements.AchievementSet.java
com.madgear.ninjatrials.achievements.Achievement.java
com.madgear.ninjatrials.hud.AchievementNotify.java
com.madgear.ninjatrials.hud.Chronometer.java
com.madgear.ninjatrials.hud.GameHUD.java
com.madgear.ninjatrials.hud.HeadCharacter.java
com.madgear.ninjatrials.hud.PowerBar.java
com.madgear.ninjatrials.hud.PrecisionAngleBar.java
com.madgear.ninjatrials.hud.PrecisionBar.java
com.madgear.ninjatrials.hud.SelectionStripe.java
com.madgear.ninjatrials.hud.ShurikenEnemyCounter.java
com.madgear.ninjatrials.hud.VolumeBar.java
com.madgear.ninjatrials.layers.GameOverLayer.java
com.madgear.ninjatrials.managers.GameManager.java
com.madgear.ninjatrials.managers.ResourceManager.java
com.madgear.ninjatrials.managers.SFXManager.java
com.madgear.ninjatrials.managers.SceneManager.java
com.madgear.ninjatrials.managers.UserData.java
com.madgear.ninjatrials.records.Record.java
com.madgear.ninjatrials.records.RecordsTableSet.java
com.madgear.ninjatrials.records.RecordsTable.java
com.madgear.ninjatrials.sequences.CreditsScene.java
com.madgear.ninjatrials.sequences.EndingScene.java
com.madgear.ninjatrials.sequences.EndingSequenceRyokoEasy.java
com.madgear.ninjatrials.sequences.EndingSequenceShoEasy.java
com.madgear.ninjatrials.sequences.Intro1Scene.java
com.madgear.ninjatrials.sequences.Intro2Scene.java
com.madgear.ninjatrials.sequences.Intro2SequenceRyokoEasy.java
com.madgear.ninjatrials.sequences.Intro2SequenceShoEasy.java
com.madgear.ninjatrials.sequences.Sequence.java
com.madgear.ninjatrials.sequences.SplashIntroScene.java
com.madgear.ninjatrials.trials.TrialSceneCut.java
com.madgear.ninjatrials.trials.TrialSceneJump.java
com.madgear.ninjatrials.trials.TrialSceneRun.java
com.madgear.ninjatrials.trials.TrialSceneShuriken.java
com.madgear.ninjatrials.trials.run.RunBg.java
com.madgear.ninjatrials.trials.run.RunCharacter.java
com.madgear.ninjatrials.trials.shuriken.ShurikenCoordinates.java
com.madgear.ninjatrials.trials.shuriken.ShurikenEnemy.java
com.madgear.ninjatrials.trials.shuriken.ShurikenHands.java
com.madgear.ninjatrials.trials.shuriken.ShurikenShuriken.java
com.madgear.ninjatrials.utils.AutoDiagonalParallaxBackground.java
com.madgear.ninjatrials.utils.AutoHorizontalParallaxBackground.java
com.madgear.ninjatrials.utils.AutoVerticalParallaxBackground.java
com.madgear.ninjatrials.utils.ParallaxBackground2d.java