Commit fbb645bb authored by Viktor Lidholt's avatar Viktor Lidholt

Fixes compilation error in demo game and adds auto scrolling star field

parent 8b4d0201
...@@ -561,9 +561,10 @@ class Laser extends Sprite { ...@@ -561,9 +561,10 @@ class Laser extends Sprite {
// Background starfield // Background starfield
class StarField extends Node { class StarField extends NodeWithSize {
Image _image; sky.Image _image;
int _numStars; int _numStars;
bool _autoScroll;
List<Point> _starPositions; List<Point> _starPositions;
List<double> _starScales; List<double> _starScales;
List<Rect> _rects; List<Rect> _rects;
...@@ -573,7 +574,7 @@ class StarField extends Node { ...@@ -573,7 +574,7 @@ class StarField extends Node {
..isAntiAlias = false ..isAntiAlias = false
..setTransferMode(sky.TransferMode.plus); ..setTransferMode(sky.TransferMode.plus);
StarField(SpriteSheet spriteSheet, this._numStars) { StarField(SpriteSheet spriteSheet, this._numStars, [this._autoScroll = false]) : super(new Size(1024.0, 1024.0)) {
_starPositions = []; _starPositions = [];
_starScales = []; _starScales = [];
_colors = []; _colors = [];
...@@ -618,6 +619,12 @@ class StarField extends Node { ...@@ -618,6 +619,12 @@ class StarField extends Node {
_starPositions[i] = new Point(xPos, yPos); _starPositions[i] = new Point(xPos, yPos);
} }
} }
void update(double dt) {
if (_autoScroll) {
move(dt * 100.0, 0.0);
}
}
} }
class Hud extends NodeWithSize { class Hud extends NodeWithSize {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment