Skip to content

Commit 9287085

Browse files
idbriimenaechmi
authored andcommitted
Use get_ref before accessing card tweens (#4)
CardTemplate's _tween is a WeakRef and not a Tween. Also resets the project.godot to the compat renderer
1 parent dcbc810 commit 9287085

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

project.godot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ screenshot_card={
4949

5050
[rendering]
5151

52+
renderer/rendering_method="gl_compatibility"
5253
environment/defaults/default_environment="res://default_env.tres"

src/core/CardTemplate.gd

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,15 +1998,14 @@ func _organize_attachments() -> void:
19981998

19991999
# We don't want to try and move it if it's still tweening.
20002000
# But if it isn't, we make sure it always follows its parent is_running()
2001-
if not (card._tween.is_running()) and \
2002-
card.state in \
2003-
[CardState.ON_PLAY_BOARD,CardState.FOCUSED_ON_BOARD]:
2004-
card.global_position = global_position + \
2005-
Vector2(
2006-
(attach_index + 1) * card_size.x
2007-
* CFConst.ATTACHMENT_OFFSET[attachment_offset].x,
2008-
(attach_index + 1) * card_size.y \
2009-
* CFConst.ATTACHMENT_OFFSET[attachment_offset].y)
2001+
var tween = card._tween.get_ref() as Tween
2002+
if (not (tween and tween.is_running())
2003+
and card.state in [CardState.ON_PLAY_BOARD,CardState.FOCUSED_ON_BOARD]
2004+
):
2005+
card.global_position = (global_position +
2006+
Vector2(
2007+
(attach_index + 1) * card_size.x * CFConst.ATTACHMENT_OFFSET[attachment_offset].x,
2008+
(attach_index + 1) * card_size.y * CFConst.ATTACHMENT_OFFSET[attachment_offset].y))
20102009

20112010
# Returns the global mouse position but ensures it does not exit the
20122011
# viewport limits when including the card rect

src/custom/CGFBoard.gd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ func reshuffle_all_in_pile(pile: Pile = cfc.NMAP.deck):
5959
await get_tree().create_timer(0.1).timeout
6060
# Last card in, is the top card of the pile
6161
var last_card : Card = pile.get_top_card()
62-
if last_card._tween and last_card._tween.is_running():
63-
await last_card._tween.finished
62+
var tween = last_card._tween.get_ref() as Tween
63+
if tween.is_running():
64+
await tween.finished
6465
await get_tree().create_timer(0.2).timeout
6566
pile.shuffle_cards()
6667

0 commit comments

Comments
 (0)