Android Open Source - Froggy Scrollable






From Project

Back to project page Froggy.

License

The source code is released under:

GNU General Public License

If you think the Android project Froggy 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.mopgames.GameObjects;
//from  w w  w . ja  v a 2s . c o m
import com.badlogic.gdx.math.Vector2;

public class Scrollable {

  // Protected is similar to private, but allows inheritance by subclasses.
  protected Vector2 position;
  protected Vector2 velocity;
  protected int width;
  protected int height;
  protected boolean isScrolledLeft;

  public Scrollable(float x, float y, int width, int height, float scrollSpeed) {
    position = new Vector2(x, y);
    velocity = new Vector2(scrollSpeed, 0);
    this.width = width;
    this.height = height;
    isScrolledLeft = false;
  }

  public void update(float delta) {
    position.add(velocity.cpy().scl(delta));

    // If the Scrollable object is no longer visible:
    if (position.x + width < 0) {
      isScrolledLeft = true;
    }
  }

  // Reset: Should Override in subclass for more specific behavior.
  public void reset(float newX) {
    position.x = newX;
    isScrolledLeft = false;
  }

  public void stop() {
    velocity.x = 0;
  }

  // Getters for instance variables
  public boolean isScrolledLeft() {
    return isScrolledLeft;
  }

  public float getTailX() {
    return position.x + width;
  }

  public float getX() {
    return position.x;
  }

  public float getY() {
    return position.y;
  }

  public int getWidth() {
    return width;
  }

  public int getHeight() {
    return height;
  }

}




Java Source Code List

android.UnusedStub.java
com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.GameHelper.java
com.mopgames.ActionResolverDesktop.java
com.mopgames.MainActivity.java
com.mopgames.Main.java
com.mopgames.RobovmLauncher.java
com.mopgames.Froggy.FroggyGame.java
com.mopgames.GameObjects.Background.java
com.mopgames.GameObjects.Frog.java
com.mopgames.GameObjects.Lilypad.java
com.mopgames.GameObjects.MenuItem.java
com.mopgames.GameObjects.ScrollHandler.java
com.mopgames.GameObjects.Scrollable.java
com.mopgames.GameWorld.GameRenderer.java
com.mopgames.GameWorld.GameWorld.java
com.mopgames.Helpers.ActionResolver.java
com.mopgames.Helpers.AssetLoader.java
com.mopgames.Helpers.InputHandler.java
com.mopgames.Screens.GameScreen.java
com.mopgames.Screens.SplashScreen.java
com.mopgames.TweenAccessors.SpriteAccessor.java
com.mopgames.TweenAccessors.ValueAccessor.java
com.mopgames.TweenAccessors.Value.java
com.mopgames.client.ActionResolverDesktop.java
com.mopgames.client.GwtLauncher.java
com.mopgames.ui.SimpleButton.java