mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 20:13:50 +08:00
more api options
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user