feat: drag and undrag state

This commit is contained in:
2026-06-15 17:50:38 +03:30
parent 323031adbe
commit dee3fbad6d
2 changed files with 3 additions and 0 deletions
@@ -16,6 +16,7 @@ class CardComponent extends PositionComponent
VoidCallback? onPlay; // در صورت مجاز بودن، بازیِ این کارت VoidCallback? onPlay; // در صورت مجاز بودن، بازیِ این کارت
bool dimmed; // کارت غیرمجاز/غیرفعال bool dimmed; // کارت غیرمجاز/غیرفعال
Vector2? home; // موقعیت اصلی در دست (برای برگشت پس از کشیدنِ ناقص) Vector2? home; // موقعیت اصلی در دست (برای برگشت پس از کشیدنِ ناقص)
int restPriority = 0; // ترتیب لایه‌ی اصلی در دست (برای بازگردانی پس از کشیدن)
Rect? dropZone; // ناحیه‌ی وسط میز؛ رهاکردن کارت در آن یعنی بازی Rect? dropZone; // ناحیه‌ی وسط میز؛ رهاکردن کارت در آن یعنی بازی
Sprite? _sprite; Sprite? _sprite;
bool _dragging = false; bool _dragging = false;
@@ -97,6 +98,7 @@ class CardComponent extends PositionComponent
} }
void _returnHome() { void _returnHome() {
priority = restPriority; // بازگردانی ترتیب لایه تا روی کارت‌های دیگر نیفتد
if (home == null) return; if (home == null) return;
add(MoveToEffect(home!, EffectController(duration: 0.2, curve: Curves.easeOut))); add(MoveToEffect(home!, EffectController(duration: 0.2, curve: Curves.easeOut)));
} }
+1
View File
@@ -234,6 +234,7 @@ class HokmGame extends FlameGame {
c.dimmed = dim; c.dimmed = dim;
c.home = target; c.home = target;
c.dropZone = _dropZone(); c.dropZone = _dropZone();
c.restPriority = 10 + i;
c.priority = 10 + i; c.priority = 10 + i;
_moveTo(c, target); _moveTo(c, target);
} }