mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
formatting
This commit is contained in:
@ -11,7 +11,11 @@ class Sprite {
|
||||
|
||||
static final Paint paint = new Paint()..color = Colors.white;
|
||||
|
||||
Sprite(String fileName, {double x = 0.0, double y = 0.0, double width = null, double height = null}) {
|
||||
Sprite(String fileName,
|
||||
{double x = 0.0,
|
||||
double y = 0.0,
|
||||
double width = null,
|
||||
double height = null}) {
|
||||
Flame.images.load(fileName).then((img) {
|
||||
if (width == null) {
|
||||
width = img.width.toDouble();
|
||||
@ -24,19 +28,28 @@ class Sprite {
|
||||
});
|
||||
}
|
||||
|
||||
Sprite.fromImage(this.image, {double x = 0.0, double y = 0.0, double width = null, double height = null}) {
|
||||
if (width == null) {
|
||||
width = image.width.toDouble();
|
||||
}
|
||||
if (height == null) {
|
||||
height = image.height.toDouble();
|
||||
}
|
||||
this.src = new Rect.fromLTWH(x, y, width, height);
|
||||
Sprite.fromImage(this.image,
|
||||
{double x = 0.0,
|
||||
double y = 0.0,
|
||||
double width = null,
|
||||
double height = null}) {
|
||||
if (width == null) {
|
||||
width = image.width.toDouble();
|
||||
}
|
||||
if (height == null) {
|
||||
height = image.height.toDouble();
|
||||
}
|
||||
this.src = new Rect.fromLTWH(x, y, width, height);
|
||||
}
|
||||
|
||||
static Future<Sprite> loadSprite(String fileName, {double x = 0.0, double y = 0.0, double width = null, double height = null}) async {
|
||||
static Future<Sprite> loadSprite(String fileName,
|
||||
{double x = 0.0,
|
||||
double y = 0.0,
|
||||
double width = null,
|
||||
double height = null}) async {
|
||||
Image image = await Flame.images.load(fileName);
|
||||
return new Sprite.fromImage(image, x: x, y: y, width: width, height: height);
|
||||
return new Sprite.fromImage(image,
|
||||
x: x, y: y, width: width, height: height);
|
||||
}
|
||||
|
||||
bool loaded() {
|
||||
|
||||
Reference in New Issue
Block a user