Skip to content

Commit 065c5e4

Browse files
authored
Animation fixes for custom portrait scenes (#818)
* consider scale when tweening via Anima * consider tweening for custom portrait scenes * do not override custom modulate colour but only use alpha * do not reset custom node scale when mirroring
1 parent 682b0d4 commit 065c5e4

File tree

17 files changed

+107
-75
lines changed

17 files changed

+107
-75
lines changed

addons/dialogic/Nodes/Anima/DialogicAnimaPropertiesHelper.gd

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,22 @@ static func get_position(node: Node) -> Vector2:
2929
static func get_size(node: Node) -> Vector2:
3030
if node is Control:
3131
return node.get_size()
32-
elif node is Node2D:
33-
return node.texture.get_size() * node.scale
32+
elif node is AnimatedSprite:
33+
var frames = (node as AnimatedSprite).frames
34+
var animation = (node as AnimatedSprite).animation
35+
# scale can be negative
36+
var scale = Vector2(abs(node.scale.x), abs(node.scale.y))
37+
return frames.get_frame(animation, 0).get_size() * scale
38+
elif node is Node2D and "texture" in node:
39+
# scale can be negative
40+
var scale = Vector2(abs(node.scale.x), abs(node.scale.y))
41+
return node.texture.get_size() * scale
3442

3543
return Vector2.ZERO
3644

3745
static func get_scale(node: Node) -> Vector2:
3846
if node is Control:
3947
return node.rect_scale
40-
4148
return node.scale
4249

4350
static func get_rotation(node: Node):

addons/dialogic/Nodes/Anima/animations/attention_seeker/bounce.gd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
1313
]
1414

1515
var scale_frames = [
16-
{ percentage = 0, to = 1 },
17-
{ percentage = 20, to = 1 },
18-
{ percentage = 40, to = 1.1, easing_points = [0.7555, 0.5, 0.8555, 0.06] },
19-
{ percentage = 43, to = 1.1, easing_points = [0.7555, 0.5, 0.8555, 0.06] },
20-
{ percentage = 53, to = 1 },
21-
{ percentage = 70, to = 1.05, easing_points = [0.755, 0.05, 0.855, 0.06] },
22-
{ percentage = 80, to = 0.95 },
23-
{ percentage = 90, to = 1.02 },
24-
{ percentage = 100, to = 1 },
16+
{ percentage = 0, to = 1 * data.node.scale.y },
17+
{ percentage = 20, to = 1 * data.node.scale.y },
18+
{ percentage = 40, to = 1.1 * data.node.scale.y, easing_points = [0.7555, 0.5, 0.8555, 0.06] },
19+
{ percentage = 43, to = 1.1 * data.node.scale.y, easing_points = [0.7555, 0.5, 0.8555, 0.06] },
20+
{ percentage = 53, to = 1 * data.node.scale.y },
21+
{ percentage = 70, to = 1.05 * data.node.scale.y, easing_points = [0.755, 0.05, 0.855, 0.06] },
22+
{ percentage = 80, to = 0.95 * data.node.scale.y },
23+
{ percentage = 90, to = 1.02 * data.node.scale.y },
24+
{ percentage = 100, to = 1 * data.node.scale.y },
2525
]
2626

2727
anima_tween.add_relative_frames(data, "Y", bounce_frames)

addons/dialogic/Nodes/Anima/animations/attention_seeker/heartbeat.gd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
22
var frames = [
3-
{ percentage = 0, from = Vector2(1, 1) },
4-
{ percentage = 14, to = Vector2(1.3, 1.3) },
5-
{ percentage = 28, to = Vector2(1, 1) },
6-
{ percentage = 42, to = Vector2(1.3, 1.3) },
7-
{ percentage = 70, to = Vector2(1, 1) },
8-
{ percentage = 100, to = Vector2(1, 1) },
3+
{ percentage = 0, from = data.node.scale * Vector2(1, 1) },
4+
{ percentage = 14, to = data.node.scale * Vector2(1.3, 1.3) },
5+
{ percentage = 28, to = data.node.scale * Vector2(1, 1) },
6+
{ percentage = 42, to = data.node.scale * Vector2(1.3, 1.3) },
7+
{ percentage = 70, to = data.node.scale * Vector2(1, 1) },
8+
{ percentage = 100, to = data.node.scale * Vector2(1, 1) },
99
]
1010

1111
DialogicAnimaPropertiesHelper.set_2D_pivot(data.node, DialogicAnimaPropertiesHelper.PIVOT.CENTER)

addons/dialogic/Nodes/Anima/animations/attention_seeker/pulse.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
22
var frames = [
3-
{ percentage = 0, from = Vector2(1, 1) },
4-
{ percentage = 50, to = Vector2(1.05, 1.05), easing = anima_tween.EASING.EASE_IN_OUT_SINE },
5-
{ percentage = 100, to = Vector2(1, 1) },
3+
{ percentage = 0, from = data.node.scale * Vector2(1, 1) },
4+
{ percentage = 50, to = data.node.scale * Vector2(1.05, 1.05), easing = anima_tween.EASING.EASE_IN_OUT_SINE },
5+
{ percentage = 100, to = data.node.scale * Vector2(1, 1) },
66
]
77

88
DialogicAnimaPropertiesHelper.set_2D_pivot(data.node, DialogicAnimaPropertiesHelper.PIVOT.CENTER)

addons/dialogic/Nodes/Anima/animations/attention_seeker/rubber_band.gd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
22
var frames = [
3-
{ percentage = 0, from = Vector2(1, 1) },
4-
{ percentage = 30, to = Vector2(1.25, 0.75) },
5-
{ percentage = 40, to = Vector2(0.75, 1.25) },
6-
{ percentage = 50, to = Vector2(1.15, 0.85) },
7-
{ percentage = 65, to = Vector2(0.95, 1.05) },
8-
{ percentage = 75, to = Vector2(1.05, 0.95) },
9-
{ percentage = 100, to = Vector2(1, 1) },
3+
{ percentage = 0, from = data.node.scale * Vector2(1, 1) },
4+
{ percentage = 30, to = data.node.scale * Vector2(1.25, 0.75) },
5+
{ percentage = 40, to = data.node.scale * Vector2(0.75, 1.25) },
6+
{ percentage = 50, to = data.node.scale * Vector2(1.15, 0.85) },
7+
{ percentage = 65, to = data.node.scale * Vector2(0.95, 1.05) },
8+
{ percentage = 75, to = data.node.scale * Vector2(1.05, 0.95) },
9+
{ percentage = 100, to = data.node.scale * Vector2(1, 1) },
1010
]
1111

1212
DialogicAnimaPropertiesHelper.set_2D_pivot(data.node, DialogicAnimaPropertiesHelper.PIVOT.CENTER)

addons/dialogic/Nodes/Anima/animations/attention_seeker/tada.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
33
{ percentage = 0, from = 0 },
44
]
55
var scale_frames = [
6-
{ percentage = 0, from = Vector2(1, 1) },
6+
{ percentage = 0, from = data.node.scale * Vector2(1, 1) },
77
]
88

99
for index in range(2, 9):

addons/dialogic/Nodes/Anima/animations/entrances_and_exits/back_in_down.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
66
]
77

88
var scale_frames = [
9-
{ percentage = 0, from = Vector2(0.7, 0.7) },
10-
{ percentage = 80, to = Vector2(0.7, 0.7) },
11-
{ percentage = 100, to = Vector2(1, 1) },
9+
{ percentage = 0, from = data.node.scale * Vector2(0.7, 0.7) },
10+
{ percentage = 80, to = data.node.scale * Vector2(0.7, 0.7) },
11+
{ percentage = 100, to = data.node.scale * Vector2(1, 1) },
1212
]
1313

1414
var opacity_frames = [

addons/dialogic/Nodes/Anima/animations/entrances_and_exits/back_in_left.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
66
]
77

88
var scale_frames = [
9-
{ percentage = 0, from = Vector2(0.7, 0.7) },
10-
{ percentage = 80, to = Vector2(0.7, 0.7) },
11-
{ percentage = 100, to = Vector2(1, 1) },
9+
{ percentage = 0, from = data.node.scale * Vector2(0.7, 0.7) },
10+
{ percentage = 80, to = data.node.scale * Vector2(0.7, 0.7) },
11+
{ percentage = 100, to = data.node.scale * Vector2(1, 1) },
1212
]
1313

1414
var opacity_frames = [

addons/dialogic/Nodes/Anima/animations/entrances_and_exits/back_in_right.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
66
]
77

88
var scale_frames = [
9-
{ percentage = 0, from = Vector2(0.7, 0.7) },
10-
{ percentage = 80, to = Vector2(0.7, 0.7) },
11-
{ percentage = 100, to = Vector2(1, 1) },
9+
{ percentage = 0, from = data.node.scale * Vector2(0.7, 0.7) },
10+
{ percentage = 80, to = data.node.scale * Vector2(0.7, 0.7) },
11+
{ percentage = 100, to = data.node.scale * Vector2(1, 1) },
1212
]
1313

1414
var opacity_frames = [

addons/dialogic/Nodes/Anima/animations/entrances_and_exits/back_in_up.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ func generate_animation(anima_tween: Tween, data: Dictionary) -> void:
66
]
77

88
var scale_frames = [
9-
{ percentage = 0, from = Vector2(0.7, 0.7) },
10-
{ percentage = 80, to = Vector2(0.7, 0.7) },
11-
{ percentage = 100, to = Vector2(1, 1) },
9+
{ percentage = 0, from = data.node.scale * Vector2(0.7, 0.7) },
10+
{ percentage = 80, to = data.node.scale * Vector2(0.7, 0.7) },
11+
{ percentage = 100, to = data.node.scale * Vector2(1, 1) },
1212
]
1313

1414
var opacity_frames = [

0 commit comments

Comments
 (0)