From fbb645bb92a6f9fc9ce39fc9836cdd83f7266b02 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 --- .../flutter/example/game/lib/game_demo_world.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/flutter/example/game/lib/game_demo_world.dart b/packages/flutter/example/game/lib/game_demo_world.dart index f5bf2524ac0..6ee0c018d21 100644 --- a/packages/flutter/example/game/lib/game_demo_world.dart +++ b/packages/flutter/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 {