From 71b262889e38973666d0b79e570accbd9fe3e2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sat, 11 Mar 2023 18:21:42 +0100 Subject: [PATCH 1/8] [Top-down movement animator] Change the animation according to the movement direction --- .../reviewed/TopDownMovementAnimator.json | 604 ++++++++++++++++++ 1 file changed, 604 insertions(+) create mode 100644 extensions/reviewed/TopDownMovementAnimator.json diff --git a/extensions/reviewed/TopDownMovementAnimator.json b/extensions/reviewed/TopDownMovementAnimator.json new file mode 100644 index 000000000..49c7779a6 --- /dev/null +++ b/extensions/reviewed/TopDownMovementAnimator.json @@ -0,0 +1,604 @@ +{ + "author": "", + "category": "Movement", + "extensionNamespace": "", + "fullName": "Top-down movement animator", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8Zz4NCgk8cGF0aCBkPSJNNiwyMS4xYy0wLjMsMC0wLjUtMC4xLTAuNy0wLjNsLTQtNC4xYy0wLjQtMC40LTAuNC0xLDAtMS40bDQtNC4xYzAuNC0wLjQsMS0wLjQsMS40LDBzMC40LDEsMCwxLjRMMy40LDE2bDMuMywzLjMNCgkJYzAuNCwwLjQsMC40LDEsMCwxLjRDNi42LDIxLDYuMywyMS4xLDYsMjEuMXoiLz4NCjwvZz4NCjxnPg0KCTxwYXRoIGQ9Ik0yNiwyMS4xYy0wLjMsMC0wLjUtMC4xLTAuNy0wLjNjLTAuNC0wLjQtMC40LTEsMC0xLjRsMy4zLTMuM2wtMy4zLTMuM2MtMC40LTAuNC0wLjQtMSwwLTEuNHMxLTAuNCwxLjQsMGw0LjEsNC4xDQoJCWMwLjIsMC4yLDAuMywwLjQsMC4zLDAuN3MtMC4xLDAuNS0wLjMsMC43bC00LjEsNC4xQzI2LjYsMjEsMjYuMywyMS4xLDI2LDIxLjF6Ii8+DQo8L2c+DQo8Zz4NCgk8cGF0aCBkPSJNMTYsMzEuMUwxNiwzMS4xYy0wLjMsMC0wLjUtMC4xLTAuNy0wLjNsLTQtNC4xYy0wLjQtMC40LTAuNC0xLDAtMS40czEtMC40LDEuNCwwbDMuMywzLjNsMy4zLTMuM2MwLjQtMC40LDEtMC40LDEuNCwwDQoJCXMwLjQsMSwwLDEuNGwtNC4xLDQuMUMxNi42LDMwLjksMTYuMywzMS4xLDE2LDMxLjF6Ii8+DQo8L2c+DQo8Zz4NCgk8cGF0aCBkPSJNMjAuMSw3Yy0wLjMsMC0wLjUtMC4xLTAuNy0wLjNMMTYsMy40bC0zLjMsMy4zYy0wLjQsMC40LTEsMC40LTEuNCwwcy0wLjQtMSwwLTEuNGw0LTQuMWMwLjQtMC40LDEtMC40LDEuNCwwbDQuMSw0LjENCgkJYzAuNCwwLjQsMC40LDEsMCwxLjRDMjAuNiw2LjksMjAuNCw3LDIwLjEsN3oiLz4NCjwvZz4NCjxnPg0KCTxwYXRoIGQ9Ik0xNiwzMGMtMC42LDAtMS0wLjQtMS0xVjNjMC0wLjYsMC40LTEsMS0xczEsMC40LDEsMXYyNkMxNywyOS42LDE2LjYsMzAsMTYsMzB6Ii8+DQo8L2c+DQo8Zz4NCgk8cGF0aCBkPSJNMjksMTdIMmMtMC42LDAtMS0wLjQtMS0xczAuNC0xLDEtMWgyN2MwLjYsMCwxLDAuNCwxLDFTMjkuNiwxNywyOSwxN3oiLz4NCjwvZz4NCjwvc3ZnPg0K", + "name": "TopDownMovementAnimator", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Glyphster Pack/Master/SVG/Arrows/a6026156355ae5f03613b03971e4ddb50d0c95b8901e7a21edc57f33f0032e42_Arrows_thin_arrows_all_directions_cross.svg", + "shortDescription": "Change the animation according to the movement direction.", + "version": "0.1.0", + "description": "Change the animation according to the movement direction.", + "tags": [ + "animation", + "direction" + ], + "authorIds": [ + "IWykYNRvhCZBN3vEgKEbBPOR3Oc2" + ], + "dependencies": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [ + { + "description": "Change the animation according to the movement direction.", + "fullName": "Top-down movement animator", + "name": "TopDownMovementAnimator", + "objectType": "Sprite", + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::PropertyDirectionCount" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "0" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "TopDownMovementBehavior::DiagonalsAllowed" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyDirectionCount" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "8" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "TopDownMovementBehavior::DiagonalsAllowed" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyDirectionCount" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "4" + ] + } + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "TopDownMovementBehavior::Speed" + }, + "parameters": [ + "Object", + "TopDownMovement", + "=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "PauseAnimation" + }, + "parameters": [ + "Object" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::PropertyIsScalingAnimation" + }, + "parameters": [ + "Object", + "Behavior" + ] + }, + { + "type": { + "value": "TopDownMovementBehavior::Speed" + }, + "parameters": [ + "Object", + "TopDownMovement", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeAnimationSpeedScale" + }, + "parameters": [ + "Object", + "=", + "Object.TopDownMovement::Speed() / Object.TopDownMovement::MaxSpeed()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationDirectionName" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "Object. Behavior::PropertyAnimationName() + ToString(mod(round((Object.TopDownMovement::Angle() + Object.Behavior::PropertyAngleOffset()) * Object.Behavior::PropertyDirectionCount() / 360), Object.Behavior::PropertyDirectionCount()))" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Change the animation but keep the current frame number.", + "comment2": "" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "AnimationName" + }, + "parameters": [ + "Object", + "Object.Behavior::PropertyAnimationDirectionName()" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationFrame" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "Object.Sprite()" + ] + }, + { + "type": { + "value": "SetAnimationName" + }, + "parameters": [ + "Object", + "Object.Behavior::PropertyAnimationDirectionName()" + ] + }, + { + "type": { + "value": "ChangeSprite" + }, + "parameters": [ + "Object", + "=", + "Object.Behavior::PropertyAnimationFrame()" + ] + } + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "the animation name of the object.", + "fullName": "Animation name", + "functionType": "ExpressionAndCondition", + "name": "AnimationName", + "sentence": "the animation name", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnString" + }, + "parameters": [ + "Object.Behavior::PropertyAnimationName()" + ] + } + ] + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "getterName": "AnimationName", + "name": "SetAnimationName", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationName" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "GetArgumentAsString(\"Value\")" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Check if the animation is scaled according to speed.", + "fullName": "Scale animation according to speed", + "functionType": "Condition", + "name": "IsScalingAnimation", + "sentence": "_PARAM0_ animation is scaled according to speed", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::PropertyIsScalingAnimation" + }, + "parameters": [ + "Object", + "Behavior" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Change whether the animation is scaled according to speed or not.", + "fullName": "Scale animation according to speed", + "functionType": "Action", + "name": "SetIsScalingAnimation", + "sentence": "Scale the animation of _PARAM0_ according to speed: _PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"Value\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyIsScalingAnimation" + }, + "parameters": [ + "Object", + "Behavior", + "no" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"Value\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyIsScalingAnimation" + }, + "parameters": [ + "Object", + "Behavior", + "yes" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + }, + { + "defaultValue": "yes", + "description": "IsScalingAnimation", + "name": "Value", + "optional": true, + "type": "yesorno" + } + ], + "objectGroups": [] + } + ], + "propertyDescriptors": [ + { + "value": "", + "type": "Behavior", + "label": "Top-down movement", + "description": "", + "group": "", + "extraInformation": [ + "TopDownMovementBehavior::TopDownMovementBehavior" + ], + "hidden": false, + "name": "TopDownMovement" + }, + { + "value": "0", + "type": "Number", + "label": "", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "PreviousVelocityX" + }, + { + "value": "0", + "type": "Number", + "label": "", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "PreviousVelocityY" + }, + { + "value": "true", + "type": "Boolean", + "label": "Scale animation according to speed", + "description": "", + "group": "Animation", + "extraInformation": [], + "hidden": false, + "name": "IsScalingAnimation" + }, + { + "value": "Walk", + "type": "String", + "label": "Animation name", + "description": "Animations must be called \"Walk0\", \"Walk1\"... for left, down...", + "group": "Animation", + "extraInformation": [], + "hidden": false, + "name": "AnimationName" + }, + { + "value": "0", + "type": "Number", + "unit": "Dimensionless", + "label": "Number of directions", + "description": "Leave to 0 to automatically use 8 when diagonals are allowed and 4 otherwise.", + "group": "Direction", + "extraInformation": [], + "hidden": false, + "name": "DirectionCount" + }, + { + "value": "", + "type": "Number", + "label": "", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "AnimationFrame" + }, + { + "value": "", + "type": "String", + "label": "", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "AnimationDirectionName" + }, + { + "value": "0", + "type": "Number", + "unit": "DegreeAngle", + "label": "Angle offset", + "description": "Setted to 90°, \"Walk0\" becomes the animation for down.", + "group": "Direction", + "extraInformation": [], + "hidden": false, + "name": "AngleOffset" + } + ], + "sharedPropertyDescriptors": [] + } + ], + "eventsBasedObjects": [] +} \ No newline at end of file From 4b3bcf94c0c24a0066e14899f680f05411a85105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sun, 12 Mar 2023 01:10:46 +0100 Subject: [PATCH 2/8] Fix configuration changes. --- .../reviewed/TopDownMovementAnimator.json | 178 +++++++++++++----- 1 file changed, 131 insertions(+), 47 deletions(-) diff --git a/extensions/reviewed/TopDownMovementAnimator.json b/extensions/reviewed/TopDownMovementAnimator.json index 49c7779a6..f963f8996 100644 --- a/extensions/reviewed/TopDownMovementAnimator.json +++ b/extensions/reviewed/TopDownMovementAnimator.json @@ -182,12 +182,12 @@ "actions": [ { "type": { - "value": "ChangeAnimationSpeedScale" + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale" }, "parameters": [ "Object", - "=", - "Object.TopDownMovement::Speed() / Object.TopDownMovement::MaxSpeed()" + "Behavior", + "" ] } ] @@ -198,13 +198,13 @@ "actions": [ { "type": { - "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationDirectionName" + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetSharedPropertyNewAnimationDirection" }, "parameters": [ "Object", "Behavior", "=", - "Object. Behavior::PropertyAnimationName() + ToString(mod(round((Object.TopDownMovement::Angle() + Object.Behavior::PropertyAngleOffset()) * Object.Behavior::PropertyDirectionCount() / 360), Object.Behavior::PropertyDirectionCount()))" + "mod((Object.TopDownMovement::Angle() + Object.Behavior::PropertyAngleOffset()) * Object.Behavior::PropertyDirectionCount() / 360, Object.Behavior::PropertyDirectionCount())" ] } ], @@ -219,7 +219,7 @@ "textG": 0, "textR": 0 }, - "comment": "Change the animation but keep the current frame number.", + "comment": "Change the animation but keep the current frame number.\nA small margin is used to avoid to flicker between 2 directions.", "comment2": "" }, { @@ -228,18 +228,30 @@ { "type": { "inverted": true, - "value": "AnimationName" + "value": "BuiltinCommonInstructions::CompareNumbers" }, "parameters": [ - "Object", - "Object.Behavior::PropertyAnimationDirectionName()" + "abs(mod(Object.Behavior::SharedPropertyNewAnimationDirection() - Object.Behavior::PropertyAnimationDirection(), Object.Behavior::PropertyDirectionCount()))", + ">", + "0.5 + 0.0625" ] } ], "actions": [ { "type": { - "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationFrame" + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationDirection" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "round(Object.Behavior::SharedPropertyNewAnimationDirection())" + ] + }, + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetSharedPropertyAnimationFrame" }, "parameters": [ "Object", @@ -254,7 +266,7 @@ }, "parameters": [ "Object", - "Object.Behavior::PropertyAnimationDirectionName()" + "Object. Behavior::PropertyAnimationName() + ToString(Object.Behavior::PropertyAnimationDirection())" ] }, { @@ -264,7 +276,7 @@ "parameters": [ "Object", "=", - "Object.Behavior::PropertyAnimationFrame()" + "Object.Behavior::SharedPropertyAnimationFrame()" ] } ] @@ -338,7 +350,19 @@ "events": [ { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], + "conditions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::PropertyAnimationName" + }, + "parameters": [ + "Object", + "Behavior", + "!=", + "GetArgumentAsString(\"Value\")" + ] + } + ], "actions": [ { "type": { @@ -350,6 +374,15 @@ "=", "GetArgumentAsString(\"Value\")" ] + }, + { + "type": { + "value": "SetAnimationName" + }, + "parameters": [ + "Object", + "Object. Behavior::PropertyAnimationName() + ToString(Object.Behavior::PropertyAnimationDirection())" + ] } ] } @@ -448,6 +481,16 @@ "Behavior", "no" ] + }, + { + "type": { + "value": "ChangeAnimationSpeedScale" + }, + "parameters": [ + "Object", + "=", + "1" + ] } ] }, @@ -473,6 +516,16 @@ "Behavior", "yes" ] + }, + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale" + }, + "parameters": [ + "Object", + "Behavior", + "" + ] } ] } @@ -499,6 +552,46 @@ } ], "objectGroups": [] + }, + { + "description": "Change the animation speed scale according to the object speed.", + "fullName": "Animation speed scale", + "functionType": "Action", + "name": "SetAnimationSpeedScale", + "sentence": "Change the animation speed scale according to _PARAM0_ speed", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "ChangeAnimationSpeedScale" + }, + "parameters": [ + "Object", + "=", + "Object.TopDownMovement::Speed() / Object.TopDownMovement::MaxSpeed()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] } ], "propertyDescriptors": [ @@ -514,26 +607,6 @@ "hidden": false, "name": "TopDownMovement" }, - { - "value": "0", - "type": "Number", - "label": "", - "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "PreviousVelocityX" - }, - { - "value": "0", - "type": "Number", - "label": "", - "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "PreviousVelocityY" - }, { "value": "true", "type": "Boolean", @@ -566,38 +639,49 @@ "name": "DirectionCount" }, { - "value": "", + "value": "0", + "type": "Number", + "unit": "DegreeAngle", + "label": "Angle offset", + "description": "Setted to 90°, \"Walk0\" becomes the animation for down.", + "group": "Direction", + "extraInformation": [], + "hidden": false, + "name": "AngleOffset" + }, + { + "value": "0", "type": "Number", "label": "", "description": "", "group": "", "extraInformation": [], "hidden": true, - "name": "AnimationFrame" - }, + "name": "AnimationDirection" + } + ], + "sharedPropertyDescriptors": [ { - "value": "", - "type": "String", + "value": "0", + "type": "Number", "label": "", "description": "", "group": "", "extraInformation": [], "hidden": true, - "name": "AnimationDirectionName" + "name": "NewAnimationDirection" }, { "value": "0", "type": "Number", - "unit": "DegreeAngle", - "label": "Angle offset", - "description": "Setted to 90°, \"Walk0\" becomes the animation for down.", - "group": "Direction", + "label": "", + "description": "", + "group": "", "extraInformation": [], - "hidden": false, - "name": "AngleOffset" + "hidden": true, + "name": "AnimationFrame" } - ], - "sharedPropertyDescriptors": [] + ] } ], "eventsBasedObjects": [] From 9ae9ff28ce8ad35f31a5cce9e4f3cf0f9786a038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sun, 12 Mar 2023 01:37:46 +0100 Subject: [PATCH 3/8] Fix animation resume. --- .../reviewed/TopDownMovementAnimator.json | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/extensions/reviewed/TopDownMovementAnimator.json b/extensions/reviewed/TopDownMovementAnimator.json index f963f8996..54e8a27b8 100644 --- a/extensions/reviewed/TopDownMovementAnimator.json +++ b/extensions/reviewed/TopDownMovementAnimator.json @@ -158,15 +158,6 @@ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ - { - "type": { - "value": "TopDownMovementAnimator::TopDownMovementAnimator::PropertyIsScalingAnimation" - }, - "parameters": [ - "Object", - "Behavior" - ] - }, { "type": { "value": "TopDownMovementBehavior::Speed" @@ -182,12 +173,38 @@ "actions": [ { "type": { - "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale" + "value": "PlayAnimation" }, "parameters": [ - "Object", - "Behavior", - "" + "Object" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::PropertyIsScalingAnimation" + }, + "parameters": [ + "Object", + "Behavior" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationSpeedScale" + }, + "parameters": [ + "Object", + "Behavior", + "" + ] + } ] } ] From 5b43a751327291c15b8382d7ba9a03db1e192149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sun, 12 Mar 2023 02:27:24 +0100 Subject: [PATCH 4/8] Handle onActivate. --- .../reviewed/TopDownMovementAnimator.json | 281 +++++++++++++----- 1 file changed, 211 insertions(+), 70 deletions(-) diff --git a/extensions/reviewed/TopDownMovementAnimator.json b/extensions/reviewed/TopDownMovementAnimator.json index 54e8a27b8..4bdc35e18 100644 --- a/extensions/reviewed/TopDownMovementAnimator.json +++ b/extensions/reviewed/TopDownMovementAnimator.json @@ -123,6 +123,46 @@ ], "objectGroups": [] }, + { + "fullName": "", + "functionType": "Action", + "name": "onActivate", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationDirection" + }, + "parameters": [ + "Object", + "Behavior", + "Object.Behavior::Direction()", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] + }, { "fullName": "", "functionType": "Action", @@ -221,81 +261,49 @@ "Object", "Behavior", "=", - "mod((Object.TopDownMovement::Angle() + Object.Behavior::PropertyAngleOffset()) * Object.Behavior::PropertyDirectionCount() / 360, Object.Behavior::PropertyDirectionCount())" + "Object.Behavior::Direction()" ] } - ], - "events": [ + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Use a small margin is used to avoid to flicker between 2 directions.", + "comment2": "" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 + "type": { + "inverted": true, + "value": "BuiltinCommonInstructions::CompareNumbers" }, - "comment": "Change the animation but keep the current frame number.\nA small margin is used to avoid to flicker between 2 directions.", - "comment2": "" - }, + "parameters": [ + "abs(mod(Object.Behavior::SharedPropertyNewAnimationDirection() - Object.Behavior::PropertyAnimationDirection(), Object.Behavior::PropertyDirectionCount()))", + ">", + "0.5 + 0.0625" + ] + } + ], + "actions": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "BuiltinCommonInstructions::CompareNumbers" - }, - "parameters": [ - "abs(mod(Object.Behavior::SharedPropertyNewAnimationDirection() - Object.Behavior::PropertyAnimationDirection(), Object.Behavior::PropertyDirectionCount()))", - ">", - "0.5 + 0.0625" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationDirection" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "round(Object.Behavior::SharedPropertyNewAnimationDirection())" - ] - }, - { - "type": { - "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetSharedPropertyAnimationFrame" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Object.Sprite()" - ] - }, - { - "type": { - "value": "SetAnimationName" - }, - "parameters": [ - "Object", - "Object. Behavior::PropertyAnimationName() + ToString(Object.Behavior::PropertyAnimationDirection())" - ] - }, - { - "type": { - "value": "ChangeSprite" - }, - "parameters": [ - "Object", - "=", - "Object.Behavior::SharedPropertyAnimationFrame()" - ] - } + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetAnimationDirection" + }, + "parameters": [ + "Object", + "Behavior", + "Object.Behavior::SharedPropertyNewAnimationDirection()", + "" ] } ] @@ -575,6 +583,7 @@ "fullName": "Animation speed scale", "functionType": "Action", "name": "SetAnimationSpeedScale", + "private": true, "sentence": "Change the animation speed scale according to _PARAM0_ speed", "events": [ { @@ -609,6 +618,138 @@ } ], "objectGroups": [] + }, + { + "description": "Return the object movement direction.", + "fullName": "Direction", + "functionType": "Expression", + "name": "Direction", + "private": true, + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "mod((Object.TopDownMovement::Angle() + Object.Behavior::PropertyAngleOffset()) * Object.Behavior::PropertyDirectionCount() / 360, Object.Behavior::PropertyDirectionCount())" + ] + } + ] + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + } + ], + "objectGroups": [] + }, + { + "description": "Change the animation direction of the object.", + "fullName": "Animation direction", + "functionType": "Action", + "name": "SetAnimationDirection", + "private": true, + "sentence": "Change the animation direction of _PARAM0_ to _PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Change the animation but keep the current frame number.", + "comment2": "" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetPropertyAnimationDirection" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "round(GetArgumentAsNumber(\"Value\"))" + ] + }, + { + "type": { + "value": "TopDownMovementAnimator::TopDownMovementAnimator::SetSharedPropertyAnimationFrame" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "Object.Sprite()" + ] + }, + { + "type": { + "value": "SetAnimationName" + }, + "parameters": [ + "Object", + "Object. Behavior::PropertyAnimationName() + ToString(Object.Behavior::PropertyAnimationDirection())" + ] + }, + { + "type": { + "value": "ChangeSprite" + }, + "parameters": [ + "Object", + "=", + "Object.Behavior::SharedPropertyAnimationFrame()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + }, + { + "description": "Value", + "name": "Value", + "type": "expression" + } + ], + "objectGroups": [] } ], "propertyDescriptors": [ From 296aaf3c3d073a6c57e74a6f2f1abcb7c0592563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sun, 12 Mar 2023 18:50:17 +0100 Subject: [PATCH 5/8] More reliable calculus. --- .../reviewed/TopDownMovementAnimator.json | 60 +++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/extensions/reviewed/TopDownMovementAnimator.json b/extensions/reviewed/TopDownMovementAnimator.json index 4bdc35e18..77d50f35e 100644 --- a/extensions/reviewed/TopDownMovementAnimator.json +++ b/extensions/reviewed/TopDownMovementAnimator.json @@ -288,9 +288,9 @@ "value": "BuiltinCommonInstructions::CompareNumbers" }, "parameters": [ - "abs(mod(Object.Behavior::SharedPropertyNewAnimationDirection() - Object.Behavior::PropertyAnimationDirection(), Object.Behavior::PropertyDirectionCount()))", + "abs(Object.Behavior:: DirectionDifference(Object.Behavior::SharedPropertyNewAnimationDirection(), Object.Behavior::PropertyAnimationDirection()))", ">", - "0.5 + 0.0625" + "0.5 + 0.03125" ] } ], @@ -636,7 +636,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "mod((Object.TopDownMovement::Angle() + Object.Behavior::PropertyAngleOffset()) * Object.Behavior::PropertyDirectionCount() / 360, Object.Behavior::PropertyDirectionCount())" + "(Object.TopDownMovement::Angle() + Object.Behavior::PropertyAngleOffset()) * Object.Behavior::PropertyDirectionCount() / 360" ] } ] @@ -661,6 +661,58 @@ ], "objectGroups": [] }, + { + "description": "Return the difference between 2 directions.", + "fullName": "Direction dirrerence", + "functionType": "Expression", + "name": "DirectionDifference", + "private": true, + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "mod(mod(GetArgumentAsNumber(\"Direction\") - GetArgumentAsNumber(\"OtherDirection\"), Object.Behavior::PropertyDirectionCount()) + Object.Behavior::PropertyDirectionCount() / 2, Object.Behavior::PropertyDirectionCount()) - Object.Behavior::PropertyDirectionCount() / 2" + ] + } + ] + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Sprite", + "type": "object" + }, + { + "description": "Behavior", + "name": "Behavior", + "supplementaryInformation": "TopDownMovementAnimator::TopDownMovementAnimator", + "type": "behavior" + }, + { + "description": "Direction", + "name": "Direction", + "type": "expression" + }, + { + "description": "Other direction", + "name": "OtherDirection", + "type": "expression" + } + ], + "objectGroups": [] + }, { "description": "Change the animation direction of the object.", "fullName": "Animation direction", @@ -694,7 +746,7 @@ "Object", "Behavior", "=", - "round(GetArgumentAsNumber(\"Value\"))" + "mod(mod(round(GetArgumentAsNumber(\"Value\")), Object.Behavior::PropertyDirectionCount()) + Object.Behavior::PropertyDirectionCount(), Object.Behavior::PropertyDirectionCount())" ] }, { From b9315f0e44ae92924e160d0faf5324cd3f7c59f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sun, 10 Sep 2023 14:22:49 +0200 Subject: [PATCH 6/8] Fix a typo. --- extensions/reviewed/TopDownMovementAnimator.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/extensions/reviewed/TopDownMovementAnimator.json b/extensions/reviewed/TopDownMovementAnimator.json index 77d50f35e..870921f37 100644 --- a/extensions/reviewed/TopDownMovementAnimator.json +++ b/extensions/reviewed/TopDownMovementAnimator.json @@ -11,6 +11,7 @@ "version": "0.1.0", "description": "Change the animation according to the movement direction.", "tags": [ + "top-down", "animation", "direction" ], @@ -276,8 +277,7 @@ "textG": 0, "textR": 0 }, - "comment": "Use a small margin is used to avoid to flicker between 2 directions.", - "comment2": "" + "comment": "Use a small margin is used to avoid to flicker between 2 directions." }, { "type": "BuiltinCommonInstructions::Standard", @@ -731,8 +731,7 @@ "textG": 0, "textR": 0 }, - "comment": "Change the animation but keep the current frame number.", - "comment2": "" + "comment": "Change the animation but keep the current frame number." }, { "type": "BuiltinCommonInstructions::Standard", @@ -853,7 +852,7 @@ "type": "Number", "unit": "DegreeAngle", "label": "Angle offset", - "description": "Setted to 90°, \"Walk0\" becomes the animation for down.", + "description": "Set to 90°, \"Walk0\" becomes the animation for down.", "group": "Direction", "extraInformation": [], "hidden": false, From 2122c25a3d11fe10b05921f1f54b58e1862d4ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sun, 10 Sep 2023 14:23:42 +0200 Subject: [PATCH 7/8] Move it to the community list. --- extensions/{reviewed => community}/TopDownMovementAnimator.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename extensions/{reviewed => community}/TopDownMovementAnimator.json (100%) diff --git a/extensions/reviewed/TopDownMovementAnimator.json b/extensions/community/TopDownMovementAnimator.json similarity index 100% rename from extensions/reviewed/TopDownMovementAnimator.json rename to extensions/community/TopDownMovementAnimator.json From 8247b0ecbc1897bdd08a7d05fcdabdae7ce911ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Davy=20H=C3=A9lard?= Date: Sun, 10 Sep 2023 14:25:39 +0200 Subject: [PATCH 8/8] Fix the same typo in another extension. --- extensions/community/NavMeshPathfinding.json | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/extensions/community/NavMeshPathfinding.json b/extensions/community/NavMeshPathfinding.json index d5682ed36..1e7356dbd 100644 --- a/extensions/community/NavMeshPathfinding.json +++ b/extensions/community/NavMeshPathfinding.json @@ -4515,8 +4515,7 @@ "textG": 0, "textR": 0 }, - "comment": "Initiate and attach properties as objects variables", - "comment2": "" + "comment": "Initiate and attach properties as objects variables" }, { "type": "BuiltinCommonInstructions::Standard", @@ -6096,8 +6095,7 @@ "textG": 0, "textR": 0 }, - "comment": "Initiate and attach properties as objects variables", - "comment2": "" + "comment": "Initiate and attach properties as objects variables" }, { "type": "BuiltinCommonInstructions::Standard", @@ -7116,8 +7114,7 @@ "textG": 0, "textR": 0 }, - "comment": "Use a small margin is used to avoid to flicker between 2 directions.", - "comment2": "" + "comment": "Use a small margin is used to avoid to flicker between 2 directions." }, { "type": "BuiltinCommonInstructions::Standard", @@ -7571,8 +7568,7 @@ "textG": 0, "textR": 0 }, - "comment": "Change the animation but keep the current frame number.", - "comment2": "" + "comment": "Change the animation but keep the current frame number." }, { "type": "BuiltinCommonInstructions::Standard", @@ -7693,7 +7689,7 @@ "type": "Number", "unit": "DegreeAngle", "label": "Angle offset", - "description": "Setted to 90°, \"Walk0\" becomes the animation for down.", + "description": "Set to 90°, \"Walk0\" becomes the animation for down.", "group": "Direction", "extraInformation": [], "hidden": false,