Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2195)

Unified Diff: samples/pop_pop_win/lib/src/stage/game_root.dart

Issue 242443008: samples/pop_pop_win: now based on StageXL (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added Alex to authors Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samples/pop_pop_win/lib/src/stage/game_root.dart
diff --git a/samples/pop_pop_win/lib/src/stage/game_root.dart b/samples/pop_pop_win/lib/src/stage/game_root.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1d1887e36538bb1b4a31184f3080e1d81cb2c622
--- /dev/null
+++ b/samples/pop_pop_win/lib/src/stage/game_root.dart
@@ -0,0 +1,46 @@
+library pop_pop_win.stage.game_root;
+
+import 'package:stagexl/stagexl.dart';
+
+import '../audio.dart';
+import '../game.dart';
+import '../game_manager.dart';
+import 'game_element.dart';
+
+class GameRoot extends GameManager {
+ final Stage stage;
+ final ResourceManager resourceManager;
+ GameElement _gameElement;
+
+ GameRoot(int width, int height, int bombCount,
+ this.stage, this.resourceManager) : super(width, height, bombCount) {
+
+ var opa = resourceManager.getTextureAtlas('opaque');
+ var sta = resourceManager.getTextureAtlas('static');
+
+ _gameElement = new GameElement(this)
+ ..alpha = 0;
+
+ stage
Siggi Cherem (dart-lang) 2014/04/21 22:00:56 I'd remove this \n
kevmoo 2014/04/21 22:22:54 Done.
+ ..addChild(_gameElement)
+ ..juggler.tween(_gameElement, .5).animate.alpha.to(1);
+ }
+
+ void onGameStateChanged(GameState newState) {
+ if (newState == GameState.won) {
+ _gameElement.boardElement.squares.forEach((se) => se.updateState());
+ if (game.duration.inMilliseconds < _gameElement.scoreElement.bestTime
+ || _gameElement.scoreElement.bestTime == 0) {
+ _gameElement.scoreElement.bestTime = game.duration.inMilliseconds;
+ }
+ GameAudio.win();
+ }
+ }
+
+ void newGame() {
+ super.newGame();
+ if (_gameElement != null) {
+ _gameElement.boardElement.squares.forEach((se) => se.updateState());
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698