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

Unified Diff: samples/pop_pop_win/web/game.dart

Issue 200723008: samples/poppopwin: upgrade to first-class sample (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed pkgbuild.status for rename Created 6 years, 9 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
« no previous file with comments | « samples/pop_pop_win/web/favicon.ico ('k') | samples/pop_pop_win/web/game_web.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/pop_pop_win/web/game.dart
diff --git a/samples/third_party/pop-pop-win/web/game.dart b/samples/pop_pop_win/web/game.dart
similarity index 83%
rename from samples/third_party/pop-pop-win/web/game.dart
rename to samples/pop_pop_win/web/game.dart
index 3cb58f1654ce70f855b4646c79f10e19a4ec8c65..50657338136f154e0c2263881779d0a71692bfcf 100644
--- a/samples/third_party/pop-pop-win/web/game.dart
+++ b/samples/pop_pop_win/web/game.dart
@@ -13,16 +13,18 @@ import 'texture_data.dart';
part '_audio.dart';
-const String _TRANSPARENT_TEXTURE = 'images/transparent_animated.png';
-const String _OPAQUE_TEXTURE = 'images/dart_opaque_01.jpg';
-const String _TRANSPARENT_STATIC_TEXTURE = 'images/transparent_static.png';
+const String _ASSET_DIR = 'assets/poppopwin/';
+
+const String _TRANSPARENT_TEXTURE = '${_ASSET_DIR}images/transparent_animated.png';
+const String _OPAQUE_TEXTURE = '${_ASSET_DIR}images/dart_opaque_01.jpg';
+const String _TRANSPARENT_STATIC_TEXTURE = '${_ASSET_DIR}images/transparent_static.png';
const int _LOADING_BAR_PX_WIDTH = 398;
DivElement _loadingBar;
ImageLoader _imageLoader;
-_Audio _audio;
+final _Audio _audio = new _Audio();
void startGame(PlatformTarget platform) {
initPlatform(platform);
@@ -36,25 +38,24 @@ void startGame(PlatformTarget platform) {
_imageLoader.loaded.listen(_onLoaded);
_imageLoader.progress.listen(_onProgress);
_imageLoader.load();
-
- _audio = new _Audio();
}
-void _onProgress(args) {
+void _onProgress(_) {
int completedBytes = _imageLoader.completedBytes;
int totalBytes = _imageLoader.totalBytes;
completedBytes += _audio.completedBytes;
totalBytes += _audio.totalBytes;
- final percent = completedBytes / totalBytes;
- final percentClean = (percent * 1000).floor() / 10;
+ var percent = completedBytes / totalBytes;
+ if (percent == double.INFINITY) percent = 0;
+ var percentClean = (percent * 1000).floor() / 10;
- final barWidth = percent * _LOADING_BAR_PX_WIDTH;
+ var barWidth = percent * _LOADING_BAR_PX_WIDTH;
_loadingBar.style.width = '${barWidth.toInt()}px';
}
-void _onLoaded(args) {
+void _onLoaded(_) {
if(_imageLoader.state == ResourceLoader.StateLoaded && _audio.done) {
//
« no previous file with comments | « samples/pop_pop_win/web/favicon.ico ('k') | samples/pop_pop_win/web/game_web.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698