Package com.dragonboatrace.tools
Class ScrollingBackground
- java.lang.Object
-
- com.dragonboatrace.tools.ScrollingBackground
-
public class ScrollingBackground extends java.lang.ObjectRepresents the scrolling background.
-
-
Field Summary
Fields Modifier and Type Field Description private com.badlogic.gdx.graphics.TextureimageThe texture to use as the background.private floatimageScaleThe scale at which to draw the background.private floatxPositionThe x position that both the images use to align vertically.private floaty1The y position of the first image.private floaty2The 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 voidrender(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)Render the background at its current y1 and y2 positions.voidresize(int width)Resize the background to scale with width.voidupdate(float deltaDistance)Scroll the background according the distance travelled by the player.
-
-
-
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.
-
-
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.
-
-