From 1ace7181ed2c041925db2d74f6af0bc1161a1b01 Mon Sep 17 00:00:00 2001 From: Viktor Lidholt Date: Tue, 28 Jul 2015 17:21:06 -0700 Subject: [PATCH] Fixes compilation error in demo game and adds auto scrolling star field --- .../sky/example/game/lib/game_demo_world.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sky/packages/sky/example/game/lib/game_demo_world.dart b/sky/packages/sky/example/game/lib/game_demo_world.dart index f5bf2524ac0..6ee0c018d21 100644 --- a/sky/packages/sky/example/game/lib/game_demo_world.dart +++ b/sky/packages/sky/example/game/lib/game_demo_world.dart @@ -561,9 +561,10 @@ class Laser extends Sprite { // Background starfield -class StarField extends Node { - Image _image; +class StarField extends NodeWithSize { + sky.Image _image; int _numStars; + bool _autoScroll; List _starPositions; List _starScales; List _rects; @@ -573,7 +574,7 @@ class StarField extends Node { ..isAntiAlias = false ..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 = []; _starScales = []; _colors = []; @@ -618,6 +619,12 @@ class StarField extends Node { _starPositions[i] = new Point(xPos, yPos); } } + + void update(double dt) { + if (_autoScroll) { + move(dt * 100.0, 0.0); + } + } } class Hud extends NodeWithSize {