feat: drag and undrag state
This commit is contained in:
@@ -16,6 +16,7 @@ class CardComponent extends PositionComponent
|
||||
VoidCallback? onPlay; // در صورت مجاز بودن، بازیِ این کارت
|
||||
bool dimmed; // کارت غیرمجاز/غیرفعال
|
||||
Vector2? home; // موقعیت اصلی در دست (برای برگشت پس از کشیدنِ ناقص)
|
||||
int restPriority = 0; // ترتیب لایهی اصلی در دست (برای بازگردانی پس از کشیدن)
|
||||
Rect? dropZone; // ناحیهی وسط میز؛ رهاکردن کارت در آن یعنی بازی
|
||||
Sprite? _sprite;
|
||||
bool _dragging = false;
|
||||
@@ -97,6 +98,7 @@ class CardComponent extends PositionComponent
|
||||
}
|
||||
|
||||
void _returnHome() {
|
||||
priority = restPriority; // بازگردانی ترتیب لایه تا روی کارتهای دیگر نیفتد
|
||||
if (home == null) return;
|
||||
add(MoveToEffect(home!, EffectController(duration: 0.2, curve: Curves.easeOut)));
|
||||
}
|
||||
|
||||
@@ -234,6 +234,7 @@ class HokmGame extends FlameGame {
|
||||
c.dimmed = dim;
|
||||
c.home = target;
|
||||
c.dropZone = _dropZone();
|
||||
c.restPriority = 10 + i;
|
||||
c.priority = 10 + i;
|
||||
_moveTo(c, target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user