Skip to content

Commit b40078a

Browse files
committed
Reset card position in disableHoverEffect and always set baseX/baseY
1 parent ee295a8 commit b40078a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

playing-cards-2-planes/Card.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ export class Card extends Container {
198198
disableHoverEffect() {
199199
this.off('pointerenter');
200200
this.off('pointerleave');
201+
// Reset position to base values
202+
this.x = this.baseX;
203+
this.y = this.baseY;
204+
// Reset hit area to default
205+
this.hitArea = new Rectangle(-CARD_WIDTH / 2, -CARD_HEIGHT / 2, CARD_WIDTH, CARD_HEIGHT);
201206
}
202207

203208
/**

playing-cards-2-planes/Hand.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class Hand extends CardContainer {
4040
const card = cards[0];
4141
card.x = this._screen.width / 2;
4242
card.y = this._screen.height - CARD_VISIBLE_RATIO * CARD_HEIGHT;
43+
card.baseX = card.x;
4344
card.baseY = card.y;
4445
card.angle = 0;
4546
return;
@@ -66,6 +67,7 @@ export class Hand extends CardContainer {
6667
cards.forEach((card, index) => {
6768
card.x = firstCardX + index * spacingBetweenCards + card.jitterX;
6869
card.y = this._screen.height - CARD_VISIBLE_RATIO * CARD_HEIGHT + card.jitterY;
70+
card.baseX = card.x;
6971
card.baseY = card.y;
7072
// Apply tilt: 0 degrees at middle, increasing by 1 degree per card away from center
7173
card.angle = (index - middleIndex) * 1;

playing-cards-2-planes/Table.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ export class Table extends Container {
153153
const qb = this._getQuadrantBounds(i);
154154
card.x = Math.min(Math.max(card.x, qb.minX), qb.maxX);
155155
card.y = Math.min(Math.max(card.y, qb.minY), qb.maxY);
156+
card.baseX = card.x;
157+
card.baseY = card.y;
156158
}
157159
}
158160
}
@@ -189,6 +191,8 @@ export class Table extends Container {
189191
const angle = baseAngle + jitter;
190192

191193
const card = new Card(spriteSheet, textureKey, clickHandler, x, y, angle);
194+
card.baseX = x;
195+
card.baseY = y;
192196
this.addChild(card);
193197

194198
// Mark quadrant as occupied

0 commit comments

Comments
 (0)