mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 11:43:19 +08:00
Vector2 for position and size on PositionComponent
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'sprite.dart';
|
||||
import 'sprite_animation.dart';
|
||||
import 'extensions/vector2.dart';
|
||||
|
||||
/// Utility class to help extract animations and sprites from a spritesheet image
|
||||
class SpriteSheet {
|
||||
@ -36,12 +38,11 @@ class SpriteSheet {
|
||||
int x,
|
||||
int y,
|
||||
) {
|
||||
Vector2 size = Vector2(textureWidth.toDouble(), textureHeight.toDouble());
|
||||
return Sprite(
|
||||
imageName,
|
||||
x: (x * textureWidth).toDouble(),
|
||||
y: (y * textureHeight).toDouble(),
|
||||
width: textureWidth.toDouble(),
|
||||
height: textureHeight.toDouble(),
|
||||
position: Vector2(x.toDouble(), y.toDouble())..multiply(size),
|
||||
size: size,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user