Skip to content

Commit b76ba01

Browse files
authored
[Community] [Top-down animator] Update the animation at object creation (#1635)
- Don't show in changelog
1 parent c3e46f5 commit b76ba01

File tree

1 file changed

+133
-108
lines changed

1 file changed

+133
-108
lines changed

extensions/community/TopDownMovementAnimator.json

Lines changed: 133 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "TopDownMovementAnimator",
1010
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Glyphster Pack/Master/SVG/Arrows/a6026156355ae5f03613b03971e4ddb50d0c95b8901e7a21edc57f33f0032e42_Arrows_thin_arrows_all_directions_cross.svg",
1111
"shortDescription": "Change the animation according to the movement direction.",
12-
"version": "0.2.2",
12+
"version": "0.2.3",
1313
"description": "Change the animation according to the movement direction.",
1414
"origin": {
1515
"identifier": "TopDownMovementAnimator",
@@ -229,26 +229,16 @@
229229
"events": [
230230
{
231231
"type": "BuiltinCommonInstructions::Standard",
232-
"conditions": [
233-
{
234-
"type": {
235-
"value": "BooleanVariable"
236-
},
237-
"parameters": [
238-
"IsPausingAnimation",
239-
"True",
240-
""
241-
]
242-
}
243-
],
232+
"conditions": [],
244233
"actions": [
245234
{
246235
"type": {
247-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationPause"
236+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationDirection"
248237
},
249238
"parameters": [
250239
"Object",
251240
"Behavior",
241+
"NewAnimationDirection",
252242
""
253243
]
254244
}
@@ -271,7 +261,7 @@
271261
"actions": [
272262
{
273263
"type": {
274-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale"
264+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationSpeedScale"
275265
},
276266
"parameters": [
277267
"Object",
@@ -283,68 +273,29 @@
283273
},
284274
{
285275
"type": "BuiltinCommonInstructions::Standard",
286-
"conditions": [],
287-
"actions": [
276+
"conditions": [
288277
{
289278
"type": {
290-
"value": "SetNumberVariable"
279+
"value": "BooleanVariable"
291280
},
292281
"parameters": [
293-
"NewAnimationDirection",
294-
"=",
295-
"Object.Behavior::Direction()"
282+
"IsPausingAnimation",
283+
"True",
284+
""
296285
]
297286
}
298287
],
299-
"events": [
288+
"actions": [
300289
{
301-
"type": "BuiltinCommonInstructions::Comment",
302-
"color": {
303-
"b": 109,
304-
"g": 230,
305-
"r": 255,
306-
"textB": 0,
307-
"textG": 0,
308-
"textR": 0
290+
"type": {
291+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationPause"
309292
},
310-
"comment": "Use a small margin is used to avoid to flicker between 2 directions."
311-
},
312-
{
313-
"type": "BuiltinCommonInstructions::Standard",
314-
"conditions": [
315-
{
316-
"type": {
317-
"value": "BuiltinCommonInstructions::CompareNumbers"
318-
},
319-
"parameters": [
320-
"abs(Object.Behavior::DirectionDifference(NewAnimationDirection, AnimationDirection))",
321-
">",
322-
"0.5 + 0.03125"
323-
]
324-
}
325-
],
326-
"actions": [
327-
{
328-
"type": {
329-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationDirection"
330-
},
331-
"parameters": [
332-
"Object",
333-
"Behavior",
334-
"NewAnimationDirection",
335-
""
336-
]
337-
}
293+
"parameters": [
294+
"Object",
295+
"Behavior",
296+
""
338297
]
339298
}
340-
],
341-
"variables": [
342-
{
343-
"folded": true,
344-
"name": "NewAnimationDirection",
345-
"type": "number",
346-
"value": 0
347-
}
348299
]
349300
}
350301
],
@@ -410,6 +361,18 @@
410361
"name": "SetAnimationName",
411362
"sentence": "",
412363
"events": [
364+
{
365+
"type": "BuiltinCommonInstructions::Comment",
366+
"color": {
367+
"b": 109,
368+
"g": 230,
369+
"r": 255,
370+
"textB": 0,
371+
"textG": 0,
372+
"textR": 0
373+
},
374+
"comment": "Also update the animation direction to avoid to play the animation in an old direction for 1 frame."
375+
},
413376
{
414377
"type": "BuiltinCommonInstructions::Standard",
415378
"conditions": [
@@ -444,6 +407,17 @@
444407
"Behavior",
445408
""
446409
]
410+
},
411+
{
412+
"type": {
413+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationDirection"
414+
},
415+
"parameters": [
416+
"Object",
417+
"Behavior",
418+
"NewAnimationDirection",
419+
""
420+
]
447421
}
448422
]
449423
}
@@ -581,7 +555,7 @@
581555
},
582556
{
583557
"type": {
584-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationPause"
558+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationPause"
585559
},
586560
"parameters": [
587561
"Object",
@@ -735,7 +709,7 @@
735709
},
736710
{
737711
"type": {
738-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale"
712+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationSpeedScale"
739713
},
740714
"parameters": [
741715
"Object",
@@ -772,7 +746,7 @@
772746
"description": "Change the animation speed scale according to the object speed.",
773747
"fullName": "Animation speed scale",
774748
"functionType": "Action",
775-
"name": "SetAnimationSpeedScale",
749+
"name": "UpdateAnimationSpeedScale",
776750
"private": true,
777751
"sentence": "Change the animation speed scale according to _PARAM0_ speed",
778752
"events": [
@@ -854,7 +828,7 @@
854828
"description": "Pause the animation according to the object speed.",
855829
"fullName": "Animation pause",
856830
"functionType": "Action",
857-
"name": "SetAnimationPause",
831+
"name": "UpdateAnimationPause",
858832
"private": true,
859833
"sentence": "Pause the animation according to _PARAM0_ speed",
860834
"events": [
@@ -1021,12 +995,12 @@
1021995
"objectGroups": []
1022996
},
1023997
{
1024-
"description": "Change the animation direction of the object.",
1025-
"fullName": "Animation name and direction",
998+
"description": "Update the animation direction of the object.",
999+
"fullName": "Update animation direction",
10261000
"functionType": "Action",
1027-
"name": "SetAnimationDirection",
1001+
"name": "UpdateAnimationDirection",
10281002
"private": true,
1029-
"sentence": "Change the animation direction of _PARAM0_ to _PARAM2_",
1003+
"sentence": "Update the animation direction of _PARAM0_",
10301004
"events": [
10311005
{
10321006
"type": "BuiltinCommonInstructions::Comment",
@@ -1049,47 +1023,103 @@
10491023
"value": "SetNumberVariable"
10501024
},
10511025
"parameters": [
1052-
"AnimationDirection",
1053-
"=",
1054-
"mod(mod(round(NewDirection), DirectionCount) + DirectionCount, DirectionCount)"
1055-
]
1056-
},
1057-
{
1058-
"type": {
1059-
"value": "SetNumberVariable"
1060-
},
1061-
"parameters": [
1062-
"AnimationElapsedTime",
1026+
"NewAnimationDirection",
10631027
"=",
1064-
"Object.Animation::ElapsedTime()"
1028+
"Object.Behavior::Direction()"
10651029
]
1066-
},
1030+
}
1031+
],
1032+
"events": [
10671033
{
1068-
"type": {
1069-
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationName"
1034+
"type": "BuiltinCommonInstructions::Comment",
1035+
"color": {
1036+
"b": 109,
1037+
"g": 230,
1038+
"r": 255,
1039+
"textB": 0,
1040+
"textG": 0,
1041+
"textR": 0
10701042
},
1071-
"parameters": [
1072-
"Object",
1073-
"Behavior",
1074-
""
1075-
]
1043+
"comment": "Use a small margin is used to avoid to flicker between 2 directions."
10761044
},
10771045
{
1078-
"type": {
1079-
"value": "AnimatableCapability::AnimatableBehavior::SetElapsedTime"
1080-
},
1081-
"parameters": [
1082-
"Object",
1083-
"Animation",
1084-
"=",
1085-
"AnimationElapsedTime"
1046+
"type": "BuiltinCommonInstructions::Standard",
1047+
"conditions": [
1048+
{
1049+
"type": {
1050+
"value": "BuiltinCommonInstructions::CompareNumbers"
1051+
},
1052+
"parameters": [
1053+
"abs(Object.Behavior::DirectionDifference(NewAnimationDirection, AnimationDirection))",
1054+
">",
1055+
"0.5 + 0.03125"
1056+
]
1057+
}
1058+
],
1059+
"actions": [],
1060+
"events": [
1061+
{
1062+
"type": "BuiltinCommonInstructions::Standard",
1063+
"conditions": [],
1064+
"actions": [
1065+
{
1066+
"type": {
1067+
"value": "SetNumberVariable"
1068+
},
1069+
"parameters": [
1070+
"AnimationDirection",
1071+
"=",
1072+
"mod(mod(round(NewAnimationDirection), DirectionCount) + DirectionCount, DirectionCount)"
1073+
]
1074+
},
1075+
{
1076+
"type": {
1077+
"value": "SetNumberVariable"
1078+
},
1079+
"parameters": [
1080+
"AnimationElapsedTime",
1081+
"=",
1082+
"Object.Animation::ElapsedTime()"
1083+
]
1084+
},
1085+
{
1086+
"type": {
1087+
"value": "TopDownMovementAnimator::TopDownMovementAnimator::UpdateAnimationName"
1088+
},
1089+
"parameters": [
1090+
"Object",
1091+
"Behavior",
1092+
""
1093+
]
1094+
},
1095+
{
1096+
"type": {
1097+
"value": "AnimatableCapability::AnimatableBehavior::SetElapsedTime"
1098+
},
1099+
"parameters": [
1100+
"Object",
1101+
"Animation",
1102+
"=",
1103+
"AnimationElapsedTime"
1104+
]
1105+
}
1106+
],
1107+
"variables": [
1108+
{
1109+
"folded": true,
1110+
"name": "AnimationElapsedTime",
1111+
"type": "number",
1112+
"value": 0
1113+
}
1114+
]
1115+
}
10861116
]
10871117
}
10881118
],
10891119
"variables": [
10901120
{
10911121
"folded": true,
1092-
"name": "AnimationElapsedTime",
1122+
"name": "NewAnimationDirection",
10931123
"type": "number",
10941124
"value": 0
10951125
}
@@ -1107,11 +1137,6 @@
11071137
"name": "Behavior",
11081138
"supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator",
11091139
"type": "behavior"
1110-
},
1111-
{
1112-
"description": "Direction",
1113-
"name": "NewDirection",
1114-
"type": "expression"
11151140
}
11161141
],
11171142
"objectGroups": []

0 commit comments

Comments
 (0)