OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |