Class ScrollingBackground


  • public class ScrollingBackground
    extends java.lang.Object
    Represents the scrolling background.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.badlogic.gdx.graphics.Texture image
      The texture to use as the background.
      private float imageScale
      The scale at which to draw the background.
      private float xPosition
      The x position that both the images use to align vertically.
      private float y1
      The y position of the first image.
      private float y2
      The y position the second image.
    • Constructor Summary

      Constructors 
      Constructor Description
      ScrollingBackground()
      Creates a new scrolling background.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Render the background at its current y1 and y2 positions.
      void resize​(int width)
      Resize the background to scale with width.
      void update​(float deltaDistance)
      Scroll the background according the distance travelled by the player.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • image

        private final com.badlogic.gdx.graphics.Texture image
        The texture to use as the background.
      • xPosition

        private final float xPosition
        The x position that both the images use to align vertically.
      • y1

        private float y1
        The y position of the first image.
      • y2

        private float y2
        The y position the second image.
      • imageScale

        private float imageScale
        The scale at which to draw the background.
    • Constructor Detail

      • ScrollingBackground

        public ScrollingBackground()
        Creates a new scrolling background.
    • Method Detail

      • update

        public void update​(float deltaDistance)
        Scroll the background according the distance travelled by the player.
        Parameters:
        deltaDistance - The distance travelled in the last frame by the player.
      • render

        public void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
        Render the background at its current y1 and y2 positions.
        Parameters:
        batch - The SpriteBatch to be added to.
      • resize

        public void resize​(int width)
        Resize the background to scale with width.
        Parameters:
        width - The width to scale to.