more api options

This commit is contained in:
Luan Nico
2017-12-30 17:46:47 -02:00
parent 16b86c5a5d
commit fbaec30724
2 changed files with 5 additions and 1 deletions

View File

@ -75,7 +75,7 @@ class SpriteComponent extends PositionComponent {
@override
render(Canvas canvas) {
if (sprite.loaded() && x != null && y != null) {
if (sprite != null && sprite.loaded() && x != null && y != null) {
prepareCanvas(canvas);
sprite.render(canvas, width, height);
}

View File

@ -9,6 +9,10 @@ class Sprite {
static final Paint paint = new Paint()..color = Colors.white;
Sprite.fromImage(this.image) {
this.src = new Rect.fromLTWH(0.0, 0.0, image.width.toDouble(), image.height.toDouble());
}
Sprite(String fileName, {double x = 0.0, double y = 0.0, double width = -1.0, double height = -1.0}) {
Flame.images.load(fileName).then((img) {
if (width == -1.0) {