mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
Scale for PositionComponent (#892)
* Draft of PositionComponent.scale * Use matrix transformations * Update tests to take matrix transform into consideration * Add tests for collision detection with scale * Rename ScaleEffect to SizeEffect * Use transform matrix to prepare canvas * Fix scaledSizeCache * Add changelog entries and docs * Dartdoc on public access methods * Update packages/flame/CHANGELOG.md Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net> * Move cache classes to own directory Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
import 'package:flame/components.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flame/input.dart';
|
||||
|
||||
class Square extends PositionComponent {
|
||||
Square(Vector2 position, Vector2 size, {double angle = 0}) {
|
||||
this.position.setFrom(position);
|
||||
this.size.setFrom(size);
|
||||
this.angle = angle;
|
||||
}
|
||||
Square(Vector2 position, Vector2 size, {double angle = 0})
|
||||
: super(
|
||||
position: position,
|
||||
size: size,
|
||||
angle: angle,
|
||||
);
|
||||
}
|
||||
|
||||
class ParentSquare extends Square with HasGameRef {
|
||||
@ -31,7 +33,7 @@ class ParentSquare extends Square with HasGameRef {
|
||||
}
|
||||
}
|
||||
|
||||
class Composability extends BaseGame {
|
||||
class Composability extends BaseGame with TapDetector {
|
||||
late ParentSquare _parent;
|
||||
|
||||
@override
|
||||
@ -49,4 +51,10 @@ class Composability extends BaseGame {
|
||||
super.update(dt);
|
||||
_parent.angle += dt;
|
||||
}
|
||||
|
||||
@override
|
||||
void onTap() {
|
||||
super.onTap();
|
||||
_parent.scale = Vector2.all(2.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user