Module parallax
A repeating background that features proportional scrolling in relation to a Scene's Camera.
Parallax repeats ParallaxLayers through the x axis.
When the Camera pans along the x axis, the layers scroll
proportionately according to p_factor.
Stacking layers back-to-front with an increasing p_factor can create
the illusion of 3D depth in 2D.
Parallax also offers the ability to react to y axis panning. Using
y_wiggle and sea_level , you can create the illusion of altitude.
Layers do not repeat through the y axis.
Parallax extends BoundObject
Properties
| sky_color | An {r, g, b, a} vector that represents the background color
for the top of the Parallax. |
| sea_color | An {r, g, b, a} vector that represents the background color
for the bottom of the Parallax. |
| y_wiggle | The pixel range across which to translate the Parallax against
the camera.focal y position. |
| sea_level | The percentage across the Scene y axis where the Parallax
considered to be "flat" when simulating altitude effects. |
| bg_z | The z value for the Parallax's sky and sea background rectangles. |
Class Methods
| Parallax:new (...) | Create a new Parallax |
Instance Methods
| parallax:add_layer (layer) | Add a ParallaxLayer to Parallax |
| parallax:add_layers (...) | Add a variable list of ParallaxLayers to Parallax |
Properties
Properties. Significant fields on an instance.- sky_color
-
An
{r, g, b, a}vector that represents the background color for the top of theParallax.The height of the "sky" is (screen height * sea_level )
Default
{0, 0, 1, 1}(solid blue)Warning: You must set the property explicitly for changes to take apply. Like this:
parallax.sky_color = {0.5, 0, 0, 1}Not this:
parallax.sky_color[1] = 0.5 - sea_color
-
An
{r, g, b, a}vector that represents the background color for the bottom of theParallax.The height of the "sea" is (screen height * (1 - sea_level ))
Default
{0, 1, 0, 1}(solid green)Warning: You must set the property explicitly for changes to take apply. Like this:
parallax.sea_color = {0.5, 0, 0, 1}Not this:
parallax.sea_color[1] = 0.5 - y_wiggle
-
The pixel range across which to translate the
Parallaxagainst the camera.focalyposition.A positive y_wiggle means that
Parallaxwill translate opposite theCamera(camera goes down, parallax goes up). Can be positive or negative.Default
0 - sea_level
-
The percentage across the
Sceneyaxis where theParallaxconsidered to be "flat" when simulating altitude effects. This might be0.0if you are creating overhead clouds, or1.0if you are creating an ocean.Default
0.5 - bg_z
-
The z value for the
Parallax's sky and sea background rectangles. Default-200.0
Class Methods
Class Methods. Must be called onClass, with a capital leading character.
e.g. Class:method("foo")
- Parallax:new (...)
-
Create a new
ParallaxParameters:
- ... ParallaxLayer A variable list of ParallaxLayers to add upon creation.
Returns:
-
Parallax
Instance Methods
Instance Methods. Must be called on an instance ofClass.
e.g. instance:method("foo")
- parallax:add_layer (layer)
-
Add a ParallaxLayer to
ParallaxParameters:
- layer ParallaxLayer The layer to add
Returns:
-
nil
- parallax:add_layers (...)
-
Add a variable list of ParallaxLayers to
ParallaxParameters:
- ... ParallaxLayer The layers to add
Returns:
-
nil