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

Side by Side Diff: sky/examples/game/lib/sprite_box.dart

Issue 1204783003: Adds basic sprite sheet support to sprites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Adds basic sprite sheet support to sprites (fixed issues) 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 case SpriteBoxTransformMode.stretch: 198 case SpriteBoxTransformMode.stretch:
199 scaleX = size.width/systemWidth; 199 scaleX = size.width/systemWidth;
200 scaleY = size.height/systemHeight; 200 scaleY = size.height/systemHeight;
201 break; 201 break;
202 case SpriteBoxTransformMode.letterbox: 202 case SpriteBoxTransformMode.letterbox:
203 scaleX = size.width/systemWidth; 203 scaleX = size.width/systemWidth;
204 scaleY = size.height/systemHeight; 204 scaleY = size.height/systemHeight;
205 if (scaleX > scaleY) { 205 if (scaleX > scaleY) {
206 scaleY = scaleX; 206 scaleY = scaleX;
207 offsetY = (size.height - scaleY * systemHeight)/2.0; 207 offsetY = (size.height - scaleY * systemHeight)/2.0;
208 } 208 } else {
209 else {
210 scaleX = scaleY; 209 scaleX = scaleY;
211 offsetX = (size.width - scaleX * systemWidth)/2.0; 210 offsetX = (size.width - scaleX * systemWidth)/2.0;
212 } 211 }
213 break; 212 break;
214 case SpriteBoxTransformMode.scaleToFit: 213 case SpriteBoxTransformMode.scaleToFit:
215 scaleX = size.width/systemWidth; 214 scaleX = size.width/systemWidth;
216 scaleY = size.height/systemHeight; 215 scaleY = size.height/systemHeight;
217 if (scaleX < scaleY) { 216 if (scaleX < scaleY) {
218 scaleY = scaleX; 217 scaleY = scaleX;
219 offsetY = (size.height - scaleY * systemHeight)/2.0; 218 offsetY = (size.height - scaleY * systemHeight)/2.0;
220 } 219 } else {
221 else {
222 scaleX = scaleY; 220 scaleX = scaleY;
223 offsetX = (size.width - scaleX * systemWidth)/2.0; 221 offsetX = (size.width - scaleX * systemWidth)/2.0;
224 } 222 }
225 break; 223 break;
226 case SpriteBoxTransformMode.fixedWidth: 224 case SpriteBoxTransformMode.fixedWidth:
227 scaleX = size.width/systemWidth; 225 scaleX = size.width/systemWidth;
228 scaleY = scaleX; 226 scaleY = scaleX;
229 systemHeight = size.height/scaleX; 227 systemHeight = size.height/scaleX;
230 rootNode.size = new Size(systemWidth, systemHeight); 228 rootNode.size = new Size(systemWidth, systemHeight);
231 break; 229 break;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 /// if (event.pointer == firstPointerId) { 372 /// if (event.pointer == firstPointerId) {
375 /// // Do something 373 /// // Do something
376 /// } 374 /// }
377 final int pointer; 375 final int pointer;
378 376
379 /// Creates a new SpriteBoxEvent, typically this is done internally inside the SpriteBox. 377 /// Creates a new SpriteBoxEvent, typically this is done internally inside the SpriteBox.
380 /// 378 ///
381 /// var event = new SpriteBoxEvent(new Point(50.0, 50.0), 'pointerdown', 0 ); 379 /// var event = new SpriteBoxEvent(new Point(50.0, 50.0), 'pointerdown', 0 );
382 SpriteBoxEvent(this.boxPosition, this.type, this.pointer); 380 SpriteBoxEvent(this.boxPosition, this.type, this.pointer);
383 } 381 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698