Move files to src and comply with the dart package layout convention (#621)

* 👌 Use `Offset` type directly in `JoystickAction.update` calculations (#631)

* Move files to src and comply with the dart package layout convention

* Fixing widgets example

Co-authored-by: Serge Matveenko <lig@countzero.co>
Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
This commit is contained in:
Renan
2021-01-20 09:05:43 -03:00
committed by GitHub
parent a8ef5cadea
commit ccee9a466b
146 changed files with 1232 additions and 1275 deletions

View File

@@ -0,0 +1,46 @@
import 'dart:ui';
import 'package:flutter/foundation.dart';
import '../extensions/vector2.dart';
import '../sprite.dart';
import 'component.dart';
import 'position_component.dart';
export '../sprite.dart';
/// A [PositionComponent] that renders a single [Sprite] at the designated
/// position, scaled to have the designated size and rotated to the specified
/// angle.
///
/// This a commonly used subclass of [Component].
class SpriteComponent extends PositionComponent {
/// The [sprite] to be rendered by this component.
Sprite sprite;
/// Use this to override the colour used (to apply tint or opacity).
///
/// If not provided the default is full white (no tint).
Paint overridePaint;
/// Creates a component with an empty sprite which can be set later
SpriteComponent();
SpriteComponent.fromImage(Vector2 size, Image image)
: this.fromSprite(size, Sprite(image));
SpriteComponent.fromSprite(Vector2 size, this.sprite) {
super.size.setFrom(size);
}
@mustCallSuper
@override
void render(Canvas canvas) {
super.render(canvas);
sprite?.render(
canvas,
size: size,
overridePaint: overridePaint,
);
}
}