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

Side by Side Diff: sky/sdk/example/game/lib/sprite_box.dart

Issue 1233673003: Fix bugs found by Dart analyzer (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: typo Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 part of sprites; 1 part of sprites;
2 2
3 /// Options for setting up a [SpriteBox]. 3 /// Options for setting up a [SpriteBox].
4 /// 4 ///
5 /// * [nativePoints], use the same points as the parent [Widget]. 5 /// * [nativePoints], use the same points as the parent [Widget].
6 /// * [letterbox], use the size of the root node for the coordinate system, con strain the aspect ratio and trim off 6 /// * [letterbox], use the size of the root node for the coordinate system, con strain the aspect ratio and trim off
7 /// areas that end up outside the screen. 7 /// areas that end up outside the screen.
8 /// * [stretch], use the size of the root node for the coordinate system, scale it to fit the size of the box. 8 /// * [stretch], use the size of the root node for the coordinate system, scale it to fit the size of the box.
9 /// * [scaleToFit], similar to the letterbox option, but instead of trimming ar eas the sprite system will be scaled 9 /// * [scaleToFit], similar to the letterbox option, but instead of trimming ar eas the sprite system will be scaled
10 /// down to fit the box. 10 /// down to fit the box.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 canvas.concat(transformMatrix.storage); 259 canvas.concat(transformMatrix.storage);
260 260
261 // Draw the sprite tree 261 // Draw the sprite tree
262 _rootNode._visit(canvas); 262 _rootNode._visit(canvas);
263 263
264 canvas.restore(); 264 canvas.restore();
265 } 265 }
266 266
267 // Updates 267 // Updates
268 268
269 int _animationId = 0;
270
271 void _scheduleTick() { 269 void _scheduleTick() {
272 _animationId = scheduler.requestAnimationFrame(_tick); 270 scheduler.requestAnimationFrame(_tick);
273 } 271 }
274 272
275 void _tick(double timeStamp) { 273 void _tick(double timeStamp) {
276 274
277 // Calculate the time between frames in seconds 275 // Calculate the time between frames in seconds
278 if (_lastTimeStamp == null) _lastTimeStamp = timeStamp; 276 if (_lastTimeStamp == null) _lastTimeStamp = timeStamp;
279 double delta = (timeStamp - _lastTimeStamp) / 1000; 277 double delta = (timeStamp - _lastTimeStamp) / 1000;
280 _lastTimeStamp = timeStamp; 278 _lastTimeStamp = timeStamp;
281 279
282 // Count the number of frames we've been running 280 // Count the number of frames we've been running
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 /// if (event.pointer == firstPointerId) { 383 /// if (event.pointer == firstPointerId) {
386 /// // Do something 384 /// // Do something
387 /// } 385 /// }
388 final int pointer; 386 final int pointer;
389 387
390 /// Creates a new SpriteBoxEvent, typically this is done internally inside the SpriteBox. 388 /// Creates a new SpriteBoxEvent, typically this is done internally inside the SpriteBox.
391 /// 389 ///
392 /// var event = new SpriteBoxEvent(new Point(50.0, 50.0), 'pointerdown', 0 ); 390 /// var event = new SpriteBoxEvent(new Point(50.0, 50.0), 'pointerdown', 0 );
393 SpriteBoxEvent(this.boxPosition, this.type, this.pointer); 391 SpriteBoxEvent(this.boxPosition, this.type, this.pointer);
394 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698