mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 20:36:31 +08:00
more api options
This commit is contained in:
@ -75,7 +75,7 @@ class SpriteComponent extends PositionComponent {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
render(Canvas canvas) {
|
render(Canvas canvas) {
|
||||||
if (sprite.loaded() && x != null && y != null) {
|
if (sprite != null && sprite.loaded() && x != null && y != null) {
|
||||||
prepareCanvas(canvas);
|
prepareCanvas(canvas);
|
||||||
sprite.render(canvas, width, height);
|
sprite.render(canvas, width, height);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,10 @@ class Sprite {
|
|||||||
|
|
||||||
static final Paint paint = new Paint()..color = Colors.white;
|
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}) {
|
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) {
|
Flame.images.load(fileName).then((img) {
|
||||||
if (width == -1.0) {
|
if (width == -1.0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user