Class ParallaxLayer
java.lang.Object
com.csse3200.game.rendering.parallax.ParallaxLayer
Represents a single layer in a parallax background system.
Each layer can scroll at a different speed relative to the camera movement,
creating depth perception. Layers can be either tiled (repeated) or stretched
to fill the viewport.
-
Constructor Summary
ConstructorsConstructorDescriptionParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight) Creates a basic parallax layer with default settings.ParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight, boolean tileHorizontally, boolean tileVertically, float tileWidth, float tileHeight, float offsetX, float offsetY) Creates a tiled parallax layer with custom offset.ParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight, boolean tileHorizontally, boolean tileVertically, float tileWidth, float tileHeight, float offsetX, float offsetY, float scaleX, float scaleY) Creates a fully customizable parallax layer.ParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight, float offsetX, float offsetY) Creates a parallax layer with custom offset. -
Method Summary
Modifier and TypeMethodDescriptionvoidrender(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Renders this parallax layer to the screen.
-
Constructor Details
-
ParallaxLayer
public ParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight) Creates a basic parallax layer with default settings. The layer will be stretched and use default scaling (1.0).- Parameters:
texture- The texture to displaycamera- The camera to track for parallax calculationsfactor- The parallax factor (0.0 = static, 1.0 = moves with camera)mapWidth- The total width of the game mapmapHeight- The total height of the game map
-
ParallaxLayer
public ParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight, float offsetX, float offsetY) Creates a parallax layer with custom offset. The layer will be stretched and use default scaling (1.0).- Parameters:
texture- The texture to displaycamera- The camera to track for parallax calculationsfactor- The parallax factor (0.0 = static, 1.0 = moves with camera)mapWidth- The total width of the game mapmapHeight- The total height of the game mapoffsetX- Horizontal offset in world unitsoffsetY- Vertical offset in world units
-
ParallaxLayer
public ParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight, boolean tileHorizontally, boolean tileVertically, float tileWidth, float tileHeight, float offsetX, float offsetY) Creates a tiled parallax layer with custom offset. The texture will be repeated according to the tiling parameters.- Parameters:
texture- The texture to displaycamera- The camera to track for parallax calculationsfactor- The parallax factor (0.0 = static, 1.0 = moves with camera)mapWidth- The total width of the game mapmapHeight- The total height of the game maptileHorizontally- Whether to tile the texture horizontallytileVertically- Whether to tile the texture verticallytileWidth- Width of each tile (0 = use texture width)tileHeight- Height of each tile (0 = use texture height)offsetX- Horizontal offset in world unitsoffsetY- Vertical offset in world units
-
ParallaxLayer
public ParallaxLayer(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Camera camera, float factor, float mapWidth, float mapHeight, boolean tileHorizontally, boolean tileVertically, float tileWidth, float tileHeight, float offsetX, float offsetY, float scaleX, float scaleY) Creates a fully customizable parallax layer. This is the master constructor that all other constructors delegate to.- Parameters:
texture- The texture to displaycamera- The camera to track for parallax calculationsfactor- The parallax factor (0.0 = static, 1.0 = moves with camera)mapWidth- The total width of the game mapmapHeight- The total height of the game maptileHorizontally- Whether to tile the texture horizontallytileVertically- Whether to tile the texture verticallytileWidth- Width of each tile before scaling (0 = use texture width)tileHeight- Height of each tile before scaling (0 = use texture height)offsetX- Horizontal offset in world unitsoffsetY- Vertical offset in world unitsscaleX- Horizontal scale factor (1.0 = original size)scaleY- Vertical scale factor (1.0 = original size)
-
-
Method Details
-
render
public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Renders this parallax layer to the screen. Calculates the appropriate position based on camera movement and parallax factor, then renders either as tiles or stretched based on configuration.- Parameters:
batch- The sprite batch to use for rendering
-