Modifying FlxStarfield and FlxStarfield2D#464
Modifying FlxStarfield and FlxStarfield2D#464ezacharyk wants to merge 4 commits intoHaxeFlixel:devfrom
Conversation
|
What are these classes even used for- |
These classes create an animated starfield background for your game. The 2d one, makes the stars fly in a horizontal or vertical direction. The 3d one makes the stars fly like when Star Wars ships start up hyperspace. Here is an example with the 2D starfield: |
|
I feel like it would be a good idea to say what they do in a comment or something then since they don't have any descriptions right now. |
Good point. I have added comments to the classes to provide those descriptions |
|
Realized I missed a step in the Code Review Process. Here is a public repo with a running test of the FlxStarfield2D class with the above changes: |
Modifying FlxStarfield and FlxStarfield2D to Utilize a 0 speed for static starfield.
I needed a version of Starfield with stationary stars. So I modified Starfield and Starfield2d to accommodate for a static field by setting the starspeed to 0, specifically, the max speed.
When creating a new Starfield2D, just set the speed to 0:
var stars = new FlxStarField2D(); stars.setStarSpeed(0,0);The FlxStarfield and FlxStarfield2D then check if the speed is 0 and if so, it does not move the stars. It retains the ability for the stars to twinkle by setting a FlxG.random.float(0,1) in the FlxStarfield.draw function when assigning the colorIndex.