From db70f22db166f5ee8edda1902cd32728141c5b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Vivet?= Date: Mon, 3 Feb 2025 12:49:44 +0100 Subject: [PATCH] Update with avatar custom object --- .../assets/avatar_border_white.png | Bin 0 -> 176 bytes .../assets/unknown.png | Bin 0 -> 1927 bytes .../multiplayer-platformer-arrow-fight.json | 13563 ++++++---------- 3 files changed, 4757 insertions(+), 8806 deletions(-) create mode 100644 examples/multiplayer-platformer-arrow-fight/assets/avatar_border_white.png create mode 100644 examples/multiplayer-platformer-arrow-fight/assets/unknown.png diff --git a/examples/multiplayer-platformer-arrow-fight/assets/avatar_border_white.png b/examples/multiplayer-platformer-arrow-fight/assets/avatar_border_white.png new file mode 100644 index 0000000000000000000000000000000000000000..21d49156025e9605616c77f243c16b0deed5e49f GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5y8Awi_W^)%vF%}28J2BoosZ$T+a29w(7Bet# z3xhBt!>lYggMy42Eqd#15DQiZ{Dkw*UW! z?WNrN}Bzg3<<2jp}r7(9^-{$DB}zsTHMdZX|R8X!MQV?hlP1rRZZ3W*#< zfn#ngygcbPi9wQ7dWG-0_(OOBDahbX$$%eU%f<^IBkuTyCA(C0WS^)IBvdDx(aE#mI0Xh#_UcQ)-W>)xR!n!Us6tI43KD1FK$p--f`VMY=Eb4n zcWfLAB1kRLLKBZDh|ye+qA6(BQII44j*g#ZNK!w-L5z&nJly(>jYC0Ft?bE$z{m#$ zF$jHs=mZOZQIMaMSGmtR!q%N2NFhr?QR-m!5Pc(=SrN;A-^k(25i_f`Z}Zz}fdgGa z!(SBS40OOwmEW*&D2RG;ZYgx{3I%!pFF4R8bn6NQ>4RT@Q}6!7#=-8u%8`I>1P3um zYY7rtFo@9-5w1*uK?b6YvYmoAckwUXWNB69Xcij>5mf~3QvVY=5(kM3gCz+V!$+e1 z5d*u0C*vg`ziO0Oy%d_Ai)5RjC)%aqXewwS35fch6~133EErH;lw>VIBZCM;Ig>4z zA=086#o{1od5{bwKGVxVzHsp1zs`#LYW<;_iO&z8{jQd$ zBfU;)O_0l>SGbZVL&d!by@txX?Qeq>TaT4M2FVR}rDUj-!B7D~P1bjH%V7LSt0xOl zT8YA3k%J_eIGdd(rPzE)LE;mY{KIS_ohs5b`?Z$YYdy$btgJO@q?iuMGLb2kfDGw2jYs9K@o|G|u6e9={~AP{*1h!R#-gMe7RkA=_=DKZ^Jf9IPTnBJomDmCit=l3P3R+G7*c<473{Xjn0oanbz)4tcuyg<~>4q?f!n9k?P z_F}MB_e zpk9t4e#t)@#H?Y27Ta=hK}?Ec8Je9k-69jj;0zR|xGP`g^X)IjT32?%o9{f3L1orI z=@c_k;eqVir>}}xIK%=m>P%pYS1->3sq=-*?|#LZB^;1?UkG!Sa6sw^PFBSVR2U#8 z{S{u~G0e%c-wCgS*(={g6hd9eIgSZSDp!J2=Eg?!)PvAV%kC zdCF~pogfBB<^gg~cPEJ1NiKeJF0fo6W?j;ravpr>0;%7LJjvO%n&ypZ^XBa{veLDqGcdB$<1HT9Zd9lFzb=f zR*2-ECV3NU_Jhfy986v-v`izpi};#yzhn#VYs$uxRUEHre}pU<_z%t0lh|bM_6q<2 N002ovPDHLkV1htXj5GiM literal 0 HcmV?d00001 diff --git a/examples/multiplayer-platformer-arrow-fight/multiplayer-platformer-arrow-fight.json b/examples/multiplayer-platformer-arrow-fight/multiplayer-platformer-arrow-fight.json index 7d303a1f1..60cc79b5e 100644 --- a/examples/multiplayer-platformer-arrow-fight/multiplayer-platformer-arrow-fight.json +++ b/examples/multiplayer-platformer-arrow-fight/multiplayer-platformer-arrow-fight.json @@ -1,7 +1,7 @@ { - "firstLayout": "", + "firstLayout": "Lobby", "gdVersion": { - "build": 221, + "build": 223, "major": 5, "minor": 5, "revision": 0 @@ -573,6 +573,22 @@ "name": "world_tileset.png", "smoothed": false, "userAdded": true + }, + { + "file": "assets/unknown.png", + "kind": "image", + "metadata": "", + "name": "assets\\unknown.png", + "smoothed": true, + "userAdded": false + }, + { + "file": "assets/avatar_border_white.png", + "kind": "image", + "metadata": "", + "name": "assets\\avatar_border_white.png", + "smoothed": true, + "userAdded": false } ], "resourceFolders": [] @@ -1575,7 +1591,7 @@ "name": "Score", "persistentUuid": "e403f614-65c5-44a6-a001-0c398864963a", "width": 246, - "x": 16, + "x": 80, "y": 144, "zOrder": 9, "numberProperties": [], @@ -1606,7 +1622,7 @@ "name": "Score", "persistentUuid": "c661ffde-5840-450b-acb3-6fe3c2cb1e3f", "width": 246, - "x": 16, + "x": 80, "y": 0, "zOrder": 9, "numberProperties": [], @@ -1636,7 +1652,7 @@ "name": "Score", "persistentUuid": "f977216e-65c3-4b4b-9ef0-8f4f564e61fd", "width": 246, - "x": 16, + "x": 80, "y": 48, "zOrder": 9, "numberProperties": [], @@ -1667,7 +1683,7 @@ "name": "Score", "persistentUuid": "4e6dba52-6b69-449e-a167-a11cda325df9", "width": 246, - "x": 16, + "x": 80, "y": 96, "zOrder": 9, "numberProperties": [], @@ -1756,9 +1772,121 @@ } ], "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 31, + "height": 48, + "keepRatio": true, + "layer": "UI", + "name": "Avatar", + "persistentUuid": "e4a8631a-9406-45c3-93fb-20514756d69e", + "width": 48, + "x": 16, + "y": 0, + "zOrder": 13, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [ + { + "name": "PlayerNumber", + "persistentUuid": "8f19c748-ab88-4c41-bd3d-6ba67c292b5d", + "type": "number", + "value": 1 + } + ] + }, + { + "angle": 0, + "customSize": true, + "depth": 31, + "height": 48, + "keepRatio": true, + "layer": "UI", + "name": "Avatar", + "persistentUuid": "2879400b-8013-4c2a-803a-a85ba1cf668e", + "width": 48, + "x": 16, + "y": 48, + "zOrder": 13, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [ + { + "name": "PlayerNumber", + "type": "number", + "value": 2 + } + ] + }, + { + "angle": 0, + "customSize": true, + "depth": 31, + "height": 48, + "keepRatio": true, + "layer": "UI", + "name": "Avatar", + "persistentUuid": "9346e37e-b40e-4d1e-9909-bca975b29b35", + "width": 48, + "x": 16, + "y": 96, + "zOrder": 13, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [ + { + "name": "PlayerNumber", + "type": "number", + "value": 3 + } + ] + }, + { + "angle": 0, + "customSize": true, + "depth": 31, + "height": 48, + "keepRatio": true, + "layer": "UI", + "name": "Avatar", + "persistentUuid": "a82af8c6-eb16-4c59-832b-ebbc8d833632", + "width": 48, + "x": 16, + "y": 144, + "zOrder": 13, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [ + { + "name": "PlayerNumber", + "type": "number", + "value": 4 + } + ] } ], "objects": [ + { + "assetStoreId": "", + "height": 16, + "name": "Tile", + "texture": "Platform_Stone2.png", + "type": "TiledSpriteObject::TiledSprite", + "width": 16, + "variables": [], + "effects": [], + "behaviors": [ + { + "name": "Platform", + "type": "PlatformBehavior::PlatformBehavior", + "canBeGrabbed": false, + "platformType": "NormalPlatform", + "yGrabOffset": 0 + } + ] + }, { "adaptCollisionMaskAutomatically": true, "assetStoreId": "", @@ -5203,6 +5331,24 @@ "tileSize": 16, "tilesWithHitBox": "0,16,32,1,17,33,2,18,34,3,19,35,8,24,40,50,9,10,11,25,41,26,42,27,43,4,20,36,5,37,6,22,38,7,23,39,21" } + }, + { + "assetStoreId": "", + "name": "Avatar", + "type": "PlayerAvatar::PlayerAvatar", + "variables": [ + { + "name": "PlayerNumber", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "content": { + "PlayerNumber": 0, + "BorderEnabled": false + } } ], "objectsFolderStructure": { @@ -5231,6 +5377,9 @@ { "objectName": "JumpThrough" }, + { + "objectName": "Tile" + }, { "objectName": "LevelTiles" } @@ -5271,6 +5420,9 @@ "objectName": "CameraCenter" } ] + }, + { + "objectName": "Avatar" } ] }, @@ -5339,6 +5491,47 @@ } ], "events": [ + { + "type": "BuiltinCommonInstructions::ForEach", + "object": "Avatar", + "conditions": [], + "actions": [ + { + "type": { + "value": "PlayerAvatar::PlayerAvatar::SetUserID" + }, + "parameters": [ + "Avatar", + "=", + "PlayerAvatar::UserID(Avatar.PlayerNumber)", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "SystemInfo::IsMobile" + }, + "parameters": [] + } + ], + "actions": [ + { + "type": { + "value": "Delete" + }, + "parameters": [ + "MobileControls", + "" + ] + } + ] + }, { "colorB": 228, "colorG": 176, @@ -5618,138 +5811,18 @@ } ], "parameters": [] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "SystemInfo::IsMobile" - }, - "parameters": [] - } - ], - "actions": [ - { - "type": { - "value": "Delete" - }, - "parameters": [ - "MobileControls", - "" - ] - } - ], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "Cache" - }, - "parameters": [ - "MovementJoystick" - ] - }, - { - "type": { - "value": "Cache" - }, - "parameters": [ - "AimingJoystick" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::ActivateControl" - }, - "parameters": [ - "MovementJoystick", - "", - "" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::ActivateControl" - }, - "parameters": [ - "AimingJoystick", - "", - "" - ] - } - ] - } - ] } ] } ], "parameters": [] }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::HasTouchStartedOnScreenSide" - }, - "parameters": [ - "", - "MovementJoystick", - "\"Left\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::TeleportAndPress" - }, - "parameters": [ - "MovementJoystick", - "CursorX(\"UI\")" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::HasTouchStartedOnScreenSide" - }, - "parameters": [ - "", - "AimingJoystick", - "\"Right\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::TeleportAndPress" - }, - "parameters": [ - "AimingJoystick", - "CursorX(\"UI\")" - ] - } - ] - }, { "colorB": 228, "colorG": 176, "colorR": 74, "creationTime": 0, + "folded": true, "name": "Controls", "source": "", "type": "BuiltinCommonInstructions::Group", @@ -5783,11 +5856,11 @@ "conditions": [ { "type": { - "value": "KeyFromTextPressed" + "value": "KeyPressed" }, "parameters": [ "", - "\"w\"" + "w" ] } ], @@ -5808,11 +5881,11 @@ "conditions": [ { "type": { - "value": "KeyFromTextPressed" + "value": "KeyPressed" }, "parameters": [ "", - "\"a\"" + "a" ] } ], @@ -5833,11 +5906,11 @@ "conditions": [ { "type": { - "value": "KeyFromTextPressed" + "value": "KeyPressed" }, "parameters": [ "", - "\"s\"" + "s" ] } ], @@ -5858,11 +5931,11 @@ "conditions": [ { "type": { - "value": "KeyFromTextPressed" + "value": "KeyPressed" }, "parameters": [ "", - "\"d\"" + "d" ] } ], @@ -5901,11 +5974,11 @@ "subInstructions": [ { "type": { - "value": "KeyFromTextPressed" + "value": "KeyPressed" }, "parameters": [ "", - "\"Up\"" + "Up" ] }, { @@ -5943,11 +6016,11 @@ }, { "type": { - "value": "KeyFromTextPressed" + "value": "KeyPressed" }, "parameters": [ "", - "\"w\"" + "w" ] } ] @@ -6044,11 +6117,11 @@ "conditions": [ { "type": { - "value": "MouseButtonFromTextPressed" + "value": "MouseButtonPressed" }, "parameters": [ "", - "\"Left\"" + "Left" ] } ], @@ -6082,11 +6155,11 @@ "conditions": [ { "type": { - "value": "MouseButtonFromTextReleased" + "value": "MouseButtonReleased" }, "parameters": [ "", - "\"Left\"" + "Left" ] } ], @@ -6346,6 +6419,7 @@ "colorG": 176, "colorR": 74, "creationTime": 0, + "folded": true, "name": "Arrows", "source": "", "type": "BuiltinCommonInstructions::Group", @@ -6975,6 +7049,7 @@ "colorG": 176, "colorR": 74, "creationTime": 0, + "folded": true, "name": "Bot controls", "source": "", "type": "BuiltinCommonInstructions::Group", @@ -7405,6 +7480,7 @@ "colorG": 176, "colorR": 74, "creationTime": 0, + "folded": true, "name": "Player drop out", "source": "", "type": "BuiltinCommonInstructions::Group", @@ -7462,6 +7538,7 @@ "colorG": 176, "colorR": 74, "creationTime": 0, + "folded": true, "name": "Pause game", "source": "", "type": "BuiltinCommonInstructions::Group", @@ -7471,11 +7548,11 @@ "conditions": [ { "type": { - "value": "KeyFromTextPressed" + "value": "KeyPressed" }, "parameters": [ "", - "\"p\"" + "p" ] }, { @@ -7637,6 +7714,7 @@ "colorG": 176, "colorR": 74, "creationTime": 0, + "folded": true, "name": "Death", "source": "", "type": "BuiltinCommonInstructions::Group", @@ -8058,7 +8136,7 @@ "name": "BehaviorRemapper", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/alpha-w-box-outline.svg", "shortDescription": "Quickly remap Behavior controls to different keys. ", - "version": "1.0.1", + "version": "1.0.0", "description": [ "Make sure to disable default controls unless you want two keys to do the same action.", "", @@ -8137,7 +8215,7 @@ }, "parameters": [ "", - "Up" + "Object.Behavior::PropertyUp()" ] } ], @@ -8162,7 +8240,7 @@ }, "parameters": [ "", - "Left" + "Object.Behavior::PropertyLeft()" ] } ], @@ -8187,7 +8265,7 @@ }, "parameters": [ "", - "Right" + "Object.Behavior::PropertyRight()" ] } ], @@ -8212,7 +8290,7 @@ }, "parameters": [ "", - "Down" + "Object.Behavior::PropertyDown()" ] } ], @@ -8270,7 +8348,7 @@ "Object", "Behavior", "=", - "up" + "GetArgumentAsString(\"up\")" ] }, { @@ -8281,7 +8359,7 @@ "Object", "Behavior", "=", - "left" + "GetArgumentAsString(\"left\")" ] }, { @@ -8292,7 +8370,7 @@ "Object", "Behavior", "=", - "right" + "GetArgumentAsString(\"right\")" ] }, { @@ -8303,7 +8381,7 @@ "Object", "Behavior", "=", - "down" + "GetArgumentAsString(\"down\")" ] } ] @@ -8371,7 +8449,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"WASD\"" ] @@ -8444,7 +8522,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"ZQSD\"" ] @@ -8517,7 +8595,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"Numpad\"" ] @@ -8590,7 +8668,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"IJKL\"" ] @@ -8738,7 +8816,7 @@ }, "parameters": [ "", - "Up" + "Object.Behavior::PropertyUp()" ] } ], @@ -8772,7 +8850,7 @@ }, "parameters": [ "", - "Left" + "Object.Behavior::PropertyLeft()" ] } ], @@ -8797,7 +8875,7 @@ }, "parameters": [ "", - "Right" + "Object.Behavior::PropertyRight()" ] } ], @@ -8822,7 +8900,7 @@ }, "parameters": [ "", - "Down" + "Object.Behavior::PropertyDown()" ] } ], @@ -8856,7 +8934,7 @@ }, "parameters": [ "", - "Jump" + "Object.Behavior::PropertyJump()" ] } ], @@ -8914,7 +8992,7 @@ "Object", "Behavior", "=", - "up" + "GetArgumentAsString(\"up\")" ] }, { @@ -8925,7 +9003,7 @@ "Object", "Behavior", "=", - "left" + "GetArgumentAsString(\"left\")" ] }, { @@ -8936,7 +9014,7 @@ "Object", "Behavior", "=", - "right" + "GetArgumentAsString(\"right\")" ] }, { @@ -8947,7 +9025,7 @@ "Object", "Behavior", "=", - "down" + "GetArgumentAsString(\"down\")" ] }, { @@ -8958,7 +9036,7 @@ "Object", "Behavior", "=", - "jump" + "GetArgumentAsString(\"jump\")" ] } ] @@ -9031,7 +9109,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"WASD\"" ] @@ -9115,7 +9193,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"ZQSD\"" ] @@ -9199,7 +9277,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"Numpad\"" ] @@ -9283,7 +9361,7 @@ "value": "StrEqual" }, "parameters": [ - "options", + "GetArgumentAsString(\"options\")", "=", "\"IJKL\"" ] @@ -9443,7 +9521,7 @@ "name": "SpriteMultitouchJoystick", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/Videogames/Videogames_controller_joystick_arrows_direction.svg", "shortDescription": "Joysticks or buttons for touchscreens.", - "version": "1.6.1", + "version": "1.2.2", "description": [ "Multitouch joysticks can be used the same way as physical gamepads:", "- 4 or 8 directions", @@ -9478,458 +9556,8 @@ ], "dependencies": [], "globalVariables": [], - "sceneVariables": [ - { - "name": "Controllers", - "type": "array", - "children": [ - { - "type": "structure", - "children": [ - { - "name": "Buttons", - "type": "array", - "children": [ - { - "type": "structure", - "children": [ - { - "name": "State", - "type": "string", - "value": "Idle" - } - ] - } - ] - }, - { - "name": "Joystick", - "type": "structure", - "children": [] - } - ] - } - ] - } - ], + "sceneVariables": [], "eventsFunctions": [ - { - "fullName": "Accelerated speed", - "functionType": "Expression", - "name": "AcceleratedSpeed", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "CurrentSpeed" - ] - } - ], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"TargetedSpeed\"", - "<", - "0" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Reduce the speed to match the stick force." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "TargetedSpeed" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "min(TargetedSpeed, CurrentSpeed + Acceleration * TimeDelta())" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "TargetedSpeed" - ] - }, - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "-", - "Acceleration * TimeDelta()" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Turn back at least as fast as it would stop." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">=", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "max(TargetedSpeed, CurrentSpeed - max(Acceleration , Deceleration) * TimeDelta())" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"TargetedSpeed\"", - ">", - "0" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Reduce the speed to match the stick force." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "TargetedSpeed" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "max(TargetedSpeed, CurrentSpeed - Acceleration * TimeDelta())" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "TargetedSpeed" - ] - }, - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "+", - "Acceleration * TimeDelta()" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Turn back at least as fast as it would stop." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<=", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "min(TargetedSpeed, CurrentSpeed + max(Acceleration , Deceleration) * TimeDelta())" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"TargetedSpeed\"", - "=", - "0" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "min(0, CurrentSpeed + Acceleration * TimeDelta())" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "max(0, CurrentSpeed - Acceleration * TimeDelta())" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "clamp(AcceleratedSpeed, -SpeedMax, SpeedMax)" - ] - } - ] - } - ], - "variables": [ - { - "name": "AcceleratedSpeed", - "type": "number", - "value": 0 - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Current speed", - "name": "CurrentSpeed", - "type": "expression" - }, - { - "description": "Targeted speed", - "name": "TargetedSpeed", - "type": "expression" - }, - { - "description": "Max speed", - "name": "SpeedMax", - "type": "expression" - }, - { - "description": "Acceleration", - "name": "Acceleration", - "type": "expression" - }, - { - "description": "Deceleration", - "name": "Deceleration", - "type": "expression" - } - ], - "objectGroups": [] - }, { "description": "Check if a button is pressed on a gamepad.", "fullName": "Multitouch controller button pressed", @@ -9942,10 +9570,10 @@ "conditions": [ { "type": { - "value": "StringVariable" + "value": "VarSceneTxt" }, "parameters": [ - "Controllers[ControllerIdentifier].Buttons[Button].State", + "__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Buttons[GetArgumentAsString(\"Button\")].State", "=", "\"Pressed\"" ] @@ -9990,10 +9618,10 @@ "conditions": [ { "type": { - "value": "StringVariable" + "value": "VarSceneTxt" }, "parameters": [ - "Controllers[ControllerIdentifier].Buttons[Button].State", + "__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Buttons[GetArgumentAsString(\"Button\")].State", "=", "\"Released\"" ] @@ -10040,12 +9668,12 @@ "actions": [ { "type": { - "value": "SetStringVariable" + "value": "ModVarSceneTxt" }, "parameters": [ - "Controllers[ControllerIdentifier].Buttons[Button].State", + "__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Buttons[GetArgumentAsString(\"Button\")].State", "=", - "ButtonState" + "GetArgumentAsString(\"ButtonState\")" ] } ] @@ -10085,12 +9713,12 @@ "actions": [ { "type": { - "value": "SetNumberVariable" + "value": "ModVarScene" }, "parameters": [ - "Controllers[ControllerIdentifier].Joystick[JoystickIdentifier].DeadZone", + "__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Joystick[GetArgumentAsString(\"JoystickIdentifier\")].DeadZone", "=", - "DeadZoneRadius" + "GetArgumentAsNumber(\"DeadZoneRadius\")" ] } ] @@ -10133,7 +9761,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "Controllers[ControllerIdentifier].Joystick[JoystickIdentifier].DeadZone" + "Variable(__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Joystick[GetArgumentAsString(\"JoystickIdentifier\")].DeadZone)" ] } ] @@ -10173,7 +9801,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "mod(round(Angle * 4 / 360), 4)" + "mod(round(GetArgumentAsNumber(\"Angle\") * 4 / 360), 4)" ] } ] @@ -10208,7 +9836,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "mod(round(Angle * 8 / 360), 8)" + "mod(round(GetArgumentAsNumber(\"Angle\") * 8 / 360), 8)" ] } ] @@ -10242,7 +9870,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Right\"" ] @@ -10255,7 +9883,7 @@ "", "=", "0", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10279,7 +9907,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Down\"" ] @@ -10292,7 +9920,7 @@ "", "=", "1", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10316,7 +9944,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Left\"" ] @@ -10329,7 +9957,7 @@ "", "=", "2", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10353,7 +9981,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Up\"" ] @@ -10366,7 +9994,7 @@ "", "=", "3", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10414,7 +10042,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Right\"" ] @@ -10427,7 +10055,7 @@ "", "=", "0", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10451,7 +10079,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"DownRight\"" ] @@ -10464,7 +10092,7 @@ "", "=", "1", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10488,7 +10116,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Down\"" ] @@ -10501,7 +10129,7 @@ "", "=", "2", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10525,7 +10153,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"DownLeft\"" ] @@ -10538,7 +10166,7 @@ "", "=", "3", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10562,7 +10190,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Left\"" ] @@ -10575,7 +10203,7 @@ "", "=", "4", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10599,7 +10227,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"UpLeft\"" ] @@ -10612,7 +10240,7 @@ "", "=", "5", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10636,7 +10264,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"Up\"" ] @@ -10649,7 +10277,7 @@ "", "=", "6", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10673,7 +10301,7 @@ "value": "BuiltinCommonInstructions::CompareStrings" }, "parameters": [ - "Direction", + "GetArgumentAsString(\"Direction\")", "=", "\"UpRight\"" ] @@ -10686,7 +10314,7 @@ "", "=", "7", - "Angle", + "GetArgumentAsNumber(\"Angle\")", "" ] } @@ -10747,9 +10375,9 @@ "parameters": [ "", ">", - "0", - "ControllerIdentifier", - "JoystickIdentifier", + "SpriteMultitouchJoystick::DeadZone(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))", + "GetArgumentAsNumber(\"ControllerIdentifier\")", + "GetArgumentAsString(\"JoystickIdentifier\")", "" ] }, @@ -10759,8 +10387,8 @@ }, "parameters": [ "", - "SpriteMultitouchJoystick::JoystickAngle(ControllerIdentifier, JoystickIdentifier)", - "Direction", + "SpriteMultitouchJoystick::JoystickAngle(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))", + "GetArgumentAsString(\"Direction\")", "" ] } @@ -10827,9 +10455,9 @@ "parameters": [ "", ">", - "0", - "ControllerIdentifier", - "JoystickIdentifier", + "SpriteMultitouchJoystick::DeadZone(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))", + "GetArgumentAsNumber(\"ControllerIdentifier\")", + "GetArgumentAsString(\"JoystickIdentifier\")", "" ] }, @@ -10839,8 +10467,8 @@ }, "parameters": [ "", - "SpriteMultitouchJoystick::JoystickAngle(ControllerIdentifier, JoystickIdentifier)", - "Direction", + "SpriteMultitouchJoystick::JoystickAngle(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))", + "GetArgumentAsString(\"Direction\")", "" ] } @@ -10895,7 +10523,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "SpriteMultitouchJoystick::StickForce(ControllerIdentifier, JoystickIdentifier)" + "SpriteMultitouchJoystick::StickForce(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))" ] } ] @@ -10915,11 +10543,6 @@ "name": "JoystickIdentifier", "supplementaryInformation": "[\"Primary\",\"Secondary\"]", "type": "stringWithSelector" - }, - { - "description": "", - "name": "Coucou", - "type": "expression" } ], "objectGroups": [] @@ -10940,7 +10563,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "max(0, Controllers[ControllerIdentifier].Joystick[JoystickIdentifier].Force - SpriteMultitouchJoystick::DeadZone(ControllerIdentifier, JoystickIdentifier)) / (1 - SpriteMultitouchJoystick::DeadZone(ControllerIdentifier, JoystickIdentifier))" + "Variable(__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Joystick[GetArgumentAsString(\"JoystickIdentifier\")].Force)" ] } ] @@ -10978,12 +10601,12 @@ "actions": [ { "type": { - "value": "SetNumberVariable" + "value": "ModVarScene" }, "parameters": [ - "Controllers[ControllerIdentifier].Joystick[JoystickIdentifier].Force", + "__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Joystick[GetArgumentAsString(\"JoystickIdentifier\")].Force", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -11025,7 +10648,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "SpriteMultitouchJoystick::StickAngle(ControllerIdentifier, JoystickIdentifier)" + "SpriteMultitouchJoystick::StickAngle(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))" ] } ] @@ -11065,7 +10688,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "Controllers[ControllerIdentifier].Joystick[JoystickIdentifier].Angle" + "Variable(__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Joystick[GetArgumentAsString(\"JoystickIdentifier\")].Angle)" ] } ] @@ -11103,12 +10726,12 @@ "actions": [ { "type": { - "value": "SetNumberVariable" + "value": "ModVarScene" }, "parameters": [ - "Controllers[ControllerIdentifier].Joystick[JoystickIdentifier].Angle", + "__MultitouchJoystick.Controllers[GetArgumentAsNumber(\"ControllerIdentifier\")].Joystick[GetArgumentAsString(\"JoystickIdentifier\")].Angle", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -11149,7 +10772,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "XFromAngleAndDistance(SpriteMultitouchJoystick::StickAngle(ControllerIdentifier, JoystickIdentifier), SpriteMultitouchJoystick::StickForce(ControllerIdentifier, JoystickIdentifier))" + "SpriteMultitouchJoystick::JoystickForce(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\")) * cos(ToRad(SpriteMultitouchJoystick::JoystickAngle(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))))" ] } ] @@ -11189,7 +10812,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "YFromAngleAndDistance(SpriteMultitouchJoystick::StickAngle(ControllerIdentifier, JoystickIdentifier), SpriteMultitouchJoystick::StickForce(ControllerIdentifier, JoystickIdentifier))" + "SpriteMultitouchJoystick::JoystickForce(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\")) * sin(ToRad(SpriteMultitouchJoystick::JoystickAngle(GetArgumentAsNumber(\"ControllerIdentifier\"), GetArgumentAsString(\"JoystickIdentifier\"))))" ] } ] @@ -11212,123 +10835,6 @@ } ], "objectGroups": [] - }, - { - "description": "Check if a new touch has started on the right or left side of the screen.", - "fullName": "New touch on a screen side", - "functionType": "Condition", - "group": "Multitouch Joystick", - "name": "HasTouchStartedOnScreenSide", - "sentence": "A new touch has started on the _PARAM2_ side of the screen on _PARAM1_'s layer", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "HasAnyTouchOrMouseStarted" - }, - "parameters": [ - "" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsString" - }, - "parameters": [ - "\"Side\"", - "=", - "\"Left\"" - ] - }, - { - "type": { - "value": "TouchX" - }, - "parameters": [ - "", - "StartedTouchOrMouseId(0)", - "<", - "CameraCenterX(Object.Layer())", - "Object.Layer()", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsString" - }, - "parameters": [ - "\"Side\"", - "=", - "\"Right\"" - ] - }, - { - "type": { - "value": "TouchX" - }, - "parameters": [ - "", - "StartedTouchOrMouseId(0)", - ">=", - "CameraCenterX(Object.Layer())", - "Object.Layer()", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ] - } - ], - "parameters": [ - { - "description": "Multitouch joystick", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "objectList" - }, - { - "description": "Screen side", - "name": "Side", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" - } - ], - "objectGroups": [] } ], "eventsBasedBehaviors": [ @@ -11355,9 +10861,9 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JoystickIdentifier", - "DeadZoneRadius", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "Object.Behavior::PropertyDeadZoneRadius()", "" ] }, @@ -11519,8 +11025,8 @@ }, "parameters": [ "Object", - "TouchX(StartedTouchOrMouseId(TouchIndex), Object.Layer(), 0)", - "TouchY(StartedTouchOrMouseId(TouchIndex), Object.Layer(), 0)" + "TouchX(StartedTouchOrMouseId(Object.Behavior::PropertyTouchIndex()), Object.Layer(), 0)", + "TouchY(StartedTouchOrMouseId(Object.Behavior::PropertyTouchIndex()), Object.Layer(), 0)" ] } ], @@ -11533,7 +11039,7 @@ "Object", "Behavior", "=", - "StartedTouchOrMouseId(TouchIndex)" + "StartedTouchOrMouseId(Object.Behavior::PropertyTouchIndex())" ] } ] @@ -11580,7 +11086,7 @@ }, "parameters": [ "", - "TouchId" + "Object.Behavior::PropertyTouchId()" ] } ], @@ -11632,8 +11138,8 @@ "parameters": [ "Object", "Behavior", - "AngleBetweenPositions(Object.CenterX(), Object.CenterY(), TouchX(TouchId, Object.Layer(), 0), TouchY(TouchId, Object.Layer(), 0))", - "AngleBetweenPositions(Object.CenterX(), Object.CenterY(), TouchX(TouchId, Object.Layer(), 0), TouchY(TouchId, Object.Layer(), 0))" + "AngleBetweenPositions(Object.CenterX(), Object.CenterY(), TouchX(Object.Behavior::PropertyTouchId(), Object.Layer(), 0), TouchY(Object.Behavior::PropertyTouchId(), Object.Layer(), 0))", + "AngleBetweenPositions(Object.CenterX(), Object.CenterY(), TouchX(Object.Behavior::PropertyTouchId(), Object.Layer(), 0), TouchY(Object.Behavior::PropertyTouchId(), Object.Layer(), 0))" ] }, { @@ -11644,7 +11150,7 @@ "Object", "Behavior", "=", - "clamp(2 * DistanceBetweenPositions(Object.CenterX(), Object.CenterY(), TouchX(TouchId, Object.Layer(), 0), TouchY(TouchId, Object.Layer(), 0)) / Object.Width(), 0, 1)", + "clamp(2 * DistanceBetweenPositions(Object.CenterX(), Object.CenterY(), TouchX(Object.Behavior::PropertyTouchId(), Object.Layer(), 0), TouchY(Object.Behavior::PropertyTouchId(), Object.Layer(), 0)) / Object.Width(), 0, 1)", "" ] } @@ -11685,7 +11191,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "max(0, JoystickForce - DeadZoneRadius) / (1 - DeadZoneRadius)" + "Object.Behavior::PropertyJoystickForce()" ] } ] @@ -11729,7 +11235,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] }, { @@ -11738,9 +11244,9 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JoystickIdentifier", - "JoystickForce", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "Object.Behavior::PropertyJoystickForce()", "" ] } @@ -11758,11 +11264,6 @@ "name": "Behavior", "supplementaryInformation": "SpriteMultitouchJoystick::MultitouchJoystick", "type": "behavior" - }, - { - "description": "", - "name": "Parameter", - "type": "objectList" } ], "objectGroups": [] @@ -11783,7 +11284,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "JoystickAngle" + "Object.Behavior::PropertyJoystickAngle()" ] } ] @@ -11827,7 +11328,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] }, { @@ -11836,9 +11337,9 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JoystickIdentifier", - "JoystickAngle", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "Object.Behavior::PropertyJoystickAngle()", "" ] } @@ -11957,14 +11458,13 @@ "conditions": [ { "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::JoystickForce" + "value": "SpriteMultitouchJoystick::MultitouchJoystick::PropertyJoystickForce" }, "parameters": [ "Object", "Behavior", ">", - "0", - "" + "Object.Behavior::PropertyDeadZoneRadius()" ] }, { @@ -11973,8 +11473,8 @@ }, "parameters": [ "", - "JoystickAngle", - "Direction", + "Object.Behavior::JoystickAngle()", + "GetArgumentAsString(\"Direction\")", "" ] } @@ -12024,14 +11524,13 @@ "conditions": [ { "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::JoystickForce" + "value": "SpriteMultitouchJoystick::MultitouchJoystick::PropertyJoystickForce" }, "parameters": [ "Object", "Behavior", ">", - "0", - "" + "Object.Behavior::PropertyDeadZoneRadius()" ] }, { @@ -12040,8 +11539,8 @@ }, "parameters": [ "", - "JoystickAngle", - "Direction", + "Object.Behavior::JoystickAngle()", + "GetArgumentAsString(\"Direction\")", "" ] } @@ -12198,7 +11697,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "ControllerIdentifier" + "Object.Behavior::PropertyControllerIdentifier()" ] } ] @@ -12241,7 +11740,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -12279,7 +11778,7 @@ "value": "SetReturnString" }, "parameters": [ - "JoystickIdentifier" + "Object.Behavior::PropertyJoystickIdentifier()" ] } ] @@ -12322,7 +11821,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsString(\"Value\")" ] } ] @@ -12360,7 +11859,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "DeadZoneRadius" + "Object.Behavior::PropertyDeadZoneRadius()" ] } ] @@ -12403,59 +11902,7 @@ "Object", "Behavior", "=", - "Value" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::SetDeadZone" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "Value", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::MultitouchJoystick", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "Force the joystick into the pressing state.", - "fullName": "Force start pressing", - "functionType": "Action", - "name": "ForceStartPressing", - "sentence": "Force start pressing _PARAM0_ with touch identifier: _PARAM2_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetPropertyTouchId" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -12472,11 +11919,6 @@ "name": "Behavior", "supplementaryInformation": "SpriteMultitouchJoystick::MultitouchJoystick", "type": "behavior" - }, - { - "description": "Touch identifier", - "name": "Value", - "type": "expression" } ], "objectGroups": [] @@ -12651,31 +12093,12 @@ "conditions": [ { "type": { - "value": "BuiltinCommonInstructions::Or" + "value": "CollisionPoint" }, - "parameters": [], - "subInstructions": [ - { - "type": { - "value": "CollisionPoint" - }, - "parameters": [ - "Object", - "TouchX(StartedTouchOrMouseId(TouchIndex), Object.Layer())", - "TouchY(StartedTouchOrMouseId(TouchIndex), Object.Layer())" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchButton::PropertyRadius" - }, - "parameters": [ - "Object", - "Behavior", - ">", - "DistanceBetweenPositions(Object.CenterX(), Object.CenterY(), TouchX(StartedTouchOrMouseId(TouchIndex), Object.Layer()), TouchY(StartedTouchOrMouseId(TouchIndex), Object.Layer()))" - ] - } + "parameters": [ + "Object", + "TouchX(StartedTouchOrMouseId(Object.Behavior::PropertyTouchIndex()), Object.Layer(), 0)", + "TouchY(StartedTouchOrMouseId(Object.Behavior::PropertyTouchIndex()), Object.Layer(), 0)" ] } ], @@ -12688,7 +12111,7 @@ "Object", "Behavior", "=", - "StartedTouchOrMouseId(TouchIndex)" + "StartedTouchOrMouseId(Object.Behavior::PropertyTouchIndex())" ] }, { @@ -12744,7 +12167,7 @@ }, "parameters": [ "", - "TouchId" + "Object.Behavior::PropertyTouchId()" ] } ], @@ -12912,9 +12335,9 @@ }, "parameters": [ "", - "ControllerIdentifier", - "ButtonIdentifier", - "ButtonState", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyButtonIdentifier()", + "GetArgumentAsString(\"ButtonState\")", "" ] } @@ -12991,16 +12414,6 @@ "extraInformation": [], "hidden": true, "name": "IsReleased" - }, - { - "value": "0", - "type": "Number", - "unit": "Pixel", - "label": "Triggering circle radius", - "description": "This circle adds up to the object collision mask.", - "group": "", - "extraInformation": [], - "name": "Radius" } ], "sharedPropertyDescriptors": [] @@ -13026,8 +12439,8 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JoystickIdentifier", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", "\"Left\"", "" ] @@ -13054,8 +12467,8 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JoystickIdentifier", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", "\"Right\"", "" ] @@ -13082,8 +12495,8 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JoystickIdentifier", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", "\"Up\"", "" ] @@ -13119,8 +12532,8 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JoystickIdentifier", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", "\"Down\"", "" ] @@ -13147,8 +12560,8 @@ }, "parameters": [ "", - "ControllerIdentifier", - "JumpButton", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJumpButton()", "\"Down\"" ] } @@ -13228,9 +12641,9 @@ "sharedPropertyDescriptors": [] }, { - "description": "Control a 3D physics character with a multitouch controller.", - "fullName": "3D platformer multitouch controller mapper", - "name": "Platformer3DMultitouchMapper", + "description": "Control a top-down character with a multitouch controller.", + "fullName": "Top-down multitouch controller mapper", + "name": "TopDownMultitouchMapper", "objectType": "", "eventsFunctions": [ { @@ -13244,445 +12657,481 @@ "conditions": [ { "type": { - "value": "SpriteMultitouchJoystick::StickForce" - }, - "parameters": [ - "", - ">", - "0", - "ControllerIdentifier", - "JoystickIdentifier", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SetForwardAngle" + "value": "SpriteMultitouchJoystick::TopDownMultitouchMapper::PropertyStickMode" }, "parameters": [ "Object", - "PhysicsCharacter3D", + "Behavior", "=", - "SpriteMultitouchJoystick::StickAngle(ControllerIdentifier, JoystickIdentifier) + CameraAngle(Object.Layer())" - ] - }, - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateStick" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D", - "-90", - "SpriteMultitouchJoystick::StickForce(ControllerIdentifier, JoystickIdentifier)" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsButtonPressed" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JumpButton", - "\"Down\"" + "\"Analog\"" ] } ], "actions": [ { "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" + "value": "TopDownMovementBehavior::SimulateStick" }, "parameters": [ "Object", - "PhysicsCharacter3D" + "TopDownMovement", + "SpriteMultitouchJoystick::StickAngle(Object.Behavior::PropertyControllerIdentifier(), Object.Behavior::PropertyJoystickIdentifier())", + "SpriteMultitouchJoystick::StickForce(Object.Behavior::PropertyControllerIdentifier(), Object.Behavior::PropertyJoystickIdentifier())" ] } ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::Platformer3DMultitouchMapper", - "type": "behavior" - } - ], - "objectGroups": [] - } - ], - "propertyDescriptors": [ - { - "value": "", - "type": "Behavior", - "label": "3D physics character", - "description": "", - "group": "", - "extraInformation": [ - "Physics3D::PhysicsCharacter3D" - ], - "name": "PhysicsCharacter3D" - }, - { - "value": "1", - "type": "Number", - "label": "Controller identifier (1, 2, 3, 4...)", - "description": "", - "group": "", - "extraInformation": [], - "name": "ControllerIdentifier" - }, - { - "value": "Primary", - "type": "Choice", - "label": "Walk joystick", - "description": "", - "group": "Controls", - "extraInformation": [ - "Primary", - "Secondary" - ], - "name": "JoystickIdentifier" - }, - { - "value": "A", - "type": "String", - "label": "Jump button name", - "description": "", - "group": "Controls", - "extraInformation": [], - "name": "JumpButton" - } - ], - "sharedPropertyDescriptors": [] - }, - { - "description": "Control a 3D physics character with a multitouch controller.", - "fullName": "3D shooter multitouch controller mapper", - "name": "Shooter3DMultitouchMapper", - "objectType": "", - "eventsFunctions": [ - { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", - "events": [ { "type": "BuiltinCommonInstructions::Standard", "conditions": [ { "type": { - "value": "SpriteMultitouchJoystick::StickForce" - }, - "parameters": [ - "", - ">", - "0", - "ControllerIdentifier", - "JoystickIdentifier", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateStick" + "value": "SpriteMultitouchJoystick::TopDownMultitouchMapper::PropertyStickMode" }, "parameters": [ "Object", - "PhysicsCharacter3D", - "SpriteMultitouchJoystick::StickAngle(ControllerIdentifier, JoystickIdentifier)", - "SpriteMultitouchJoystick::StickForce(ControllerIdentifier, JoystickIdentifier)" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsButtonPressed" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JumpButton", - "\"Down\"" + "Behavior", + "=", + "\"360°\"" ] } ], "actions": [ { "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" + "value": "TopDownMovementBehavior::SimulateStick" }, "parameters": [ "Object", - "PhysicsCharacter3D" + "TopDownMovement", + "SpriteMultitouchJoystick::StickAngle(Object.Behavior::PropertyControllerIdentifier(), Object.Behavior::PropertyJoystickIdentifier())", + "sign(SpriteMultitouchJoystick::StickForce(Object.Behavior::PropertyControllerIdentifier(), Object.Behavior::PropertyJoystickIdentifier()))" ] } ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::Shooter3DMultitouchMapper", - "type": "behavior" - } - ], - "objectGroups": [] - } - ], - "propertyDescriptors": [ - { - "value": "", - "type": "Behavior", - "label": "3D physics character", - "description": "", - "group": "", - "extraInformation": [ - "Physics3D::PhysicsCharacter3D" - ], - "name": "PhysicsCharacter3D" - }, - { - "value": "1", - "type": "Number", - "label": "Controller identifier (1, 2, 3, 4...)", - "description": "", - "group": "", - "extraInformation": [], - "name": "ControllerIdentifier" - }, - { - "value": "Primary", - "type": "Choice", - "label": "Walk joystick", - "description": "", - "group": "Controls", - "extraInformation": [ - "Primary", - "Secondary" - ], - "name": "JoystickIdentifier" - }, - { - "value": "A", - "type": "String", - "label": "Jump button name", - "description": "", - "group": "Controls", - "extraInformation": [], - "name": "JumpButton" - } - ], - "sharedPropertyDescriptors": [] - }, - { - "description": "Control camera rotations with a multitouch controller.", - "fullName": "First person camera multitouch controller mapper", - "name": "FirstPersonMultitouchMapper", - "objectType": "", - "eventsFunctions": [ - { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "TODO It's probably a bad idea to rotate the object around Y." }, { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyCurrentRotationSpeedZ" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "SpriteMultitouchJoystick::AcceleratedSpeed(CurrentRotationSpeedZ, SpriteMultitouchJoystick::StickForceX(ControllerIdentifier, CameraStick) * HorizontalRotationSpeedMax, HorizontalRotationSpeedMax, HorizontalRotationAcceleration, HorizontalRotationDeceleration)" - ] - }, - { - "type": { - "value": "SetAngle" - }, - "parameters": [ - "Object", - "+", - "CurrentRotationSpeedZ * TimeDelta()" - ] - }, + "conditions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyCurrentRotationSpeedY" + "value": "SpriteMultitouchJoystick::TopDownMultitouchMapper::PropertyStickMode" }, "parameters": [ "Object", "Behavior", "=", - "SpriteMultitouchJoystick::AcceleratedSpeed(CurrentRotationSpeedY, SpriteMultitouchJoystick::StickForceY(ControllerIdentifier, CameraStick) * VerticalRotationSpeedMax, VerticalRotationSpeedMax, VerticalRotationAcceleration, VerticalRotationDeceleration)" - ] - }, - { - "type": { - "value": "Scene3D::Base3DBehavior::SetRotationY" - }, - "parameters": [ - "Object", - "Object3D", - "+", - "CurrentRotationSpeedY * TimeDelta()" - ] - }, - { - "type": { - "value": "Scene3D::Base3DBehavior::SetRotationY" - }, - "parameters": [ - "Object", - "Object3D", - "=", - "clamp(Object.Object3D::RotationY(), VerticalAngleMin, VerticalAngleMax)" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::LookFromObjectEyes" - }, - "parameters": [ - "Object", - "Behavior", - "" + "\"8 Directions\"" ] } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "Move the camera to look though _PARAM1_ eyes. The object must look to the right when all its angles are 0 and the top of its head be toward Z+.", - "fullName": "Look through object eyes", - "functionType": "Action", - "group": "Layers and cameras", - "name": "LookFromObjectEyes", - "private": true, - "sentence": "Move the camera to look though _PARAM0_ eyes", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "CentreCamera" - }, - "parameters": [ - "", - "Object", - "", - "Object.Layer()", - "" - ] - }, - { - "type": { - "value": "Scene3D::SetCameraZ" - }, - "parameters": [ - "", - "=", - "Object.Object3D::Z() + Object.Object3D::Depth() + OffsetZ", - "", - "" - ] - }, + ], + "actions": [], + "events": [ { - "type": { - "value": "Scene3D::SetCameraRotationX" - }, - "parameters": [ - "", - "=", - "- Object.Object3D::RotationY() + 90", - "GetArgumentAsString(\"Layer\")", - "" - ] - }, - { - "type": { - "value": "Scene3D::SetCameraRotationY" - }, - "parameters": [ - "", - "=", - "Object.Object3D::RotationX()", - "GetArgumentAsString(\"Layer\")", - "" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "TopDownMovementBehavior::DiagonalsAllowed" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Left\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateLeftKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Right\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateRightKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Up\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateUpKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Down\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateDownKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + } ] }, { - "type": { - "value": "SetCameraAngle" - }, - "parameters": [ - "", - "=", - "Object.Angle() + 90", - "Object.Layer()", - "" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "TopDownMovementBehavior::DiagonalsAllowed" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Left\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateLeftKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Right\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateRightKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Up\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateUpKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"Down\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateDownKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"UpLeft\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateUpKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + }, + { + "type": { + "value": "TopDownMovementBehavior::SimulateLeftKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"UpRight\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateUpKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + }, + { + "type": { + "value": "TopDownMovementBehavior::SimulateRightKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"DownLeft\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateDownKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + }, + { + "type": { + "value": "TopDownMovementBehavior::SimulateLeftKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "", + "Object.Behavior::PropertyControllerIdentifier()", + "Object.Behavior::PropertyJoystickIdentifier()", + "\"DownRight\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "TopDownMovementBehavior::SimulateDownKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + }, + { + "type": { + "value": "TopDownMovementBehavior::SimulateRightKey" + }, + "parameters": [ + "Object", + "TopDownMovement" + ] + } + ] + } ] } ] @@ -13697,58 +13146,81 @@ { "description": "Behavior", "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", + "supplementaryInformation": "SpriteMultitouchJoystick::TopDownMultitouchMapper", "type": "behavior" } ], "objectGroups": [] - }, + } + ], + "propertyDescriptors": [ { - "description": "the maximum horizontal rotation speed of the object.", - "fullName": "Maximum horizontal rotation speed", - "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper horizontal rotation configuration", - "name": "HorizontalRotationSpeedMax", - "sentence": "the maximum horizontal rotation speed", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "HorizontalRotationSpeedMax" - ] - } - ] - } + "value": "", + "type": "Behavior", + "label": "Top-down movement behavior", + "description": "", + "group": "", + "extraInformation": [ + "TopDownMovementBehavior::TopDownMovementBehavior" ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" - } + "name": "TopDownMovement" + }, + { + "value": "1", + "type": "Number", + "label": "Controller identifier (1, 2, 3, 4...)", + "description": "", + "group": "", + "extraInformation": [], + "name": "ControllerIdentifier" + }, + { + "value": "Primary", + "type": "Choice", + "label": "Joystick name", + "description": "", + "group": "", + "extraInformation": [ + "Primary", + "Secondary" ], - "objectGroups": [] + "name": "JoystickIdentifier" }, + { + "value": "Analog", + "type": "Choice", + "label": "Stick mode", + "description": "", + "group": "Controls", + "extraInformation": [ + "Analog", + "360°", + "8 Directions" + ], + "name": "StickMode" + } + ], + "sharedPropertyDescriptors": [] + } + ], + "eventsBasedObjects": [ + { + "areaMaxX": 64, + "areaMaxY": 64, + "areaMaxZ": 64, + "areaMinX": 0, + "areaMinY": 0, + "areaMinZ": 0, + "defaultName": "Joystick", + "description": "Joystick for touchscreens.", + "fullName": "Multitouch Joystick", + "isUsingLegacyInstancesRenderer": true, + "name": "SpriteMultitouchJoystick", + "eventsFunctions": [ { "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "HorizontalRotationSpeedMax", - "name": "SetHorizontalRotationSpeedMax", + "functionType": "Action", + "name": "onCreated", "sentence": "", "events": [ { @@ -13757,40 +13229,108 @@ "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyHorizontalRotationSpeedMax" + "value": "Create" }, "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "", + "Border", + "0", + "0", + "" ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" + }, + { + "type": { + "value": "Create" + }, + "parameters": [ + "", + "Thumb", + "0", + "0", + "" + ] + }, + { + "type": { + "value": "ChangePlan" + }, + "parameters": [ + "Border", + "=", + "1" + ] + }, + { + "type": { + "value": "ChangePlan" + }, + "parameters": [ + "Thumb", + "=", + "2" + ] + }, + { + "type": { + "value": "SetCenter" + }, + "parameters": [ + "Border", + "=", + "0", + "=", + "0" + ] + }, + { + "type": { + "value": "SetCenter" + }, + "parameters": [ + "Thumb", + "=", + "0", + "=", + "0" + ] + }, + { + "type": { + "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::UpdateConfiguration" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "SetIncludedInParentCollisionMask" + }, + "parameters": [ + "Thumb", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", + "type": "object" } ], "objectGroups": [] }, { - "description": "the horizontal rotation acceleration of the object.", - "fullName": "Horizontal rotation acceleration", - "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper horizontal rotation configuration", - "name": "HorizontalRotationAcceleration", - "sentence": "the horizontal rotation acceleration", + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -13798,38 +13338,32 @@ "actions": [ { "type": { - "value": "SetReturnNumber" + "value": "MettreAutour" }, "parameters": [ - "HorizontalRotationAcceleration" + "Thumb", + "Border", + "Border.MultitouchJoystick::JoystickForce() * Border.Width() / 2", + "Border.MultitouchJoystick::JoystickAngle()" ] } ] } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "HorizontalRotationAcceleration", - "name": "SetHorizontalRotationAcceleration", + "functionType": "Action", + "name": "onHotReloading", "sentence": "", "events": [ { @@ -13838,13 +13372,11 @@ "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyHorizontalRotationAcceleration" + "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::UpdateConfiguration" }, "parameters": [ "Object", - "Behavior", - "=", - "Value" + "" ] } ] @@ -13854,24 +13386,19 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "description": "the horizontal rotation deceleration of the object.", - "fullName": "Horizontal rotation deceleration", - "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper horizontal rotation configuration", - "name": "HorizontalRotationDeceleration", - "sentence": "the horizontal rotation deceleration", + "description": "Pass the object property values to the behavior.", + "fullName": "Update configuration", + "functionType": "Action", + "name": "UpdateConfiguration", + "private": true, + "sentence": "Update the configuration of _PARAM0_", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -13879,53 +13406,107 @@ "actions": [ { "type": { - "value": "SetReturnNumber" + "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetControllerIdentifier" + }, + "parameters": [ + "Border", + "MultitouchJoystick", + "=", + "Object.PropertyControllerIdentifier()", + "" + ] + }, + { + "type": { + "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetJoystickIdentifier" + }, + "parameters": [ + "Border", + "MultitouchJoystick", + "=", + "Object.PropertyJoystickIdentifier()", + "" + ] + }, + { + "type": { + "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetDeadZoneRadius" }, "parameters": [ - "HorizontalRotationDeceleration" + "Border", + "MultitouchJoystick", + "=", + "Object.PropertyDeadZoneRadius()", + "" ] } ] } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "HorizontalRotationDeceleration", - "name": "SetHorizontalRotationDeceleration", - "sentence": "", + "description": "De/activate control of the joystick.", + "fullName": "De/activate control", + "functionType": "Action", + "name": "ActivateControl", + "sentence": "Activate control of _PARAM0_: _PARAM1_", "events": [ { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldActivate\"" + ] + } + ], "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyHorizontalRotationDeceleration" + "value": "ActivateBehavior" }, "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "Border", + "MultitouchJoystick", + "no" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldActivate\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "ActivateBehavior" + }, + "parameters": [ + "Border", + "MultitouchJoystick", + "yes" ] } ] @@ -13935,64 +13516,67 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" }, { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" + "description": "Activate", + "name": "ShouldActivate", + "type": "yesorno" } ], "objectGroups": [] }, { - "description": "the maximum vertical rotation speed of the object.", - "fullName": "Maximum vertical rotation speed", - "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper vertical rotation configuration", - "name": "VerticalRotationSpeedMax", - "sentence": "the maximum vertical rotation speed", + "description": "Check if a stick is pressed.", + "fullName": "Stick pressed", + "functionType": "Condition", + "name": "IsPressed", + "sentence": "Stick _PARAM0_ is pressed", "events": [ { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::MultitouchJoystick::IsPressed" + }, + "parameters": [ + "Border", + "MultitouchJoystick", + "!=" + ] + } + ], "actions": [ { "type": { - "value": "SetReturnNumber" + "value": "SetReturnBoolean" }, "parameters": [ - "VerticalRotationSpeedMax" + "True" ] } ] } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalRotationSpeedMax", - "name": "SetVerticalRotationSpeedMax", - "sentence": "", + "description": "the joystick force (from 0 to 1).", + "fullName": "Joystick force (deprecated)", + "functionType": "ExpressionAndCondition", + "name": "JoystickForce", + "private": true, + "sentence": "the joystick force", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -14000,40 +13584,34 @@ "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyVerticalRotationSpeedMax" + "value": "SetReturnNumber" }, "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "Border.MultitouchJoystick::JoystickForce()" ] } ] } ], + "expressionType": { + "type": "expression" + }, "parameters": [ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "description": "the vertical rotation acceleration of the object.", - "fullName": "Vertical rotation acceleration", + "description": "the strick force (from 0 to 1).", + "fullName": "Stick force", "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper vertical rotation configuration", - "name": "VerticalRotationAcceleration", - "sentence": "the vertical rotation acceleration", + "name": "StickForce", + "sentence": "the stick force", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -14044,7 +13622,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "VerticalRotationAcceleration" + "Border.MultitouchJoystick::JoystickForce()" ] } ] @@ -14057,23 +13635,18 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalRotationAcceleration", - "name": "SetVerticalRotationAcceleration", - "sentence": "", + "description": "the stick force on X axis (from -1 at the left to 1 at the right).", + "fullName": "Stick X force", + "functionType": "ExpressionAndCondition", + "name": "StickForceX", + "sentence": "the stick X force", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -14081,40 +13654,34 @@ "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyVerticalRotationAcceleration" + "value": "SetReturnNumber" }, "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "Border.MultitouchJoystick::StickForceX()" ] } ] } ], + "expressionType": { + "type": "expression" + }, "parameters": [ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "description": "the vertical rotation deceleration of the object.", - "fullName": "Vertical rotation deceleration", + "description": "the stick force on Y axis (from -1 at the top to 1 at the bottom).", + "fullName": "Stick Y force", "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper vertical rotation configuration", - "name": "VerticalRotationDeceleration", - "sentence": "the vertical rotation deceleration", + "name": "StickForceY", + "sentence": "the stick Y force", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -14125,7 +13692,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "VerticalRotationDeceleration" + "Border.MultitouchJoystick::StickForceY()" ] } ] @@ -14138,22 +13705,18 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalRotationDeceleration", - "name": "SetVerticalRotationDeceleration", + "description": "Return the angle the joystick is pointing towards (from -180 to 180).", + "fullName": "Joystick angle (deprecated)", + "functionType": "Expression", + "name": "JoystickAngle", + "private": true, "sentence": "", "events": [ { @@ -14162,40 +13725,34 @@ "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyVerticalRotationDeceleration" + "value": "SetReturnNumber" }, "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "Border.MultitouchJoystick::JoystickAngle()" ] } ] } ], + "expressionType": { + "type": "expression" + }, "parameters": [ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "description": "the minimum vertical camera angle of the object.", - "fullName": "Minimum vertical camera angle", - "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper vertical rotation configuration", - "name": "VerticalAngleMin", - "sentence": "the minimum vertical camera angle", + "description": "Return the angle the stick is pointing towards (from -180 to 180).", + "fullName": "Stick angle", + "functionType": "Expression", + "name": "StickAngle", + "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -14206,7 +13763,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "VerticalAngleMin" + "Border.MultitouchJoystick::JoystickAngle()" ] } ] @@ -14219,37 +13776,91 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "description": "Check if joystick is pushed in a given direction.", + "fullName": "Joystick pushed in a direction (4-way movement)", + "functionType": "Condition", + "name": "IsDirectionPushed4Way", + "sentence": "_PARAM0_ is pushed in direction _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::MultitouchJoystick::IsDirectionPushed4Way" + }, + "parameters": [ + "Border", + "MultitouchJoystick", + "GetArgumentAsString(\"Direction\")", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" }, { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" + "description": "Direction", + "name": "Direction", + "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\"]", + "type": "stringWithSelector" } ], "objectGroups": [] }, { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalAngleMin", - "name": "SetVerticalAngleMin", - "sentence": "", + "description": "Check if joystick is pushed in a given direction.", + "fullName": "Joystick pushed in a direction (8-way movement)", + "functionType": "Condition", + "name": "IsDirectionPushed8Way", + "sentence": "_PARAM0_ is pushed in direction _PARAM1_", "events": [ { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], + "conditions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::MultitouchJoystick::IsDirectionPushed8Way" + }, + "parameters": [ + "Border", + "MultitouchJoystick", + "GetArgumentAsString(\"Direction\")", + "" + ] + } + ], "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyVerticalAngleMin" + "value": "SetReturnBoolean" }, "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "True" ] } ] @@ -14259,24 +13870,25 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" }, { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" + "description": "Direction", + "name": "Direction", + "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\",\"UpLeft\",\"UpRight\",\"DownLeft\",\"DownRight\"]", + "type": "stringWithSelector" } ], "objectGroups": [] }, { - "description": "the maximum vertical camera angle of the object.", - "fullName": "Maximum vertical camera angle", + "description": "the multitouch controller identifier (1, 2, 3, 4...).", + "fullName": "Multitouch controller identifier", "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper vertical rotation configuration", - "name": "VerticalAngleMax", - "sentence": "the maximum vertical camera angle", + "group": "Multitouch Joystick configuration", + "name": "ControllerIdentifier", + "sentence": "the multitouch controller identifier", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -14287,7 +13899,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "VerticalAngleMax" + "Border.MultitouchJoystick::PropertyControllerIdentifier()" ] } ] @@ -14300,13 +13912,8 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] @@ -14314,8 +13921,8 @@ { "fullName": "", "functionType": "ActionWithOperator", - "getterName": "VerticalAngleMax", - "name": "SetVerticalAngleMax", + "getterName": "ControllerIdentifier", + "name": "SetControllerIdentifier", "sentence": "", "events": [ { @@ -14324,13 +13931,14 @@ "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyVerticalAngleMax" + "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetControllerIdentifier" }, "parameters": [ - "Object", - "Behavior", + "Border", + "MultitouchJoystick", "=", - "Value" + "GetArgumentAsNumber(\"Value\")", + "" ] } ] @@ -14340,24 +13948,19 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] }, { - "description": "the z position offset of the object.", - "fullName": "Z position offset", + "description": "the joystick name of the object.", + "fullName": "Joystick name", "functionType": "ExpressionAndCondition", - "group": "First person camera multitouch controller mapper position configuration", - "name": "OffsetZ", - "sentence": "the z position offset", + "group": "Multitouch Joystick configuration", + "name": "JoystickIdentifier", + "sentence": "the joystick name", "events": [ { "type": "BuiltinCommonInstructions::Standard", @@ -14365,29 +13968,24 @@ "actions": [ { "type": { - "value": "SetReturnNumber" + "value": "SetReturnString" }, "parameters": [ - "OffsetZ" + "Border.MultitouchJoystick::PropertyJoystickIdentifier()" ] } ] } ], "expressionType": { - "type": "expression" + "type": "string" }, "parameters": [ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] @@ -14395,8 +13993,8 @@ { "fullName": "", "functionType": "ActionWithOperator", - "getterName": "OffsetZ", - "name": "SetOffsetZ", + "getterName": "JoystickIdentifier", + "name": "SetJoystickIdentifier", "sentence": "", "events": [ { @@ -14405,13 +14003,14 @@ "actions": [ { "type": { - "value": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper::SetPropertyOffsetZ" + "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetJoystickIdentifier" }, "parameters": [ - "Object", - "Behavior", + "Border", + "MultitouchJoystick", "=", - "Value" + "GetArgumentAsString(\"Value\")", + "" ] } ] @@ -14421,2079 +14020,1353 @@ { "description": "Object", "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::FirstPersonMultitouchMapper", - "type": "behavior" } ], "objectGroups": [] - } - ], - "propertyDescriptors": [ - { - "value": "", - "type": "Behavior", - "label": "3D capability", - "description": "", - "group": "", - "extraInformation": [ - "Scene3D::Base3DBehavior" - ], - "name": "Object3D" }, { - "value": "1", - "type": "Number", - "label": "Controller identifier (1, 2, 3, 4...)", - "description": "", - "group": "", - "extraInformation": [], - "name": "ControllerIdentifier" - }, - { - "value": "Secondary", - "type": "Choice", - "label": "Camera joystick", - "description": "", - "group": "Controls", - "extraInformation": [ - "Primary", - "Secondary" + "description": "the dead zone radius of the joystick (range: 0 to 1). The deadzone is an area for which movement on sticks won't be taken into account (instead, the stick will be considered as not moved).", + "fullName": "Dead zone radius", + "functionType": "ExpressionAndCondition", + "group": "Multitouch Joystick configuration", + "name": "DeadZoneRadius", + "sentence": "the dead zone radius", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Border.MultitouchJoystick::PropertyDeadZoneRadius()" + ] + } + ] + } ], - "name": "CameraStick" - }, - { - "value": "180", - "type": "Number", - "unit": "AngularSpeed", - "label": "Maximum rotation speed", - "description": "", - "group": "Horizontal rotation", - "extraInformation": [], - "name": "HorizontalRotationSpeedMax" - }, - { - "value": "360", - "type": "Number", - "label": "Rotation acceleration", - "description": "", - "group": "Horizontal rotation", - "extraInformation": [], - "name": "HorizontalRotationAcceleration" - }, - { - "value": "720", - "type": "Number", - "label": "Rotation deceleration", - "description": "", - "group": "Horizontal rotation", - "extraInformation": [], - "name": "HorizontalRotationDeceleration" + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", + "type": "object" + } + ], + "objectGroups": [] }, { - "value": "120", - "type": "Number", - "unit": "AngularSpeed", - "label": "Maximum rotation speed", - "description": "", - "group": "Vertical rotation", - "extraInformation": [], - "name": "VerticalRotationSpeedMax" - }, + "fullName": "", + "functionType": "ActionWithOperator", + "getterName": "DeadZoneRadius", + "name": "SetDeadZoneRadius", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetDeadZoneRadius" + }, + "parameters": [ + "Border", + "MultitouchJoystick", + "=", + "GetArgumentAsNumber(\"Value\")", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", + "type": "object" + } + ], + "objectGroups": [] + } + ], + "propertyDescriptors": [ { - "value": "240", + "value": "1", "type": "Number", - "label": "Rotation acceleration", + "label": "Multitouch controller identifier (1, 2, 3, 4...)", "description": "", - "group": "Vertical rotation", + "group": "", "extraInformation": [], - "name": "VerticalRotationAcceleration" + "name": "ControllerIdentifier" }, { - "value": "480", - "type": "Number", - "label": "Rotation deceleration", + "value": "Primary", + "type": "Choice", + "label": "Joystick name", "description": "", - "group": "Vertical rotation", - "extraInformation": [], - "name": "VerticalRotationDeceleration" + "group": "", + "extraInformation": [ + "Primary", + "Secondary" + ], + "name": "JoystickIdentifier" }, { - "value": "-90", + "value": "0.4", "type": "Number", - "unit": "DegreeAngle", - "label": "Minimum angle", - "description": "", - "group": "Vertical rotation", + "label": "Dead zone radius (range: 0 to 1)", + "description": "The deadzone is an area for which movement on sticks won't be taken into account (instead, the stick will be considered as not moved)", + "group": "", "extraInformation": [], - "name": "VerticalAngleMin" + "name": "DeadZoneRadius" }, { - "value": "90", - "type": "Number", - "unit": "DegreeAngle", - "label": "Maximum angle", - "description": "", - "group": "Vertical rotation", - "extraInformation": [], - "name": "VerticalAngleMax" + "value": "Center-center", + "type": "String", + "label": "", + "description": "Only used by the scene editor.", + "group": "", + "extraInformation": [ + "Thumb" + ], + "hidden": true, + "name": "ThumbAnchorOrigin" }, { - "value": "0", + "value": "Center-center", "type": "Number", - "unit": "Pixel", - "label": "Z position offset", - "description": "", - "group": "Position", + "label": "", + "description": "Only used by the scene editor.", + "group": "", "extraInformation": [], - "name": "OffsetZ" + "hidden": true, + "name": "ThumbAnchorTarget" }, { - "value": "0", - "type": "Number", - "unit": "AngularSpeed", - "label": "Current rotation speed Z", - "description": "", + "value": "true", + "type": "Boolean", + "label": "", + "description": "Only used by the scene editor.", "group": "", - "extraInformation": [], + "extraInformation": [ + "Thumb" + ], "hidden": true, - "name": "CurrentRotationSpeedZ" + "name": "ThumbIsScaledProportionally" }, { - "value": "0", - "type": "Number", - "unit": "AngularSpeed", - "label": "Current rotation speed Y", - "description": "", + "value": "Center-center", + "type": "String", + "label": "", + "description": "Only used by the scene editor.", "group": "", "extraInformation": [], "hidden": true, - "name": "CurrentRotationSpeedY" + "name": "ParentOrigin" } ], - "sharedPropertyDescriptors": [] - }, - { - "description": "Control a top-down character with a multitouch controller.", - "fullName": "Top-down multitouch controller mapper", - "name": "TopDownMultitouchMapper", - "objectType": "", - "eventsFunctions": [ + "objects": [ { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", - "events": [ + "adaptCollisionMaskAutomatically": false, + "assetStoreId": "", + "name": "Thumb", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::TopDownMultitouchMapper::PropertyStickMode" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Analog\"" - ] - } - ], - "actions": [ + "name": "Idle", + "useMultipleDirections": false, + "directions": [ { - "type": { - "value": "TopDownMovementBehavior::SimulateStick" - }, - "parameters": [ - "Object", - "TopDownMovement", - "SpriteMultitouchJoystick::StickAngle(ControllerIdentifier, JoystickIdentifier)", - "SpriteMultitouchJoystick::StickForce(ControllerIdentifier, JoystickIdentifier)" - ] + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [] } ] - }, + } + ] + }, + { + "adaptCollisionMaskAutomatically": false, + "assetStoreId": "", + "name": "Border", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::TopDownMultitouchMapper::PropertyStickMode" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"360°\"" - ] - } - ], - "actions": [ + "name": "MultitouchJoystick", + "type": "SpriteMultitouchJoystick::MultitouchJoystick", + "ControllerIdentifier": 1, + "JoystickIdentifier": "Primary", + "FloatingEnabled": false, + "DeadZoneRadius": 0.4, + "JoystickAngle": 0, + "JoystickForce": 0, + "TouchId": 0, + "TouchIndex": 0 + } + ], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ { - "type": { - "value": "TopDownMovementBehavior::SimulateStick" - }, - "parameters": [ - "Object", - "TopDownMovement", - "SpriteMultitouchJoystick::StickAngle(ControllerIdentifier, JoystickIdentifier)", - "sign(SpriteMultitouchJoystick::StickForce(ControllerIdentifier, JoystickIdentifier))" - ] + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [] } ] - }, + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Thumb" + }, + { + "objectName": "Border" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera3DFarPlaneDistance": 10000, + "camera3DFieldOfView": 45, + "camera3DNearPlaneDistance": 3, + "cameraType": "", + "followBaseLayerCamera": false, + "isLightingLayer": false, + "isLocked": false, + "name": "", + "renderingType": "", + "visibility": true, + "cameras": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::TopDownMultitouchMapper::PropertyStickMode" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"8 Directions\"" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "TopDownMovementBehavior::DiagonalsAllowed" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Left\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateLeftKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Right\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateRightKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Up\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateUpKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed4Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Down\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateDownKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "TopDownMovementBehavior::DiagonalsAllowed" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Left\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateLeftKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Right\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateRightKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Up\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateUpKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"Down\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateDownKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"UpLeft\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateUpKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - }, - { - "type": { - "value": "TopDownMovementBehavior::SimulateLeftKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"UpRight\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateUpKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - }, - { - "type": { - "value": "TopDownMovementBehavior::SimulateRightKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"DownLeft\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateDownKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - }, - { - "type": { - "value": "TopDownMovementBehavior::SimulateLeftKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "", - "ControllerIdentifier", - "JoystickIdentifier", - "\"DownRight\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "TopDownMovementBehavior::SimulateDownKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - }, - { - "type": { - "value": "TopDownMovementBehavior::SimulateRightKey" - }, - "parameters": [ - "Object", - "TopDownMovement" - ] - } - ] - } - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "SpriteMultitouchJoystick::TopDownMultitouchMapper", - "type": "behavior" + "defaultSize": true, + "defaultViewport": true, + "height": 0, + "viewportBottom": 1, + "viewportLeft": 0, + "viewportRight": 1, + "viewportTop": 0, + "width": 0 } ], - "objectGroups": [] + "effects": [] } ], - "propertyDescriptors": [ + "instances": [] + } + ] + }, + { + "author": "Bouh", + "category": "Input", + "extensionNamespace": "", + "fullName": "Gamepads (controllers)", + "helpPath": "/all-features/gamepad", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWdhbWVwYWQtdmFyaWFudC1vdXRsaW5lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTYsOUg4VjExSDEwVjEzSDhWMTVINlYxM0g0VjExSDZWOU0xOC41LDlBMS41LDEuNSAwIDAsMSAyMCwxMC41QTEuNSwxLjUgMCAwLDEgMTguNSwxMkExLjUsMS41IDAgMCwxIDE3LDEwLjVBMS41LDEuNSAwIDAsMSAxOC41LDlNMTUuNSwxMkExLjUsMS41IDAgMCwxIDE3LDEzLjVBMS41LDEuNSAwIDAsMSAxNS41LDE1QTEuNSwxLjUgMCAwLDEgMTQsMTMuNUExLjUsMS41IDAgMCwxIDE1LjUsMTJNMTcsNUE3LDcgMCAwLDEgMjQsMTJBNyw3IDAgMCwxIDE3LDE5QzE1LjA0LDE5IDEzLjI3LDE4LjIgMTIsMTYuOUMxMC43MywxOC4yIDguOTYsMTkgNywxOUE3LDcgMCAwLDEgMCwxMkE3LDcgMCAwLDEgNyw1SDE3TTcsN0E1LDUgMCAwLDAgMiwxMkE1LDUgMCAwLDAgNywxN0M4LjY0LDE3IDEwLjA5LDE2LjIxIDExLDE1SDEzQzEzLjkxLDE2LjIxIDE1LjM2LDE3IDE3LDE3QTUsNSAwIDAsMCAyMiwxMkE1LDUgMCAwLDAgMTcsN0g3WiIgLz48L3N2Zz4=", + "name": "Gamepads", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/gamepad-variant-outline.svg", + "shortDescription": "Add support for gamepads (or other controllers) to your game, giving access to information such as button presses, axis positions, trigger pressure, etc...", + "version": "0.6.1", + "description": [ + "Add support for gamepads (or other controllers).", + "", + "It gives access to:", + "- button presses", + "- axis positions and force", + "- trigger pressure", + "- configurable deadzone", + "- vibration", + "- automatic mappers for platformer characters and top-down movement", + "", + "The Bomberman-like example handles 4 players with gamepads ([open the project online](https://editor.gdevelop.io/?project=example://goose-bomberman))." + ], + "origin": { + "identifier": "Gamepads", + "name": "gdevelop-extension-store" + }, + "tags": [ + "controllers", + "gamepads", + "joysticks", + "axis", + "xbox", + "ps4", + "platformer", + "platform", + "top-down" + ], + "authorIds": [ + "2OwwM8ToR9dx9RJ2sAKTcrLmCB92", + "taRwmWxwAFYFL9yyBwB3cwBw0BO2", + "mnImQKdn8nQxwzkS5D6a1JB27V23" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [ + { + "description": "Get the value of the pressure on a gamepad trigger.", + "fullName": "Pressure on a gamepad trigger", + "functionType": "Expression", + "name": "TriggerPressure", + "sentence": "Player _PARAM1_ push axis _PARAM2_ to _PARAM3_", + "events": [ { - "value": "", - "type": "Behavior", - "label": "Top-down movement behavior", - "description": "", - "group": "", - "extraInformation": [ - "TopDownMovementBehavior::TopDownMovementBehavior" + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const trigger = eventsFunctionContext.getArgument(\"trigger\").toUpperCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in expression: \"Pressure on a gamepad trigger\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "if (trigger != \"LT\" && trigger != \"RT\" && trigger != \"L2\" && trigger != \"R2\") {\r", + " console.error('Parameter trigger is not valid in expression: \"Pressure on a gamepad trigger\"');\r", + " return;\r", + "}\r", + "\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "switch (trigger) {\r", + " case 'LT':\r", + " case 'L2':\r", + " eventsFunctionContext.returnValue = gamepad.buttons[6].value;\r", + " break;\r", + "\r", + " case 'RT':\r", + " case 'R2':\r", + " eventsFunctionContext.returnValue = gamepad.buttons[7].value;\r", + " break;\r", + "\r", + " default:\r", + " eventsFunctionContext.returnValue = -1;\r", + " break;\r", + "}" ], - "name": "TopDownMovement" - }, + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ { - "value": "1", - "type": "Number", - "label": "Controller identifier (1, 2, 3, 4...)", - "description": "", - "group": "", - "extraInformation": [], - "name": "ControllerIdentifier" + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "value": "Primary", - "type": "Choice", - "label": "Joystick name", - "description": "", - "group": "", - "extraInformation": [ - "Primary", - "Secondary" + "description": "Trigger button", + "name": "trigger", + "supplementaryInformation": "[\"LT\",\"RT\",\"L2\",\"R2\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "the force of gamepad stick (from 0 to 1).", + "fullName": "Stick force", + "functionType": "ExpressionAndCondition", + "name": "StickForce", + "sentence": "the gamepad _PARAM1_ _PARAM2_ stick force", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", + "\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a stick force\"');\r", + " return;\r", + "}\r", + "\r", + "if (stick !== \"LEFT\" && stick !== \"RIGHT\") {\r", + " console.error('Parameter stick is not valid in expression: \"Value of a stick force\"');\r", + " return;\r", + "}\r", + "\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "\r", + "switch (stick) {\r", + " case 'LEFT':\r", + " eventsFunctionContext.returnValue = gdjs.evtTools.common.clamp(Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId)) + Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId)), 0, 1);\r", + " break;\r", + "\r", + " case 'RIGHT':\r", + " eventsFunctionContext.returnValue = gdjs.evtTools.common.clamp(Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId)) + Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId)), 0, 1);\r", + " break;\r", + "\r", + " default:\r", + " eventsFunctionContext.returnValue = -1;\r", + " break;\r", + "}" ], - "name": "JoystickIdentifier" + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "value": "Analog", - "type": "Choice", - "label": "Stick mode", - "description": "", - "group": "Controls", - "extraInformation": [ - "Analog", - "360°", - "8 Directions" - ], - "name": "StickMode" + "description": "Stick: \"Left\" or \"Right\"", + "name": "stick", + "supplementaryInformation": "[\"Left\",\"Right\"]", + "type": "stringWithSelector" } ], - "sharedPropertyDescriptors": [] - } - ], - "eventsBasedObjects": [ + "objectGroups": [] + }, { - "areaMaxX": 64, - "areaMaxY": 64, - "areaMaxZ": 64, - "areaMinX": 0, - "areaMinY": 0, - "areaMinZ": 0, - "defaultName": "Joystick", - "description": "Joystick for touchscreens.", - "fullName": "Multitouch Joystick", - "isUsingLegacyInstancesRenderer": true, - "name": "SpriteMultitouchJoystick", - "eventsFunctions": [ + "description": "Get the rotation value of a gamepad stick.\nIf the deadzone value is high, the angle value is rounded to main axes, left, left, up, down.\nAn zero deadzone value give a total freedom on the angle value.", + "fullName": "Value of a stick rotation (deprecated)", + "functionType": "Expression", + "name": "StickRotationValue", + "private": true, + "sentence": "Player _PARAM1_ push axis _PARAM2_ to _PARAM3_", + "events": [ { - "fullName": "", - "functionType": "Action", - "name": "onCreated", - "sentence": "", - "events": [ + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "Create" - }, - "parameters": [ - "", - "Border", - "0", - "0", - "" - ] - }, - { - "type": { - "value": "Create" - }, - "parameters": [ - "", - "Thumb", - "0", - "0", - "" - ] - }, - { - "type": { - "value": "ChangePlan" - }, - "parameters": [ - "Border", - "=", - "1" - ] - }, - { - "type": { - "value": "ChangePlan" - }, - "parameters": [ - "Thumb", - "=", - "2" - ] - }, - { - "type": { - "value": "SetCenter" - }, - "parameters": [ - "Border", - "=", - "0", - "=", - "0" - ] - }, - { - "type": { - "value": "SetCenter" - }, - "parameters": [ - "Thumb", - "=", - "0", - "=", - "0" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::UpdateConfiguration" - }, - "parameters": [ - "Object", - "" - ] - }, - { - "type": { - "value": "SetIncludedInParentCollisionMask" - }, - "parameters": [ - "Thumb", - "" - ] - } + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Gamepads::StickAngle(GetArgumentAsNumber(\"player_ID\"), GetArgumentAsString(\"stick\"))" ] } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] - }, + ] + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ { - "fullName": "", - "functionType": "Action", - "name": "doStepPostEvents", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "MettreAutour" - }, - "parameters": [ - "Thumb", - "Border", - "Border.MultitouchJoystick::JoystickForce() * Border.Width() / 2", - "Border.MultitouchJoystick::JoystickAngle()" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::PropertyShouldBeHiddenWhenReleased" - }, - "parameters": [ - "Object" - ] - }, - { - "type": { - "inverted": true, - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::IsPressed" - }, - "parameters": [ - "Object", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "Cache" - }, - "parameters": [ - "Object" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::ActivateControl" - }, - "parameters": [ - "Object", - "no", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "fullName": "", - "functionType": "Action", - "name": "onHotReloading", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::UpdateConfiguration" - }, - "parameters": [ - "Object", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } + "description": "Stick: \"Left\" or \"Right\"", + "name": "stick", + "supplementaryInformation": "[\"Left\",\"Right\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "Return the angle of a gamepad stick.\nIf the deadzone value is high, the angle value is rounded to main axes, left, left, up, down.\nAn zero deadzone value give a total freedom on the angle value.", + "fullName": "Stick angle", + "functionType": "Expression", + "name": "StickAngle", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", + "\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a stick rotation\"');\r", + " return;\r", + "}\r", + "if (stick !== \"LEFT\" && stick !== \"RIGHT\") {\r", + " console.error('Parameter stick is not valid in expression: \"Value of a stick rotation\"');\r", + " return;\r", + "}\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "switch (stick) {\r", + " case 'LEFT':\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.axisToAngle(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId), gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId));\r", + " break;\r", + "\r", + " case 'RIGHT':\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.axisToAngle(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId), gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId));\r", + " break;\r", + "\r", + " default:\r", + " eventsFunctionContext.returnValue = -1;\r", + " break;\r", + "}" ], - "objectGroups": [] + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "description": "Pass the object property values to the behavior.", - "fullName": "Update configuration", - "functionType": "Action", - "name": "UpdateConfiguration", - "private": true, - "sentence": "Update the configuration of _PARAM0_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetControllerIdentifier" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "=", - "ControllerIdentifier", - "" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetJoystickIdentifier" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "=", - "JoystickIdentifier", - "" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetDeadZoneRadius" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "=", - "DeadZoneRadius", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } + "description": "Stick: \"Left\" or \"Right\"", + "name": "stick", + "supplementaryInformation": "[\"Left\",\"Right\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "Get the value of axis of a gamepad stick.", + "fullName": "Value of a gamepad axis (deprecated)", + "functionType": "Expression", + "name": "AxisValue", + "private": true, + "sentence": "Player _PARAM1_ push axis _PARAM2_ to _PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", + "const direction = eventsFunctionContext.getArgument(\"direction\").toUpperCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a gamepad axis\"');\r", + " return;\r", + "}\r", + "if (stick != \"LEFT\" && stick != \"RIGHT\") {\r", + " console.error('Parameter stick is not valid in expression: \"Value of a gamepad axis\"');\r", + " return;\r", + "}\r", + "if (direction != \"UP\" && direction != \"DOWN\" && direction != \"LEFT\" && direction != \"RIGHT\" && direction != \"HORIZONTAL\" && direction != \"VERTICAL\") {\r", + " console.error('Parameter direction is not valid in expression: \"Value of a gamepad axis\"');\r", + " return;\r", + "}\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "let parameterError = false;\r", + "switch (stick) {\r", + " case 'LEFT':\r", + " switch (direction) {\r", + " case 'LEFT':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId);\r", + " }\r", + " break;\r", + "\r", + " case 'RIGHT':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId);\r", + " }\r", + " break;\r", + "\r", + " case 'UP':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId);\r", + " }\r", + " break;\r", + "\r", + " case 'DOWN':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId);\r", + " }\r", + " break;\r", + "\r", + " case \"HORIZONTAL\":\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId);\r", + " break;\r", + "\r", + " case \"VERTICAL\":\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId);\r", + " break;\r", + "\r", + " default:\r", + " break;\r", + " }\r", + " break;\r", + "\r", + " case 'RIGHT':\r", + " switch (direction) {\r", + " case 'LEFT':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId);\r", + " }\r", + " break;\r", + "\r", + " case 'RIGHT':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId);\r", + " }\r", + " break;\r", + "\r", + " case 'UP':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId);\r", + " }\r", + " break;\r", + "\r", + " case 'DOWN':\r", + " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId);\r", + " }\r", + " break;\r", + "\r", + " case \"HORIZONTAL\":\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId);\r", + " break;\r", + "\r", + " case \"VERTICAL\":\r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId);\r", + " break;\r", + "\r", + " default:\r", + " break;\r", + " }\r", + " break;\r", + "\r", + " default:\r", + " break;\r", + "}\r", + "" ], - "objectGroups": [] + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "description": "Show the joystick until it is released.", - "fullName": "Show and start pressing", - "functionType": "Action", - "name": "TeleportAndPress", - "sentence": "Show _PARAM0_ at the cursor position and start pressing", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "HasAnyTouchOrMouseStarted" - }, - "parameters": [ - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "MettreXY" - }, - "parameters": [ - "Object", - "=", - "Object.ParentTouchX(StartedTouchOrMouseId(0))", - "=", - "Object.ParentTouchY(StartedTouchOrMouseId(0))" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::ActivateControl" - }, - "parameters": [ - "Object", - "yes", - "" - ] - }, - { - "type": { - "value": "Montre" - }, - "parameters": [ - "Object", - "" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::SpriteMultitouchJoystick::SetPropertyShouldBeHiddenWhenReleased" - }, - "parameters": [ - "Object", - "yes" - ] - }, - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::ForceStartPressing" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "StartedTouchOrMouseId(0)", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] + "description": "Stick: \"Left\" or \"Right\"", + "name": "stick", + "supplementaryInformation": "[\"Left\",\"Right\"]", + "type": "stringWithSelector" }, { - "description": "Return the X position of a specified touch", - "fullName": "Touch X position (on parent)", - "functionType": "Expression", - "name": "ParentTouchX", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [] - }, - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "const object = objects[0];", - "const touchId = eventsFunctionContext.getArgument(\"TouchId\");", - "eventsFunctionContext.returnValue = gdjs.evtTools.input.getTouchX(object.getInstanceContainer(), touchId, object.getLayer());" - ], - "parameterObjects": "Object", - "useStrict": true, - "eventsSheetExpanded": false - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - }, - { - "description": "Touch identifier", - "name": "TouchId", - "type": "expression" - } - ], - "objectGroups": [] - }, + "description": "Direction", + "name": "direction", + "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\",\"Horizontal\",\"Vertical\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "Return the gamepad stick force on X axis (from -1 at the left to 1 at the right).", + "fullName": "Stick X force", + "functionType": "Expression", + "name": "StickForceX", + "sentence": "", + "events": [ { - "description": "Return the X position of a specified touch", - "fullName": "Touch X position (on parent)", - "functionType": "Expression", - "name": "ParentTouchY", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [] - }, - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "const object = objects[0];", - "const touchId = eventsFunctionContext.getArgument(\"TouchId\");", - "eventsFunctionContext.returnValue = gdjs.evtTools.input.getTouchY(object.getInstanceContainer(), touchId, object.getLayer());" - ], - "parameterObjects": "Object", - "useStrict": true, - "eventsSheetExpanded": false - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - }, - { - "description": "Touch identifier", - "name": "TouchId", - "type": "expression" - } + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"Gamepad\") - 1;\r", + "const stick = eventsFunctionContext.getArgument(\"Stick\").toLowerCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a gamepad axis\"');\r", + " return;\r", + "}\r", + "if (stick != \"left\" && stick != \"right\") {\r", + " console.error('Parameter stick is not valid in expression: \"Value of a gamepad axis\"');\r", + " return;\r", + "}\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "const axisIndex = stick === 'right' ? 2 : 0;\r", + "eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[axisIndex], playerId);\r", + "" ], - "objectGroups": [] - }, + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ { - "description": "De/activate control of the joystick.", - "fullName": "De/activate control", - "functionType": "Action", - "name": "ActivateControl", - "sentence": "Activate control of _PARAM0_: _PARAM1_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "inverted": true, - "value": "GetArgumentAsBoolean" - }, - "parameters": [ - "\"ShouldActivate\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "ActivateBehavior" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "no" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "GetArgumentAsBoolean" - }, - "parameters": [ - "\"ShouldActivate\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "ActivateBehavior" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "yes" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - }, - { - "description": "Activate", - "name": "ShouldActivate", - "type": "yesorno" - } - ], - "objectGroups": [] + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "Gamepad", + "type": "expression" }, { - "description": "Check if a stick is pressed.", - "fullName": "Stick pressed", - "functionType": "Condition", - "name": "IsPressed", - "sentence": "Stick _PARAM0_ is pressed", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::IsPressed" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "!=" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] - }, + "description": "Stick: \"Left\" or \"Right\"", + "name": "Stick", + "supplementaryInformation": "[\"Left\",\"Right\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "Return the gamepad stick force on Y axis (from -1 at the top to 1 at the bottom).", + "fullName": "Stick Y force", + "functionType": "Expression", + "name": "StickForceY", + "sentence": "", + "events": [ { - "description": "the joystick force (from 0 to 1).", - "fullName": "Joystick force (deprecated)", - "functionType": "ExpressionAndCondition", - "name": "JoystickForce", - "private": true, - "sentence": "the joystick force", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::JoystickForce()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"Gamepad\") - 1;\r", + "const stick = eventsFunctionContext.getArgument(\"Stick\").toLowerCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a gamepad axis\"');\r", + " return;\r", + "}\r", + "if (stick != \"left\" && stick != \"right\") {\r", + " console.error('Parameter stick is not valid in expression: \"Value of a gamepad axis\"');\r", + " return;\r", + "}\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "const axisIndex = stick === 'right' ? 3 : 1;\r", + "eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[axisIndex], playerId);\r", + "" ], - "objectGroups": [] + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "Gamepad", + "type": "expression" }, { - "description": "the strick force (from 0 to 1).", - "fullName": "Stick force", - "functionType": "ExpressionAndCondition", - "name": "StickForce", - "sentence": "the stick force", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::JoystickForce()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } + "description": "Stick: \"Left\" or \"Right\"", + "name": "Stick", + "supplementaryInformation": "[\"Left\",\"Right\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "Test if a button is released on a gamepad. Buttons can be:\n* Xbox: \"A\", \"B\", \"X\", \"Y\", \"LB\", \"RB\", \"LT\", \"RT\", \"BACK\", \"START\",\n* PS4: \"CROSS\", \"SQUARE\", \"CIRCLE\", \"TRIANGLE\", \"L1\", \"L2\", \"R1\", \"R2\", \"SHARE\", \"OPTIONS\", \"PS_BUTTON\", \"CLICK_TOUCHPAD\",\n* Other: \"UP\", \"DOWN\", \"LEFT\", \"RIGHT\", \"CLICK_STICK_LEFT\", \"CLICK_STICK_RIGHT\".", + "fullName": "Gamepad button released", + "functionType": "Condition", + "name": "C_Button_released", + "sentence": "Button _PARAM2_ of gamepad _PARAM1_ is released", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const button = eventsFunctionContext.getArgument(\"button\").toUpperCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in condition: \"Gamepad button released\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "if (button === \"\") {\r", + " console.error('Parameter button is not valid in condition: \"Gamepad button released\"');\r", + " return;\r", + "}\r", + "\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "let buttonId;\r", + "\r", + "switch (button) {\r", + " case 'A':\r", + " case 'CROSS':\r", + " buttonId = 0;\r", + " break;\r", + " case 'B':\r", + " case 'CIRCLE':\r", + " buttonId = 1;\r", + " break;\r", + " case 'X':\r", + " case 'SQUARE':\r", + " buttonId = 2;\r", + " break;\r", + " case 'Y':\r", + " case 'TRIANGLE':\r", + " buttonId = 3;\r", + " break;\r", + " case 'LB':\r", + " case 'L1':\r", + " buttonId = 4;\r", + " break;\r", + " case 'RB':\r", + " case 'R1':\r", + " buttonId = 5;\r", + " break;\r", + " case 'LT':\r", + " case 'L2':\r", + " buttonId = 6;\r", + " break;\r", + " case 'RT':\r", + " case 'R2':\r", + " buttonId = 7;\r", + " break;\r", + "\r", + " case 'UP':\r", + " buttonId = 12;\r", + " break;\r", + " case 'DOWN':\r", + " buttonId = 13;\r", + " break;\r", + " case 'LEFT':\r", + " buttonId = 14;\r", + " break;\r", + " case 'RIGHT':\r", + " buttonId = 15;\r", + " break;\r", + "\r", + " case 'BACK':\r", + " case 'SHARE':\r", + " buttonId = 8;\r", + " break;\r", + " case 'START':\r", + " case 'OPTIONS':\r", + " buttonId = 9;\r", + " break;\r", + "\r", + " case 'CLICK_STICK_LEFT':\r", + " buttonId = 10;\r", + " break;\r", + " case 'CLICK_STICK_RIGHT':\r", + " buttonId = 11;\r", + " break;\r", + "\r", + " //PS4\r", + " case 'PS_BUTTON':\r", + " buttonId = 16;\r", + " break;\r", + " case 'CLICK_TOUCHPAD':\r", + " buttonId = 17;\r", + " break;\r", + "\r", + " default:\r", + " console.error('The button: ' + button + ' in condition: \"Gamepad button released\" is not valid.');\r", + " break;\r", + "}\r", + "\r", + "if (buttonId === undefined) {\r", + " console.error('There is no buttons valid in condition: \"Gamepad button released\"');\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", + "}\r", + "\r", + "if (gamepad.buttons == null || gamepad.buttons[buttonId] == null) {\r", + " console.error('Buttons on the gamepad are not accessible in condition: \"Gamepad button released\"');\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", + "}\r", + "\r", + "//Define default value on pressed button or use previous value\r", + "gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] || { pressed: false };\r", + "\r", + "//Get state of button at previous frame\r", + "const previousStateButton = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed;\r", + "\r", + "//When previousStateButton is true and actual button state is not pressed\r", + "//Player have release the button\r", + "if (previousStateButton === true && gamepad.buttons[buttonId].pressed === false) {\r", + " // Save the last button used for the player \r", + " gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", + " gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = true;\r", + " eventsFunctionContext.returnValue = true;\r", + "\r", + "} else {\r", + " gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = false;\r", + " eventsFunctionContext.returnValue = false;\r", + "}\r", + "" ], - "objectGroups": [] + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "description": "the stick force on X axis (from -1 at the left to 1 at the right).", - "fullName": "Stick X force", - "functionType": "ExpressionAndCondition", - "name": "StickForceX", - "sentence": "the stick X force", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::StickForceX()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] - }, + "description": "Name of the button", + "name": "button", + "supplementaryInformation": "[\"A\",\"Cross\",\"B\",\"Circle\",\"X\",\"Square\",\"Y\",\"Triangle\",\"LB\",\"L1\",\"RB\",\"R1\",\"LT\",\"L2\",\"RT\",\"R2\",\"Up\",\"Down\",\"Left\",\"Right\",\"Back\",\"Share\",\"Start\",\"Options\",\"Click_Stick_Left\",\"Click_Stick_Right\",\"PS_Button\",\"Click_Touchpad\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "Return the index of the last pressed button of a gamepad.", + "fullName": "Last pressed button (id)", + "functionType": "Expression", + "name": "LastButtonID", + "sentence": "", + "events": [ { - "description": "the stick force on Y axis (from -1 at the top to 1 at the bottom).", - "fullName": "Stick Y force", - "functionType": "ExpressionAndCondition", - "name": "StickForceY", - "sentence": "the stick Y force", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::StickForceY()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "//Get function parameter\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "\r", + "//Player id is not valid\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in expression: \"Last pressed button (id)\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "\r", + "//Return the last button used by the player\r", + "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].lastButtonUsed;" ], - "objectGroups": [] - }, + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ { - "description": "Return the angle the joystick is pointing towards (from -180 to 180).", - "fullName": "Joystick angle (deprecated)", - "functionType": "Expression", - "name": "JoystickAngle", - "private": true, - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::JoystickAngle()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] - }, + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Check if any button is pressed on a gamepad.", + "fullName": "Any gamepad button pressed", + "functionType": "Condition", + "name": "C_Any_Button_pressed", + "sentence": "Any button of gamepad _PARAM1_ is pressed", + "events": [ { - "description": "Return the angle the stick is pointing towards (from -180 to 180).", - "fullName": "Stick angle", - "functionType": "Expression", - "name": "StickAngle", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::JoystickAngle()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameter\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in condition: \"Any gamepad button pressed\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "let buttonId;\r", + "for (let i = 0; i < gamepad.buttons.length; i++) { //For each buttons\r", + " if (gamepad.buttons[i].pressed) { //One of them is pressed\r", + " buttonId = i; //Save the button pressed\r", + " break;\r", + " }\r", + "}\r", + "\r", + "if (buttonId === undefined) {\r", + " // No buttons are pressed.\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", + "}\r", + "\r", + "if (gamepad.buttons == null || gamepad.buttons[buttonId] == null) {\r", + " console.error('Buttons on the gamepad are not accessible in condition: \"Any gamepad button pressed\"');\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", + "}\r", + "\r", + "//When a button is pressed, save the button in lastButtonUsed for each players\r", + "if (gamepad.buttons[buttonId].pressed) gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", + "eventsFunctionContext.returnValue = gamepad.buttons[buttonId].pressed;\r", + "\r", + "\r", + "" ], - "objectGroups": [] - }, + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ { - "description": "Check if joystick is pushed in a given direction.", - "fullName": "Joystick pushed in a direction (4-way movement)", - "functionType": "Condition", - "name": "IsDirectionPushed4Way", - "sentence": "_PARAM0_ is pushed in direction _PARAM1_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::IsDirectionPushed4Way" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "Direction", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - }, - { - "description": "Direction", - "name": "Direction", - "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\"]", - "type": "stringWithSelector" - } - ], - "objectGroups": [] - }, + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Return the last button pressed. \nButtons for Xbox and PS4 can be:\n* Xbox: \"A\", \"B\", \"X\", \"Y\", \"LB\", \"RB\", \"LT\", \"RT\", \"BACK\", \"START\",\n* PS4: \"CROSS\", \"SQUARE\", \"CIRCLE\", \"TRIANGLE\", \"L1\", \"L2\", \"R1\", \"R2\", \"SHARE\", \"OPTIONS\", \"PS_BUTTON\", \"CLICK_TOUCHPAD\",\n* Both: \"UP\", \"DOWN\", \"LEFT\", \"RIGHT\", \"CLICK_STICK_LEFT\", \"CLICK_STICK_RIGHT\".", + "fullName": "Last pressed button (string)", + "functionType": "StringExpression", + "name": "LastButtonString", + "sentence": "Button _PARAM2_ of gamepad _PARAM1_ is pressed", + "events": [ { - "description": "Check if joystick is pushed in a given direction.", - "fullName": "Joystick pushed in a direction (8-way movement)", - "functionType": "Condition", - "name": "IsDirectionPushed8Way", - "sentence": "_PARAM0_ is pushed in direction _PARAM1_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::IsDirectionPushed8Way" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "Direction", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetReturnBoolean" - }, - "parameters": [ - "True" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - }, - { - "description": "Direction", - "name": "Direction", - "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\",\"UpLeft\",\"UpRight\",\"DownLeft\",\"DownRight\"]", - "type": "stringWithSelector" - } + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const controllerType = eventsFunctionContext.getArgument(\"controller_type\").toUpperCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in string expression: \"Last pressed button (LastButtonString)\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "if (controllerType === \"\") {\r", + " console.error('Parameter controller type is not valid in string expression: \"Last pressed button (LastButtonString)\"');\r", + " return;\r", + "}\r", + "\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "if (gamepad !== null) { //Gamepad exist\r", + " //Get last btn id\r", + " const lastButtonUsedID = gdjs._extensionController.players[playerId].lastButtonUsed;\r", + "\r", + " //Return last button as string \r", + " eventsFunctionContext.returnValue = gdjs._extensionController.getInputString(controllerType, lastButtonUsedID);\r", + "\r", + "} else { //Gamepad dosen't exist\r", + " console.error('Your controller is not supported or the gamepad wasn\\'t detected in string expression: \"Last pressed button (LastButtonString)\"');\r", + " eventsFunctionContext.returnValue = \"Gamepad not connected\";\r", + "}" ], - "objectGroups": [] - }, + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ { - "description": "the multitouch controller identifier (1, 2, 3, 4...).", - "fullName": "Multitouch controller identifier", - "functionType": "ExpressionAndCondition", - "group": "Multitouch Joystick configuration", - "name": "ControllerIdentifier", - "sentence": "the multitouch controller identifier", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::PropertyControllerIdentifier()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "ControllerIdentifier", - "name": "SetControllerIdentifier", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetControllerIdentifier" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "=", - "Value", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] - }, + "description": "Controller type", + "name": "controller_type", + "supplementaryInformation": "[\"Xbox\",\"PS4\"]", + "type": "stringWithSelector" + } + ], + "objectGroups": [] + }, + { + "description": "Return the number of gamepads.", + "fullName": "Gamepad count", + "functionType": "Expression", + "name": "GamepadCount", + "sentence": "", + "events": [ { - "description": "the joystick name of the object.", - "fullName": "Joystick name", - "functionType": "ExpressionAndCondition", - "group": "Multitouch Joystick configuration", - "name": "JoystickIdentifier", - "sentence": "the joystick name", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnString" - }, - "parameters": [ - "Border.MultitouchJoystick::PropertyJoystickIdentifier()" - ] - } - ] - } - ], - "expressionType": { - "type": "string" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get the last activated controller\r", + "const controllerId = gdjs._extensionController.lastActiveController;\r", + "\r", + "// Check if controller is active\r", + "const gamepad = gamepads[controllerId];\r", + "if (gamepad == null) {\r", + " eventsFunctionContext.returnValue = 0;\r", + "} else {\r", + " // Return active controller id\r", + " eventsFunctionContext.returnValue = controllerId + 1;\r", + "}\r", + "" ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "JoystickIdentifier", - "name": "SetJoystickIdentifier", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetJoystickIdentifier" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "=", - "Value", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] - }, - { - "description": "the dead zone radius of the joystick (range: 0 to 1). The deadzone is an area for which movement on sticks won't be taken into account (instead, the stick will be considered as not moved).", - "fullName": "Dead zone radius", - "functionType": "ExpressionAndCondition", - "group": "Multitouch Joystick configuration", - "name": "DeadZoneRadius", - "sentence": "the dead zone radius", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Border.MultitouchJoystick::PropertyDeadZoneRadius()" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "DeadZoneRadius", - "name": "SetDeadZoneRadius", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SpriteMultitouchJoystick::MultitouchJoystick::SetDeadZoneRadius" - }, - "parameters": [ - "Border", - "MultitouchJoystick", - "=", - "Value", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "supplementaryInformation": "SpriteMultitouchJoystick::SpriteMultitouchJoystick", - "type": "object" - } - ], - "objectGroups": [] + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true } ], - "propertyDescriptors": [ - { - "value": "1", - "type": "Number", - "label": "Multitouch controller identifier (1, 2, 3, 4...)", - "description": "", - "group": "", - "extraInformation": [], - "name": "ControllerIdentifier" - }, - { - "value": "Primary", - "type": "Choice", - "label": "Joystick name", - "description": "", - "group": "", - "extraInformation": [ - "Primary", - "Secondary" - ], - "name": "JoystickIdentifier" - }, - { - "value": "0.4", - "type": "Number", - "label": "Dead zone radius (range: 0 to 1)", - "description": "The deadzone is an area for which movement on sticks won't be taken into account (instead, the stick will be considered as not moved)", - "group": "", - "extraInformation": [], - "name": "DeadZoneRadius" - }, - { - "value": "Center-center", - "type": "String", - "label": "", - "description": "Only used by the scene editor.", - "group": "", - "extraInformation": [ - "Thumb" - ], - "hidden": true, - "name": "ThumbAnchorOrigin" - }, - { - "value": "Center-center", - "type": "Number", - "label": "", - "description": "Only used by the scene editor.", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "ThumbAnchorTarget" - }, + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Check if a button is pressed on a gamepad. \nButtons can be:\n* Xbox: \"A\", \"B\", \"X\", \"Y\", \"LB\", \"RB\", \"LT\", \"RT\", \"BACK\", \"START\",\n* PS4: \"CROSS\", \"SQUARE\", \"CIRCLE\", \"TRIANGLE\", \"L1\", \"L2\", \"R1\", \"R2\", \"SHARE\", \"OPTIONS\", \"PS_BUTTON\", \"CLICK_TOUCHPAD\",\n* Other: \"UP\", \"DOWN\", \"LEFT\", \"RIGHT\", \"CLICK_STICK_LEFT\", \"CLICK_STICK_RIGHT\".", + "fullName": "Gamepad button pressed", + "functionType": "Condition", + "name": "C_Button_pressed", + "sentence": "Button _PARAM2_ of gamepad _PARAM1_ is pressed", + "events": [ { - "value": "true", - "type": "Boolean", - "label": "", - "description": "Only used by the scene editor.", - "group": "", - "extraInformation": [ - "Thumb" + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const button = eventsFunctionContext.getArgument(\"button\").toUpperCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in condition: \"Gamepad button pressed\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "if (button === \"\") {\r", + " console.error('Parameter button is not valid in condition: \"Gamepad button pressed\"');\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", + "}\r", + "\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) return;\r", + "\r", + "let buttonId;\r", + "\r", + "switch (button) {\r", + " case 'A':\r", + " case 'CROSS':\r", + " buttonId = 0;\r", + " break;\r", + " case 'B':\r", + " case 'CIRCLE':\r", + " buttonId = 1;\r", + " break;\r", + " case 'X':\r", + " case 'SQUARE':\r", + " buttonId = 2;\r", + " break;\r", + " case 'Y':\r", + " case 'TRIANGLE':\r", + " buttonId = 3;\r", + " break;\r", + " case 'LB':\r", + " case 'L1':\r", + " buttonId = 4;\r", + " break;\r", + " case 'RB':\r", + " case 'R1':\r", + " buttonId = 5;\r", + " break;\r", + " case 'LT':\r", + " case 'L2':\r", + " buttonId = 6;\r", + " break;\r", + " case 'RT':\r", + " case 'R2':\r", + " buttonId = 7;\r", + " break;\r", + "\r", + " case 'UP':\r", + " buttonId = 12;\r", + " break;\r", + " case 'DOWN':\r", + " buttonId = 13;\r", + " break;\r", + " case 'LEFT':\r", + " buttonId = 14;\r", + " break;\r", + " case 'RIGHT':\r", + " buttonId = 15;\r", + " break;\r", + "\r", + " case 'BACK':\r", + " case 'SHARE':\r", + " buttonId = 8;\r", + " break;\r", + " case 'START':\r", + " case 'OPTIONS':\r", + " buttonId = 9;\r", + " break;\r", + "\r", + " case 'CLICK_STICK_LEFT':\r", + " buttonId = 10;\r", + " break;\r", + " case 'CLICK_STICK_RIGHT':\r", + " buttonId = 11;\r", + " break;\r", + "\r", + " //PS4\r", + " case 'PS_BUTTON':\r", + " buttonId = 16;\r", + " break;\r", + " case 'CLICK_TOUCHPAD':\r", + " buttonId = 17;\r", + " break;\r", + "\r", + " default:\r", + " console.error('The button: ' + button + ' in condition: \"Gamepad button pressed\" is not valid.');\r", + " eventsFunctionContext.returnValue = false;\r", + " break;\r", + "}\r", + "\r", + "\r", + "\r", + "if (buttonId === undefined) {\r", + " console.error('There is no buttons valid in condition: \"Gamepad button pressed\"');\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", + "}\r", + "\r", + "if (gamepad.buttons == null || gamepad.buttons[buttonId] == null) {\r", + " console.error('Buttons on the gamepad are not accessible in condition: \"Gamepad button pressed\"');\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", + "}\r", + "\r", + "//When a button is pressed, save the button in lastButtonUsed for each players\r", + "if (gamepad.buttons[buttonId].pressed) gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", + "eventsFunctionContext.returnValue = gamepad.buttons[buttonId].pressed;\r", + "\r", + "\r", + "\r", + "" ], - "hidden": true, - "name": "ThumbIsScaledProportionally" - }, - { - "value": "Center-center", - "type": "String", - "label": "", - "description": "Only used by the scene editor.", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "ParentOrigin" - }, - { - "value": "", - "type": "Boolean", - "label": "", - "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "ShouldBeHiddenWhenReleased" + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true } ], - "objects": [ + "parameters": [ { - "adaptCollisionMaskAutomatically": false, - "assetStoreId": "", - "name": "Thumb", - "type": "Sprite", - "updateIfNotVisible": false, - "variables": [], - "effects": [], - "behaviors": [], - "animations": [ - { - "name": "Idle", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [] - } - ] - } - ] + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" }, { - "adaptCollisionMaskAutomatically": false, - "assetStoreId": "", - "name": "Border", - "type": "Sprite", - "updateIfNotVisible": false, - "variables": [], - "effects": [], - "behaviors": [ - { - "name": "MultitouchJoystick", - "type": "SpriteMultitouchJoystick::MultitouchJoystick", - "ControllerIdentifier": 1, - "JoystickIdentifier": "Primary", - "FloatingEnabled": false, - "DeadZoneRadius": 0.4, - "JoystickAngle": 0, - "JoystickForce": 0, - "TouchId": 0, - "TouchIndex": 0 - } - ], - "animations": [ - { - "name": "Idle", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [] - } - ] - } - ] - } - ], - "objectsFolderStructure": { - "folderName": "__ROOT", - "children": [ - { - "objectName": "Thumb" - }, - { - "objectName": "Border" - } - ] - }, - "objectsGroups": [], - "layers": [ - { - "ambientLightColorB": 200, - "ambientLightColorG": 200, - "ambientLightColorR": 200, - "camera3DFarPlaneDistance": 10000, - "camera3DFieldOfView": 45, - "camera3DNearPlaneDistance": 3, - "cameraType": "", - "followBaseLayerCamera": false, - "isLightingLayer": false, - "isLocked": false, - "name": "", - "renderingType": "", - "visibility": true, - "cameras": [ - { - "defaultSize": true, - "defaultViewport": true, - "height": 0, - "viewportBottom": 1, - "viewportLeft": 0, - "viewportRight": 1, - "viewportTop": 0, - "width": 0 - } - ], - "effects": [] + "description": "Name of the button", + "name": "button", + "supplementaryInformation": "[\"A\",\"Cross\",\"B\",\"Circle\",\"X\",\"Square\",\"Y\",\"Triangle\",\"LB\",\"L1\",\"RB\",\"R1\",\"LT\",\"L2\",\"RT\",\"R2\",\"Up\",\"Down\",\"Left\",\"Right\",\"Back\",\"Share\",\"Start\",\"Options\",\"Click_Stick_Left\",\"Click_Stick_Right\",\"PS_Button\",\"Click_Touchpad\"]", + "type": "stringWithSelector" } ], - "instances": [] - } - ] - }, - { - "author": "Bouh", - "category": "Input", - "extensionNamespace": "", - "fullName": "Gamepads (controllers)", - "helpPath": "/all-features/gamepad", - "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWdhbWVwYWQtdmFyaWFudC1vdXRsaW5lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTYsOUg4VjExSDEwVjEzSDhWMTVINlYxM0g0VjExSDZWOU0xOC41LDlBMS41LDEuNSAwIDAsMSAyMCwxMC41QTEuNSwxLjUgMCAwLDEgMTguNSwxMkExLjUsMS41IDAgMCwxIDE3LDEwLjVBMS41LDEuNSAwIDAsMSAxOC41LDlNMTUuNSwxMkExLjUsMS41IDAgMCwxIDE3LDEzLjVBMS41LDEuNSAwIDAsMSAxNS41LDE1QTEuNSwxLjUgMCAwLDEgMTQsMTMuNUExLjUsMS41IDAgMCwxIDE1LjUsMTJNMTcsNUE3LDcgMCAwLDEgMjQsMTJBNyw3IDAgMCwxIDE3LDE5QzE1LjA0LDE5IDEzLjI3LDE4LjIgMTIsMTYuOUMxMC43MywxOC4yIDguOTYsMTkgNywxOUE3LDcgMCAwLDEgMCwxMkE3LDcgMCAwLDEgNyw1SDE3TTcsN0E1LDUgMCAwLDAgMiwxMkE1LDUgMCAwLDAgNywxN0M4LjY0LDE3IDEwLjA5LDE2LjIxIDExLDE1SDEzQzEzLjkxLDE2LjIxIDE1LjM2LDE3IDE3LDE3QTUsNSAwIDAsMCAyMiwxMkE1LDUgMCAwLDAgMTcsN0g3WiIgLz48L3N2Zz4=", - "name": "Gamepads", - "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/gamepad-variant-outline.svg", - "shortDescription": "Add support for gamepads (or other controllers) to your game, giving access to information such as button presses, axis positions, trigger pressure, etc...", - "version": "0.6.3", - "description": [ - "Add support for gamepads (or other controllers).", - "", - "It gives access to:", - "- button presses", - "- axis positions and force", - "- trigger pressure", - "- configurable deadzone", - "- vibration", - "- automatic mappers for platformer characters and top-down movement", - "", - "The Bomberman-like example handles 4 players with gamepads ([open the project online](https://editor.gdevelop.io/?project=example://goose-bomberman))." - ], - "origin": { - "identifier": "Gamepads", - "name": "gdevelop-extension-store" - }, - "tags": [ - "controllers", - "gamepads", - "joysticks", - "axis", - "xbox", - "ps4", - "platformer", - "platform", - "top-down" - ], - "authorIds": [ - "2OwwM8ToR9dx9RJ2sAKTcrLmCB92", - "taRwmWxwAFYFL9yyBwB3cwBw0BO2", - "mnImQKdn8nQxwzkS5D6a1JB27V23" - ], - "dependencies": [], - "globalVariables": [], - "sceneVariables": [], - "eventsFunctions": [ + "objectGroups": [] + }, { - "fullName": "", - "functionType": "Action", - "name": "onFirstSceneLoaded", + "description": "Return the value of the deadzone applied to a gamepad sticks, between 0 and 1.", + "fullName": "Gamepad deadzone for sticks", + "functionType": "Expression", + "name": "Deadzone", "sentence": "", "events": [ { @@ -16504,134 +15377,254 @@ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "//Define an new private object javascript for the gamepad extension\r", - "gdjs._extensionController = {\r", - " players: {\r", - " 0: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", - " 1: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", - " 2: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", - " 3: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", - " },\r", - " lastActiveController: -1, // Last active controller\r", - " controllerButtonNames: { //Map associating controller button ids to button names\r", - " \"XBOX\": {\r", - " 0: \"A\",\r", - " 1: \"B\",\r", - " 2: \"X\",\r", - " 3: \"Y\",\r", - " 4: \"LB\",\r", - " 5: \"RB\",\r", - " 6: \"LT\",\r", - " 7: \"RT\",\r", - " 8: \"BACK\",\r", - " 9: \"START\",\r", - " 10: \"CLICK_STICK_LEFT\",\r", - " 11: \"CLICK_STICK_RIGHT\",\r", - " 12: \"UP\",\r", - " 13: \"DOWN\",\r", - " 14: \"LEFT\",\r", - " 15: \"RIGHT\",\r", - " 16: \"NONE\",\r", - " 17: \"NONE\"\r", - " },\r", - " \"PS4\": {\r", - " 0: \"CROSS\",\r", - " 1: \"CIRCLE\",\r", - " 2: \"SQUARE\",\r", - " 3: \"TRIANGLE\",\r", - " 4: \"L1\",\r", - " 5: \"R1\",\r", - " 6: \"L2\",\r", - " 7: \"R2\",\r", - " 8: \"SHARE\",\r", - " 9: \"OPTIONS\",\r", - " 10: \"CLICK_STICK_LEFT\",\r", - " 11: \"CLICK_STICK_RIGHT\",\r", - " 12: \"UP\",\r", - " 13: \"DOWN\",\r", - " 14: \"LEFT\",\r", - " 15: \"RIGHT\",\r", - " 16: \"PS_BUTTON\",\r", - " 17: \"CLICK_TOUCHPAD\"\r", - " }\r", - " }\r", - "};\r", + "//Get function parameter\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", "\r", - "gdjs._extensionController.getInputString = function (type, buttonId) {\r", - " const controllerButtonNames = gdjs._extensionController.controllerButtonNames;\r", - " if (controllerButtonNames[type] !== undefined) {\r", - " return controllerButtonNames[type][buttonId];\r", - " }\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in expression: \"Gamepad deadzone for sticks\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "///Return the deadzone value for a given player\r", + "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].deadzone;" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Set the deadzone for sticks of the gamepad. The deadzone is an area for which movement on sticks won't be taken into account (instead, the stick will be considered as not moved). Deadzone is between 0 and 1, and is by default 0.2.", + "fullName": "Set gamepad deadzone for sticks", + "functionType": "Action", + "name": "A_Set_deadzone", + "sentence": "Set deadzone for sticks on gamepad: _PARAM1_ to _PARAM2_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "//Get function parameter\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const newDeadzone = eventsFunctionContext.getArgument(\"deadzone\");\r", "\r", - " return \"UNKNOWN_BUTTON\";\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in action: \"Set gamepad deadzone for sticks\", is not valid, must be between 0 and 4.');\r", + " return;\r", "}\r", "\r", - "gdjs._extensionController.axisToAngle = function (deltaX, deltaY) {\r", - " const rad = Math.atan2(deltaY, deltaX);\r", - " const deg = rad * (180 / Math.PI);\r", - " return deg;\r", + "// clamp the newDeadzone in range [0, 1].\r", + "// https://github.com/4ian/GDevelop-extensions/pull/33#issuecomment-618224857\r", + "gdjs._extensionController.players[playerId].deadzone = gdjs.evtTools.common.clamp(newDeadzone, 0, 1);\r", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" + }, + { + "description": "Deadzone for sticks, 0.2 by default (0 to 1)", + "name": "deadzone", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Check if a stick of a gamepad is pushed in a given direction.", + "fullName": "Gamepad stick pushed (axis)", + "functionType": "Condition", + "name": "C_Axis_pushed", + "sentence": "_PARAM2_ stick of gamepad _PARAM1_ is pushed in direction _PARAM3_", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "//Get function parameters\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", + "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", + "const direction = eventsFunctionContext.getArgument(\"direction\").toUpperCase();\r", + "\r", + "if (playerId < 0 || playerId > 4) {\r", + " console.error('Parameter gamepad identifier in condition: \"Gamepad stick pushed (axis)\", is not valid number, must be between 0 and 4.');\r", + " return;\r", + "}\r", + "if (stick != \"LEFT\" && stick != \"RIGHT\") {\r", + " console.error('Parameter stick in condition: \"Gamepad stick pushed (axis)\", is not valid, must be LEFT or RIGHT');\r", + " return;\r", + "}\r", + "if (direction != \"UP\" && direction != \"DOWN\" && direction != \"LEFT\" && direction != \"RIGHT\" && direction != \"ANY\") {\r", + " console.error('Parameter deadzone in condition: \"Gamepad stick pushed (axis)\", is not valid, must be UP, DOWN, LEFT or RIGHT');\r", + " return;\r", "}\r", "\r", - "gdjs._extensionController.isXbox = function (gamepad) {\r", - " return (gamepad ? (\r", - " gamepad.id.toUpperCase().indexOf(\"XBOX\") !== -1\r", - " // \"XINPUT\" cannot be used to check if it is a xbox controller is just a generic\r", - " // name reported in Firefox corresponding to the driver being used by the controller\r", - " // https://gamefaqs.gamespot.com/boards/916373-pc/73341312?page=1\r", - " ) : false);\r", + "const gamepad = gamepads[playerId];\r", + "\r", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", + "if (gamepad == null) {\r", + " eventsFunctionContext.returnValue = false;\r", + " return;\r", "}\r", "\r", - "//Returns the new value taking into account the dead zone for the player_ID given\r", - "gdjs._extensionController.getNormalizedAxisValue = function (v, player_ID) {\r", - " // gdjs._extensionController = gdjs._extensionController || { deadzone: 0.2 };\r", "\r", - " // Anything smaller than this is assumed to be 0,0\r", - " const DEADZONE = gdjs._extensionController.players[player_ID].deadzone;\r", + "//Define in onFirstSceneLoaded function\r", + "const getNormalizedAxisValue = gdjs._extensionController.getNormalizedAxisValue;\r", "\r", - " if (Math.abs(v) < DEADZONE) {\r", - " // In the dead zone, set to 0\r", - " v = 0;\r", + "switch (stick) {\r", + " case 'LEFT':\r", + " switch (direction) {\r", + " case 'LEFT':\r", + " if (getNormalizedAxisValue(gamepad.axes[0], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", "\r", - " if (v == null) {\r", - " return 0;\r", - " } else {\r", - " return v;\r", + " case 'RIGHT':\r", + " if (getNormalizedAxisValue(gamepad.axes[0], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", + "\r", + " case 'UP':\r", + " if (getNormalizedAxisValue(gamepad.axes[1], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", + "\r", + " case 'DOWN':\r", + " if (getNormalizedAxisValue(gamepad.axes[1], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", + "\r", + " case 'ANY':\r", + " if ( getNormalizedAxisValue(gamepad.axes[0], playerId) < 0\r", + " || getNormalizedAxisValue(gamepad.axes[0], playerId) > 0\r", + " || getNormalizedAxisValue(gamepad.axes[1], playerId) < 0 \r", + " || getNormalizedAxisValue(gamepad.axes[1], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", + "\r", + " default:\r", + " console.error('The value Direction on stick Left on the condition: \"Gamepad stick pushed (axis)\" is not valid.');\r", + " eventsFunctionContext.returnValue = false;\r", + " break;\r", " }\r", + " break;\r", "\r", - " } else {\r", - " // We're outside the dead zone, but we'd like to smooth\r", - " // this value out so it still runs nicely between 0..1.\r", - " // That is, we don't want it to jump suddenly from 0 to\r", - " // DEADZONE.\r", + " case 'RIGHT':\r", + " switch (direction) {\r", + " case 'LEFT':\r", + " if (getNormalizedAxisValue(gamepad.axes[2], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", "\r", - " // Remap v from\r", - " // DEADZONE..1 to 0..(1-DEADZONE)\r", - " // or from\r", - " // -1..-DEADZONE to -(1-DEADZONE)..0\r", + " case 'RIGHT':\r", + " if (getNormalizedAxisValue(gamepad.axes[2], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", "\r", - " v = v - Math.sign(v) * DEADZONE;\r", + " case 'UP':\r", + " if (getNormalizedAxisValue(gamepad.axes[3], playerId) < 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", "\r", - " // Remap v from\r", - " // 0..(1-DEADZONE) to 0..1\r", - " // or from\r", - " // -(1-DEADZONE)..0 to -1..0\r", + " case 'DOWN':\r", + " if (getNormalizedAxisValue(gamepad.axes[3], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", "\r", - " return v / (1 - DEADZONE);\r", - " }\r", - "};" + " case 'ANY':\r", + " if ( getNormalizedAxisValue(gamepad.axes[2], playerId) < 0\r", + " || getNormalizedAxisValue(gamepad.axes[2], playerId) > 0\r", + " || getNormalizedAxisValue(gamepad.axes[3], playerId) < 0 \r", + " || getNormalizedAxisValue(gamepad.axes[3], playerId) > 0) {\r", + " eventsFunctionContext.returnValue = true;\r", + " return;\r", + " }\r", + " break;\r", + "\r", + " default:\r", + " console.error('The value Direction on stick Right on the condition: \"Gamepad stick pushed (axis)\" is not valid.');\r", + " eventsFunctionContext.returnValue = false;\r", + " break;\r", + " }\r", + " break;\r", + "\r", + " default:\r", + " console.error('The value Stick on the condition: \"Gamepad stick pushed (axis)\" is not valid.');\r", + " eventsFunctionContext.returnValue = false;\r", + " break;\r", + "}\r", + "\r", + "eventsFunctionContext.returnValue = false;\r", + "" ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true } ], - "parameters": [], + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" + }, + { + "description": "Stick: \"Left\" or \"Right\"", + "name": "stick", + "supplementaryInformation": "[\"Left\",\"Right\"]", + "type": "stringWithSelector" + }, + { + "description": "Direction", + "name": "direction", + "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\",\"Any\"]", + "type": "stringWithSelector" + } + ], "objectGroups": [] }, { - "fullName": "", - "functionType": "Action", - "name": "onScenePostEvents", + "description": "Return the number of connected gamepads.", + "fullName": "Connected gamepads number", + "functionType": "Expression", + "name": "ConnectedGamepadsCount", "sentence": "", "events": [ { @@ -16642,520 +15635,201 @@ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "//Each time a player press a button i save the last button pressed for the next frame", + "/** @type {Gamepad[]} */\r", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "\r", + "// Gamepads can be disconnected and become null, so we have to filter them.\r", + "eventsFunctionContext.returnValue = Object.keys(gamepads).filter(key => !!gamepads[key]).length;\r", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + }, + { + "description": "Return a string containing informations about the specified gamepad.", + "fullName": "Gamepad type", + "functionType": "StringExpression", + "name": "GamepadType", + "sentence": "Player _PARAM1_ use _PARAM2_ controller", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ "/** @type {Gamepad[]} */", "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", "", "//Get function parameter", - "let countPlayers = Object.keys(gdjs._extensionController.players).length;", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;", "", - "//Repeat for each players", - "for (let i = 0; i < countPlayers; i++) {", - " let gamepad = gamepads[i]; // Get the gamepad of the player", + "if (playerId < 0 || playerId > 4) {", + " console.error('Parameter gamepad identifier in string expression: \"Gamepad type\", is not valid number, must be between 0 and 4');", + " return;", + "}", "", - " //We have to keep this condition because if the user hasn't plugged in his controller yet, we can't get the controller in the gamepad variable.", - " if (gamepad == null) {", - " continue;", - " }", + "const gamepad = gamepads[playerId];", "", - " for (let b = 0; b < Object.keys(gamepad.buttons).length; b++) { //For each buttons", - " if (gamepad.buttons[b].pressed) { //One of them is pressed", - " gdjs._extensionController.players[i].lastButtonUsed = b; //Save the button pressed", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.", + "if (gamepad == null) return;", "", - " //Save the state of the button for the next frame.", - " gdjs._extensionController.players[i].previousFrameStateButtons[b] = { pressed: true };", + "eventsFunctionContext.returnValue = (gamepad && gamepad.id) ? gamepad.id : \"No information for player \" + (playerId + 1)", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Check if the specified gamepad has the specified information in its description. Useful to know if the gamepad is a Xbox or PS4 controller.", + "fullName": "Gamepad type", + "functionType": "Condition", + "name": "C_Controller_type", + "sentence": "Gamepad _PARAM1_ is a _PARAM2_ controller", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", "", - " // Update Last Active Controller", - " gdjs._extensionController.lastActiveController = i;", - " } else {", - " gdjs._extensionController.players[i].previousFrameStateButtons[b] = { pressed: false };", - " }", - " }", + "//Get function parameters", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;", + "const controllerType = eventsFunctionContext.getArgument(\"controller_type\").toUpperCase();", "", + "if (playerId < 0 || playerId > 4) {", + " console.error('Parameter gamepad identifier in condition: \"Gamepad type\", is not valid number, must be between 0 and 4.');", + " return;", + "}", + "if (controllerType === \"\") {", + " console.error('Parameter type in condition: \"Gamepad type\", is not a string.');", + " return;", + "}", "", - " gdjs._extensionController.players[i].rumble.elapsedTime += runtimeScene.getElapsedTime(runtimeScene) / 1000;", - " if (", - " gdjs._extensionController.players[i].rumble.duration - gdjs._extensionController.players[i].rumble.elapsedTime <= 0 &&", - " (gdjs._extensionController.players[i].rumble.weakMagnitude || gdjs._extensionController.players[i].rumble.strongMagnitude)", - " ) {", - " gdjs._extensionController.players[i].rumble.weakMagnitude = 0;", - " gdjs._extensionController.players[i].rumble.strongMagnitude = 0;", - " }", + "const gamepad = gamepads[playerId];", + "", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.", + "if (gamepad == null) return;", "", "", - "}", - "" + "if (controllerType == \"XBOX\") {", + " eventsFunctionContext.returnValue = gdjs._extensionController.isXbox(gamepad);", + "} else {", + " eventsFunctionContext.returnValue = gamepad ? gamepad.id.toUpperCase().indexOf(controllerType) !== -1 : false;", + "}" ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true } ], - "parameters": [], + "parameters": [ + { + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", + "type": "expression" + }, + { + "description": "Type: \"Xbox\", \"PS4\", \"Steam\" or \"PS3\" (among other)", + "name": "controller_type", + "type": "string" + } + ], "objectGroups": [] }, { - "fullName": "Accelerated speed", - "functionType": "Expression", - "name": "AcceleratedSpeed", - "private": true, - "sentence": "", + "description": "Check if a gamepad is connected.", + "fullName": "Gamepad connected", + "functionType": "Condition", + "name": "C_Controller_X_is_connected", + "sentence": "Gamepad _PARAM1_ is plugged and connected", "events": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "CurrentSpeed" - ] - } + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {Gamepad[]} */", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", + "", + "//Get function parameter", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;", + "", + "if (playerId < 0 || playerId > 4) {", + " console.error('Parameter gamepad identifier in condition: \"Gamepad connected\", is not valid number, must be between 0 and 4.');", + " return;", + "}", + "", + "// If gamepad was disconnected it will be null (so this will return false)", + "// If gamepad was never connected it will be undefined (so this will return false)", + "eventsFunctionContext.returnValue = !!gamepads[playerId];" ], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"TargetedSpeed\"", - "<", - "0" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Reduce the speed to match the stick force." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "TargetedSpeed" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "min(TargetedSpeed, CurrentSpeed + Acceleration * TimeDelta())" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "TargetedSpeed" - ] - }, - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "-", - "Acceleration * TimeDelta()" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Turn back at least as fast as it would stop." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">=", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "max(TargetedSpeed, CurrentSpeed - max(Acceleration , Deceleration) * TimeDelta())" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"TargetedSpeed\"", - ">", - "0" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Reduce the speed to match the stick force." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "TargetedSpeed" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "max(TargetedSpeed, CurrentSpeed - Acceleration * TimeDelta())" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "TargetedSpeed" - ] - }, - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "+", - "Acceleration * TimeDelta()" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "Turn back at least as fast as it would stop." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<=", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "min(TargetedSpeed, CurrentSpeed + max(Acceleration , Deceleration) * TimeDelta())" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"TargetedSpeed\"", - "=", - "0" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - "<", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "min(0, CurrentSpeed + Acceleration * TimeDelta())" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "CompareArgumentAsNumber" - }, - "parameters": [ - "\"CurrentSpeed\"", - ">", - "0" - ] - } - ], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "AcceleratedSpeed", - "=", - "max(0, CurrentSpeed - Acceleration * TimeDelta())" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "clamp(AcceleratedSpeed, -SpeedMax, SpeedMax)" - ] - } - ] - } - ], - "variables": [ - { - "name": "AcceleratedSpeed", - "type": "number", - "value": 0 - } - ] + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { - "description": "Current speed", - "name": "CurrentSpeed", - "type": "expression" - }, - { - "description": "Targeted speed", - "name": "TargetedSpeed", - "type": "expression" - }, - { - "description": "Max speed", - "name": "SpeedMax", - "type": "expression" - }, - { - "description": "Acceleration", - "name": "Acceleration", - "type": "expression" - }, - { - "description": "Deceleration", - "name": "Deceleration", + "description": "The gamepad identifier: 1, 2, 3 or 4", + "name": "player_ID", "type": "expression" } ], "objectGroups": [] }, { - "description": "Get the value of the pressure on a gamepad trigger.", - "fullName": "Pressure on a gamepad trigger", - "functionType": "Expression", - "name": "TriggerPressure", - "sentence": "Player _PARAM1_ push axis _PARAM2_ to _PARAM3_", + "description": "Generate a vibration on the specified controller. Might only work if the game is running in a recent web browser.", + "fullName": "Gamepad vibration", + "functionType": "Action", + "name": "A_Vibrate_controller", + "sentence": "Make gamepad _PARAM1_ vibrate for _PARAM2_ seconds", "events": [ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const trigger = eventsFunctionContext.getArgument(\"trigger\").toUpperCase();\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in expression: \"Pressure on a gamepad trigger\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "if (trigger != \"LT\" && trigger != \"RT\" && trigger != \"L2\" && trigger != \"R2\") {\r", - " console.error('Parameter trigger is not valid in expression: \"Pressure on a gamepad trigger\"');\r", - " return;\r", - "}\r", - "\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "switch (trigger) {\r", - " case 'LT':\r", - " case 'L2':\r", - " eventsFunctionContext.returnValue = gamepad.buttons[6].value;\r", - " break;\r", - "\r", - " case 'RT':\r", - " case 'R2':\r", - " eventsFunctionContext.returnValue = gamepad.buttons[7].value;\r", - " break;\r", - "\r", - " default:\r", - " eventsFunctionContext.returnValue = -1;\r", - " break;\r", + "/** @type {Gamepad[]} */", + "//Vibration work only on game in browser.", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", + "", + "//Get function parameters", + "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;", + "const duration = eventsFunctionContext.getArgument(\"Duration\") || 1;", + "", + "if (playerId < 0 || playerId > 4) {", + " console.error('Parameter gamepad identifier in action: \"Gamepad connected\", is not valid number, must be between 0 and 4.');", + " return;", + "}", + "", + "const gamepad = gamepads[playerId];", + "", + "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.", + "if (gamepad == null) return;", + "", + "if (gamepad && gamepad.vibrationActuator) {", + " gamepad.vibrationActuator.playEffect(\"dual-rumble\", {", + " startDelay: 0,", + " duration: duration * 1000,", + " weakMagnitude: 1.0,", + " strongMagnitude: 1.0", + " });", "}" ], "parameterObjects": "", @@ -17163,361 +15837,395 @@ "eventsSheetExpanded": true } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", + "name": "Player_ID", "type": "expression" }, { - "description": "Trigger button", - "name": "trigger", - "supplementaryInformation": "[\"LT\",\"RT\",\"L2\",\"R2\"]", - "type": "stringWithSelector" + "description": "Time of the vibration, in seconds (optional, default value is 1)", + "name": "Duration", + "type": "expression" } ], "objectGroups": [] }, { - "description": "the force of gamepad stick (from 0 to 1).", - "fullName": "Stick force", - "functionType": "ExpressionAndCondition", - "name": "StickForce", - "sentence": "the gamepad _PARAM1_ _PARAM2_ stick force", + "description": "Generate an advanced vibration on the specified controller. Incompatible with Firefox.", + "fullName": "Advanced gamepad vibration", + "functionType": "Action", + "name": "A_Advanced_Vibration_Controller", + "sentence": "Make gamepad _PARAM1_ vibrate for _PARAM2_ seconds with the vibration magnitude of _PARAM3_ and _PARAM4_", "events": [ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", - "\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a stick force\"');\r", - " return;\r", - "}\r", - "\r", - "if (stick !== \"LEFT\" && stick !== \"RIGHT\") {\r", - " console.error('Parameter stick is not valid in expression: \"Value of a stick force\"');\r", - " return;\r", - "}\r", - "\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "\r", - "switch (stick) {\r", - " case 'LEFT':\r", - " eventsFunctionContext.returnValue = gdjs.evtTools.common.clamp(Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId)) + Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId)), 0, 1);\r", - " break;\r", - "\r", - " case 'RIGHT':\r", - " eventsFunctionContext.returnValue = gdjs.evtTools.common.clamp(Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId)) + Math.abs(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId)), 0, 1);\r", - " break;\r", - "\r", - " default:\r", - " eventsFunctionContext.returnValue = -1;\r", - " break;\r", - "}" + "/** @type {Gamepad[]} */", + "//Vibration work only on game in browser.", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", + "", + "//Get function parameters", + "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;", + "const duration = eventsFunctionContext.getArgument(\"Duration\") || 1;", + "const strongRumbleMagnitude = eventsFunctionContext.getArgument(\"StrongMagnitude\");", + "const weakRumbleMagnitude = eventsFunctionContext.getArgument(\"WeakMagnitude\");", + "", + "if (playerId < 0 || playerId > 4) {", + " console.error('Parameter gamepad identifier in action: \"Advanced gamepad vibration\", is not valid number, must be between 0 and 4.');", + " return;", + "}", + "if (weakRumbleMagnitude < 0 || weakRumbleMagnitude > 1) {", + " console.error('Parameter weakRumble identifier in action: \"Advanced gamepad vibration\", is not valid number, must be between 0 and 1.');", + " return;", + "}", + "if (strongRumbleMagnitude < 0 || strongRumbleMagnitude > 1) {", + " console.error('Parameter strongRumble identifier in action: \"Advanced gamepad vibration\", is not valid number, must be between 0 and 1.');", + " return;", + "}", + "", + "const gamepad = gamepads[playerId];", + "", + "//we need keep this condition because when use have not yet plug the controller we can't get the controller in the gamepad variable.", + "if (gamepad == null) return;", + "", + "if (gamepad && gamepad.vibrationActuator) {", + " gamepad.vibrationActuator.playEffect(\"dual-rumble\", {", + " startDelay: 0,", + " duration: duration * 1000,", + " weakMagnitude: weakRumbleMagnitude,", + " strongMagnitude: strongRumbleMagnitude", + " });", + "}", + "", + "gdjs._extensionController.players[playerId].rumble.duration = duration;", + "gdjs._extensionController.players[playerId].rumble.elapsedTime = 0;", + "gdjs._extensionController.players[playerId].rumble.weakMagnitude = weakRumbleMagnitude;", + "gdjs._extensionController.players[playerId].rumble.strongMagnitude = strongRumbleMagnitude;" ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", + "name": "Player_ID", "type": "expression" }, { - "description": "Stick: \"Left\" or \"Right\"", - "name": "stick", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" - } - ], - "objectGroups": [] - }, - { - "description": "Get the rotation value of a gamepad stick.\nIf the deadzone value is high, the angle value is rounded to main axes, left, left, up, down.\nAn zero deadzone value give a total freedom on the angle value.", - "fullName": "Value of a stick rotation (deprecated)", - "functionType": "Expression", - "name": "StickRotationValue", - "private": true, - "sentence": "Player _PARAM1_ push axis _PARAM2_ to _PARAM3_", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "Gamepads::StickAngle(player_ID, stick)" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ + "description": "Time of the vibration, in seconds (optional, default value is 1)", + "name": "Duration", + "type": "expression" + }, { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", + "description": "Strong rumble magnitude (from 0 to 1)", + "name": "StrongMagnitude", "type": "expression" }, { - "description": "Stick: \"Left\" or \"Right\"", - "name": "stick", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" + "description": "Weak rumble magnitude (from 0 to 1)", + "name": "WeakMagnitude", + "type": "expression" } ], "objectGroups": [] }, { - "description": "Return the angle of a gamepad stick.\nIf the deadzone value is high, the angle value is rounded to main axes, left, left, up, down.\nAn zero deadzone value give a total freedom on the angle value.", - "fullName": "Stick angle", - "functionType": "Expression", - "name": "StickAngle", - "sentence": "", + "description": "Change a vibration on the specified controller. Incompatible with Firefox.", + "fullName": "Change gamepad active vibration", + "functionType": "Action", + "name": "A_Change_Vibration_Magnitude", + "sentence": "Change the vibration magnitude of _PARAM2_ & _PARAM3_ on gamepad _PARAM1_", "events": [ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", - "\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a stick rotation\"');\r", - " return;\r", - "}\r", - "if (stick !== \"LEFT\" && stick !== \"RIGHT\") {\r", - " console.error('Parameter stick is not valid in expression: \"Value of a stick rotation\"');\r", - " return;\r", - "}\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "switch (stick) {\r", - " case 'LEFT':\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.axisToAngle(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId), gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId));\r", - " break;\r", - "\r", - " case 'RIGHT':\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.axisToAngle(gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId), gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId));\r", - " break;\r", - "\r", - " default:\r", - " eventsFunctionContext.returnValue = -1;\r", - " break;\r", - "}" + "/** @type {Gamepad[]} */", + "//Vibration work only on game in browser.", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", + "", + "//Get function parameters", + "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;", + "const elapsedTime = gdjs._extensionController.players[playerId].rumble.elapsedTime || 0;", + "const originalDuration = gdjs._extensionController.players[playerId].rumble.duration || 1;", + "const strongRumbleMagnitude = eventsFunctionContext.getArgument(\"StrongMagnitude\");", + "const weakRumbleMagnitude = eventsFunctionContext.getArgument(\"WeakMagnitude\");", + "", + "", + "if (playerId < 0 || playerId > 4) {", + " console.error('Parameter gamepad identifier in action: \"Change gamepad active vibration\", is not valid number, must be between 0 and 4.');", + " return;", + "}", + "if (weakRumbleMagnitude < 0 || weakRumbleMagnitude > 1) {", + " console.error('Parameter weakRumble identifier in action: \"Change gamepad active vibration\", is not valid number, must be between 0 and 1.');", + " return;", + "}", + "if (strongRumbleMagnitude < 0 || strongRumbleMagnitude > 1) {", + " console.error('Parameter strongRumble identifier in action: \"Change gamepad active vibration\", is not valid number, must be between 0 and 1.');", + " return;", + "}", + "", + "const gamepad = gamepads[playerId];", + "", + "//we need keep this condition because when use have not yet plug the controller we can't get the controller in the gamepad variable.", + "if (gamepad == null) return;", + "", + "if (originalDuration - elapsedTime <= 0) return;", + "", + "if (gamepad && gamepad.vibrationActuator) {", + " gamepad.vibrationActuator.playEffect(\"dual-rumble\", {", + " startDelay: 0,", + " duration: 1000 * (originalDuration - elapsedTime),", + " weakMagnitude: weakRumbleMagnitude,", + " strongMagnitude: strongRumbleMagnitude", + " });", + "}", + "", + "gdjs._extensionController.players[playerId].rumble.weakMagnitude = weakRumbleMagnitude;", + "gdjs._extensionController.players[playerId].rumble.strongMagnitude = strongRumbleMagnitude;" ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", + "name": "Player_ID", "type": "expression" }, { - "description": "Stick: \"Left\" or \"Right\"", - "name": "stick", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" + "description": "Strong rumble magnitude (from 0 to 1)", + "name": "StrongMagnitude", + "type": "expression" + }, + { + "description": "Weak rumble magnitude (from 0 to 1)", + "name": "WeakMagnitude", + "type": "expression" } ], "objectGroups": [] }, { - "description": "Get the value of axis of a gamepad stick.", - "fullName": "Value of a gamepad axis (deprecated)", - "functionType": "Expression", - "name": "AxisValue", - "private": true, - "sentence": "Player _PARAM1_ push axis _PARAM2_ to _PARAM3_", + "fullName": "", + "functionType": "Action", + "name": "onFirstSceneLoaded", + "sentence": "", "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [] + }, { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", + "//Define an new private object javascript for the gamepad extension\r", + "gdjs._extensionController = {\r", + " players: {\r", + " 0: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", + " 1: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", + " 2: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", + " 3: { mapping: 'DEFAULT', lastButtonUsed: -1, deadzone: 0.2, previousFrameStateButtons: {}, rumble: {} },\r", + " },\r", + " lastActiveController: -1, // Last active controller\r", + " controllerButtonNames: { //Map associating controller button ids to button names\r", + " \"XBOX\": {\r", + " 0: \"A\",\r", + " 1: \"B\",\r", + " 2: \"X\",\r", + " 3: \"Y\",\r", + " 4: \"LB\",\r", + " 5: \"RB\",\r", + " 6: \"LT\",\r", + " 7: \"RT\",\r", + " 8: \"BACK\",\r", + " 9: \"START\",\r", + " 10: \"CLICK_STICK_LEFT\",\r", + " 11: \"CLICK_STICK_RIGHT\",\r", + " 12: \"UP\",\r", + " 13: \"DOWN\",\r", + " 14: \"LEFT\",\r", + " 15: \"RIGHT\",\r", + " 16: \"NONE\",\r", + " 17: \"NONE\"\r", + " },\r", + " \"PS4\": {\r", + " 0: \"CROSS\",\r", + " 1: \"CIRCLE\",\r", + " 2: \"SQUARE\",\r", + " 3: \"TRIANGLE\",\r", + " 4: \"L1\",\r", + " 5: \"R1\",\r", + " 6: \"L2\",\r", + " 7: \"R2\",\r", + " 8: \"SHARE\",\r", + " 9: \"OPTIONS\",\r", + " 10: \"CLICK_STICK_LEFT\",\r", + " 11: \"CLICK_STICK_RIGHT\",\r", + " 12: \"UP\",\r", + " 13: \"DOWN\",\r", + " 14: \"LEFT\",\r", + " 15: \"RIGHT\",\r", + " 16: \"PS_BUTTON\",\r", + " 17: \"CLICK_TOUCHPAD\"\r", + " }\r", + " }\r", + "};\r", "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", - "const direction = eventsFunctionContext.getArgument(\"direction\").toUpperCase();\r", + "gdjs._extensionController.getInputString = function (type, buttonId) {\r", + " const controllerButtonNames = gdjs._extensionController.controllerButtonNames;\r", + " if (controllerButtonNames[type] !== undefined) {\r", + " return controllerButtonNames[type][buttonId];\r", + " }\r", "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a gamepad axis\"');\r", - " return;\r", - "}\r", - "if (stick != \"LEFT\" && stick != \"RIGHT\") {\r", - " console.error('Parameter stick is not valid in expression: \"Value of a gamepad axis\"');\r", - " return;\r", - "}\r", - "if (direction != \"UP\" && direction != \"DOWN\" && direction != \"LEFT\" && direction != \"RIGHT\" && direction != \"HORIZONTAL\" && direction != \"VERTICAL\") {\r", - " console.error('Parameter direction is not valid in expression: \"Value of a gamepad axis\"');\r", - " return;\r", + " return \"UNKNOWN_BUTTON\";\r", "}\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "let parameterError = false;\r", - "switch (stick) {\r", - " case 'LEFT':\r", - " switch (direction) {\r", - " case 'LEFT':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId);\r", - " }\r", - " break;\r", "\r", - " case 'RIGHT':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId);\r", - " }\r", - " break;\r", + "gdjs._extensionController.axisToAngle = function (deltaX, deltaY) {\r", + " const rad = Math.atan2(deltaY, deltaX);\r", + " const deg = rad * (180 / Math.PI);\r", + " return deg;\r", + "}\r", "\r", - " case 'UP':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId);\r", - " }\r", - " break;\r", + "gdjs._extensionController.isXbox = function (gamepad) {\r", + " return (gamepad ? (\r", + " gamepad.id.toUpperCase().indexOf(\"XBOX\") !== -1\r", + " // \"XINPUT\" cannot be used to check if it is a xbox controller is just a generic\r", + " // name reported in Firefox corresponding to the driver being used by the controller\r", + " // https://gamefaqs.gamespot.com/boards/916373-pc/73341312?page=1\r", + " ) : false);\r", + "}\r", "\r", - " case 'DOWN':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId);\r", - " }\r", - " break;\r", + "//Returns the new value taking into account the dead zone for the player_ID given\r", + "gdjs._extensionController.getNormalizedAxisValue = function (v, player_ID) {\r", + " // gdjs._extensionController = gdjs._extensionController || { deadzone: 0.2 };\r", "\r", - " case \"HORIZONTAL\":\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[0], playerId);\r", - " break;\r", + " // Anything smaller than this is assumed to be 0,0\r", + " const DEADZONE = gdjs._extensionController.players[player_ID].deadzone;\r", "\r", - " case \"VERTICAL\":\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[1], playerId);\r", - " break;\r", + " if (Math.abs(v) < DEADZONE) {\r", + " // In the dead zone, set to 0\r", + " v = 0;\r", "\r", - " default:\r", - " break;\r", + " if (v == null) {\r", + " return 0;\r", + " } else {\r", + " return v;\r", " }\r", - " break;\r", - "\r", - " case 'RIGHT':\r", - " switch (direction) {\r", - " case 'LEFT':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId);\r", - " }\r", - " break;\r", - "\r", - " case 'RIGHT':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId);\r", - " }\r", - " break;\r", - "\r", - " case 'UP':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = -gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId);\r", - " }\r", - " break;\r", "\r", - " case 'DOWN':\r", - " if (gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId);\r", - " }\r", - " break;\r", + " } else {\r", + " // We're outside the dead zone, but we'd like to smooth\r", + " // this value out so it still runs nicely between 0..1.\r", + " // That is, we don't want it to jump suddenly from 0 to\r", + " // DEADZONE.\r", "\r", - " case \"HORIZONTAL\":\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[2], playerId);\r", - " break;\r", + " // Remap v from\r", + " // DEADZONE..1 to 0..(1-DEADZONE)\r", + " // or from\r", + " // -1..-DEADZONE to -(1-DEADZONE)..0\r", "\r", - " case \"VERTICAL\":\r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[3], playerId);\r", - " break;\r", + " v = v - Math.sign(v) * DEADZONE;\r", "\r", - " default:\r", - " break;\r", - " }\r", - " break;\r", + " // Remap v from\r", + " // 0..(1-DEADZONE) to 0..1\r", + " // or from\r", + " // -(1-DEADZONE)..0 to -1..0\r", "\r", - " default:\r", - " break;\r", - "}\r", - "" + " return v / (1 - DEADZONE);\r", + " }\r", + "};" ], "parameterObjects": "", "useStrict": true, "eventsSheetExpanded": true } ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - }, + "parameters": [], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onScenePostEvents", + "sentence": "", + "events": [ { - "description": "Stick: \"Left\" or \"Right\"", - "name": "stick", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [] }, { - "description": "Direction", - "name": "direction", - "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\",\"Horizontal\",\"Vertical\"]", - "type": "stringWithSelector" + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "//Each time a player press a button i save the last button pressed for the next frame", + "/** @type {Gamepad[]} */", + "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", + "", + "//Get function parameter", + "let countPlayers = Object.keys(gdjs._extensionController.players).length;", + "", + "//Repeat for each players", + "for (let i = 0; i < countPlayers; i++) {", + " let gamepad = gamepads[i]; // Get the gamepad of the player", + "", + " //We have to keep this condition because if the user hasn't plugged in his controller yet, we can't get the controller in the gamepad variable.", + " if (gamepad == null) {", + " continue;", + " }", + "", + " for (let b = 0; b < Object.keys(gamepad.buttons).length; b++) { //For each buttons", + " if (gamepad.buttons[b].pressed) { //One of them is pressed", + " gdjs._extensionController.players[i].lastButtonUsed = b; //Save the button pressed", + "", + " //Save the state of the button for the next frame.", + " gdjs._extensionController.players[i].previousFrameStateButtons[b] = { pressed: true };", + "", + " // Update Last Active Controller", + " gdjs._extensionController.lastActiveController = i;", + " } else {", + " gdjs._extensionController.players[i].previousFrameStateButtons[b] = { pressed: false };", + " }", + " }", + "", + "", + " gdjs._extensionController.players[i].rumble.elapsedTime += runtimeScene.getElapsedTime(runtimeScene) / 1000;", + " if (", + " gdjs._extensionController.players[i].rumble.duration - gdjs._extensionController.players[i].rumble.elapsedTime <= 0 &&", + " (gdjs._extensionController.players[i].rumble.weakMagnitude || gdjs._extensionController.players[i].rumble.strongMagnitude)", + " ) {", + " gdjs._extensionController.players[i].rumble.weakMagnitude = 0;", + " gdjs._extensionController.players[i].rumble.strongMagnitude = 0;", + " }", + "", + "", + "}", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true } ], + "parameters": [], "objectGroups": [] }, { - "description": "Return the gamepad stick force on X axis (from -1 at the left to 1 at the right).", - "fullName": "Stick X force", - "functionType": "Expression", - "name": "StickForceX", - "sentence": "", + "description": "Check if any button is released on a gamepad.", + "fullName": "Any gamepad button released", + "functionType": "Condition", + "name": "C_any_button_released", + "sentence": "Any button of gamepad _PARAM1_ is released", "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [] + }, { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ @@ -17525,24 +16233,49 @@ "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", "\r", "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"Gamepad\") - 1;\r", - "const stick = eventsFunctionContext.getArgument(\"Stick\").toLowerCase();\r", + "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", "\r", "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a gamepad axis\"');\r", - " return;\r", - "}\r", - "if (stick != \"left\" && stick != \"right\") {\r", - " console.error('Parameter stick is not valid in expression: \"Value of a gamepad axis\"');\r", - " return;\r", + "\tconsole.error('Parameter gamepad identifier in condition: \"Any gamepad button released\", is not valid number, must be between 0 and 4.');\r", + "\treturn;\r", "}\r", + "\r", "const gamepad = gamepads[playerId];\r", "\r", "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", "if (gamepad == null) return;\r", "\r", - "const axisIndex = stick === 'right' ? 2 : 0;\r", - "eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[axisIndex], playerId);\r", + "for (let buttonId = 0; buttonId < gamepad.buttons.length; buttonId++) { //For each buttons on current frame.\r", + "\r", + "\tif (buttonId === undefined) {\r", + "\t\teventsFunctionContext.returnValue = false;\r", + "\t\treturn;\r", + "\t}\r", + "\r", + "\t//Get previous value or define value by default for the current button\r", + "\tgdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] || { pressed: false };\r", + "\r", + "\t//Get state of the button at previous frame\r", + "\tconst previousStateButtonIsPressed = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed;\r", + "\r", + "\t//Get the state of the button on the current frame.\r", + "\tconst currentFrameStateButtonIsPressed = gamepad.buttons[buttonId].pressed;\r", + "\r", + "\t//When previousStateButtonIsPressed is true and actual button state is not pressed\r", + "\t//Player have release the button\r", + "\tif (previousStateButtonIsPressed === true && currentFrameStateButtonIsPressed === false) {\r", + "\t\tgdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = true;\r", + "\t\teventsFunctionContext.returnValue = true;\r", + "\t\t//break;\r", + "\t\treturn;\r", + "\t} else {\r", + "\t\t//The player didn't released the button yet, the previous frame state is still true\r", + "\t\tgdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = false;\r", + "\t\teventsFunctionContext.returnValue = false;\r", + "\t}\r", + "\r", + "\tif (currentFrameStateButtonIsPressed) gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", + "}\r", "" ], "parameterObjects": "", @@ -17550,61 +16283,31 @@ "eventsSheetExpanded": true } ], - "expressionType": { - "type": "expression" - }, "parameters": [ { "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "Gamepad", + "name": "player_ID", "type": "expression" - }, - { - "description": "Stick: \"Left\" or \"Right\"", - "name": "Stick", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" } ], "objectGroups": [] }, { - "description": "Return the gamepad stick force on Y axis (from -1 at the top to 1 at the bottom).", - "fullName": "Stick Y force", + "description": "Return the strength of the weak vibration motor on the gamepad of a player.", + "fullName": "Weak rumble magnitude", "functionType": "Expression", - "name": "StickForceY", + "name": "WeakVibrationMagnitude", "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"Gamepad\") - 1;\r", - "const stick = eventsFunctionContext.getArgument(\"Stick\").toLowerCase();\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier is not valid in expression: \"Value of a gamepad axis\"');\r", - " return;\r", - "}\r", - "if (stick != \"left\" && stick != \"right\") {\r", - " console.error('Parameter stick is not valid in expression: \"Value of a gamepad axis\"');\r", - " return;\r", - "}\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "const axisIndex = stick === 'right' ? 3 : 1;\r", - "eventsFunctionContext.returnValue = gdjs._extensionController.getNormalizedAxisValue(gamepad.axes[axisIndex], playerId);\r", - "" + "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;\r", + "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].rumble.weakMagnitude;" ], "parameterObjects": "", "useStrict": true, - "eventsSheetExpanded": true + "eventsSheetExpanded": false } ], "expressionType": { @@ -17613,3959 +16316,784 @@ "parameters": [ { "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "Gamepad", + "name": "Player_ID", "type": "expression" - }, - { - "description": "Stick: \"Left\" or \"Right\"", - "name": "Stick", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" } ], "objectGroups": [] }, { - "description": "Test if a button is released on a gamepad. Buttons can be:\n* Xbox: \"A\", \"B\", \"X\", \"Y\", \"LB\", \"RB\", \"LT\", \"RT\", \"BACK\", \"START\",\n* PS4: \"CROSS\", \"SQUARE\", \"CIRCLE\", \"TRIANGLE\", \"L1\", \"L2\", \"R1\", \"R2\", \"SHARE\", \"OPTIONS\", \"PS_BUTTON\", \"CLICK_TOUCHPAD\",\n* Other: \"UP\", \"DOWN\", \"LEFT\", \"RIGHT\", \"CLICK_STICK_LEFT\", \"CLICK_STICK_RIGHT\".", - "fullName": "Gamepad button released", - "functionType": "Condition", - "name": "C_Button_released", - "sentence": "Button _PARAM2_ of gamepad _PARAM1_ is released", + "description": "Return the strength of the strong vibration motor on the gamepad of a player.", + "fullName": "Strong rumble magnitude", + "functionType": "Expression", + "name": "StrongVibrationMagnitude", + "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::JsCode", "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const button = eventsFunctionContext.getArgument(\"button\").toUpperCase();\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in condition: \"Gamepad button released\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "if (button === \"\") {\r", - " console.error('Parameter button is not valid in condition: \"Gamepad button released\"');\r", - " return;\r", - "}\r", - "\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "let buttonId;\r", - "\r", - "switch (button) {\r", - " case 'A':\r", - " case 'CROSS':\r", - " buttonId = 0;\r", - " break;\r", - " case 'B':\r", - " case 'CIRCLE':\r", - " buttonId = 1;\r", - " break;\r", - " case 'X':\r", - " case 'SQUARE':\r", - " buttonId = 2;\r", - " break;\r", - " case 'Y':\r", - " case 'TRIANGLE':\r", - " buttonId = 3;\r", - " break;\r", - " case 'LB':\r", - " case 'L1':\r", - " buttonId = 4;\r", - " break;\r", - " case 'RB':\r", - " case 'R1':\r", - " buttonId = 5;\r", - " break;\r", - " case 'LT':\r", - " case 'L2':\r", - " buttonId = 6;\r", - " break;\r", - " case 'RT':\r", - " case 'R2':\r", - " buttonId = 7;\r", - " break;\r", - "\r", - " case 'UP':\r", - " buttonId = 12;\r", - " break;\r", - " case 'DOWN':\r", - " buttonId = 13;\r", - " break;\r", - " case 'LEFT':\r", - " buttonId = 14;\r", - " break;\r", - " case 'RIGHT':\r", - " buttonId = 15;\r", - " break;\r", - "\r", - " case 'BACK':\r", - " case 'SHARE':\r", - " buttonId = 8;\r", - " break;\r", - " case 'START':\r", - " case 'OPTIONS':\r", - " buttonId = 9;\r", - " break;\r", - "\r", - " case 'CLICK_STICK_LEFT':\r", - " buttonId = 10;\r", - " break;\r", - " case 'CLICK_STICK_RIGHT':\r", - " buttonId = 11;\r", - " break;\r", - "\r", - " //PS4\r", - " case 'PS_BUTTON':\r", - " buttonId = 16;\r", - " break;\r", - " case 'CLICK_TOUCHPAD':\r", - " buttonId = 17;\r", - " break;\r", - "\r", - " default:\r", - " console.error('The button: ' + button + ' in condition: \"Gamepad button released\" is not valid.');\r", - " break;\r", - "}\r", - "\r", - "if (buttonId === undefined) {\r", - " console.error('There is no buttons valid in condition: \"Gamepad button released\"');\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "if (gamepad.buttons == null || gamepad.buttons[buttonId] == null) {\r", - " console.error('Buttons on the gamepad are not accessible in condition: \"Gamepad button released\"');\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "//Define default value on pressed button or use previous value\r", - "gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] || { pressed: false };\r", - "\r", - "//Get state of button at previous frame\r", - "const previousStateButton = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed;\r", - "\r", - "//When previousStateButton is true and actual button state is not pressed\r", - "//Player have release the button\r", - "if (previousStateButton === true && gamepad.buttons[buttonId].pressed === false) {\r", - " // Save the last button used for the player \r", - " gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", - " gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = true;\r", - " eventsFunctionContext.returnValue = true;\r", - "\r", - "} else {\r", - " gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = false;\r", - " eventsFunctionContext.returnValue = false;\r", - "}\r", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - }, - { - "description": "Name of the button", - "name": "button", - "supplementaryInformation": "[\"A\",\"Cross\",\"B\",\"Circle\",\"X\",\"Square\",\"Y\",\"Triangle\",\"LB\",\"L1\",\"RB\",\"R1\",\"LT\",\"L2\",\"RT\",\"R2\",\"Up\",\"Down\",\"Left\",\"Right\",\"Back\",\"Share\",\"Start\",\"Options\",\"Click_Stick_Left\",\"Click_Stick_Right\",\"PS_Button\",\"Click_Touchpad\"]", - "type": "stringWithSelector" - } - ], - "objectGroups": [] - }, - { - "description": "Return the index of the last pressed button of a gamepad.", - "fullName": "Last pressed button (id)", - "functionType": "Expression", - "name": "LastButtonID", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "//Get function parameter\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "\r", - "//Player id is not valid\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in expression: \"Last pressed button (id)\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "\r", - "//Return the last button used by the player\r", - "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].lastButtonUsed;" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Check if any button is pressed on a gamepad.", - "fullName": "Any gamepad button pressed", - "functionType": "Condition", - "name": "C_Any_Button_pressed", - "sentence": "Any button of gamepad _PARAM1_ is pressed", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameter\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in condition: \"Any gamepad button pressed\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "let buttonId;\r", - "for (let i = 0; i < gamepad.buttons.length; i++) { //For each buttons\r", - " if (gamepad.buttons[i].pressed) { //One of them is pressed\r", - " buttonId = i; //Save the button pressed\r", - " break;\r", - " }\r", - "}\r", - "\r", - "if (buttonId === undefined) {\r", - " // No buttons are pressed.\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "if (gamepad.buttons == null || gamepad.buttons[buttonId] == null) {\r", - " console.error('Buttons on the gamepad are not accessible in condition: \"Any gamepad button pressed\"');\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "//When a button is pressed, save the button in lastButtonUsed for each players\r", - "if (gamepad.buttons[buttonId].pressed) gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", - "eventsFunctionContext.returnValue = gamepad.buttons[buttonId].pressed;\r", - "\r", - "\r", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Return the last button pressed. \nButtons for Xbox and PS4 can be:\n* Xbox: \"A\", \"B\", \"X\", \"Y\", \"LB\", \"RB\", \"LT\", \"RT\", \"BACK\", \"START\",\n* PS4: \"CROSS\", \"SQUARE\", \"CIRCLE\", \"TRIANGLE\", \"L1\", \"L2\", \"R1\", \"R2\", \"SHARE\", \"OPTIONS\", \"PS_BUTTON\", \"CLICK_TOUCHPAD\",\n* Both: \"UP\", \"DOWN\", \"LEFT\", \"RIGHT\", \"CLICK_STICK_LEFT\", \"CLICK_STICK_RIGHT\".", - "fullName": "Last pressed button (string)", - "functionType": "StringExpression", - "name": "LastButtonString", - "sentence": "Button _PARAM2_ of gamepad _PARAM1_ is pressed", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const controllerType = eventsFunctionContext.getArgument(\"controller_type\").toUpperCase();\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in string expression: \"Last pressed button (LastButtonString)\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "if (controllerType === \"\") {\r", - " console.error('Parameter controller type is not valid in string expression: \"Last pressed button (LastButtonString)\"');\r", - " return;\r", - "}\r", - "\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "if (gamepad !== null) { //Gamepad exist\r", - " //Get last btn id\r", - " const lastButtonUsedID = gdjs._extensionController.players[playerId].lastButtonUsed;\r", - "\r", - " //Return last button as string \r", - " eventsFunctionContext.returnValue = gdjs._extensionController.getInputString(controllerType, lastButtonUsedID);\r", - "\r", - "} else { //Gamepad dosen't exist\r", - " console.error('Your controller is not supported or the gamepad wasn\\'t detected in string expression: \"Last pressed button (LastButtonString)\"');\r", - " eventsFunctionContext.returnValue = \"Gamepad not connected\";\r", - "}" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "expressionType": { - "type": "string" - }, - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - }, - { - "description": "Controller type", - "name": "controller_type", - "supplementaryInformation": "[\"Xbox\",\"PS4\"]", - "type": "stringWithSelector" - } - ], - "objectGroups": [] - }, - { - "description": "Return the number of gamepads.", - "fullName": "Gamepad count", - "functionType": "Expression", - "name": "GamepadCount", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get the last activated controller\r", - "const controllerId = gdjs._extensionController.lastActiveController;\r", - "\r", - "// Check if controller is active\r", - "const gamepad = gamepads[controllerId];\r", - "if (gamepad == null) {\r", - " eventsFunctionContext.returnValue = 0;\r", - "} else {\r", - " // Return active controller id\r", - " eventsFunctionContext.returnValue = controllerId + 1;\r", - "}\r", - "" + "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;\r", + "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].rumble.strongMagnitude;" ], "parameterObjects": "", "useStrict": true, - "eventsSheetExpanded": true + "eventsSheetExpanded": false } ], "expressionType": { "type": "expression" }, - "parameters": [], - "objectGroups": [] - }, - { - "description": "Check if a button is pressed on a gamepad. \nButtons can be:\n* Xbox: \"A\", \"B\", \"X\", \"Y\", \"LB\", \"RB\", \"LT\", \"RT\", \"BACK\", \"START\",\n* PS4: \"CROSS\", \"SQUARE\", \"CIRCLE\", \"TRIANGLE\", \"L1\", \"L2\", \"R1\", \"R2\", \"SHARE\", \"OPTIONS\", \"PS_BUTTON\", \"CLICK_TOUCHPAD\",\n* Other: \"UP\", \"DOWN\", \"LEFT\", \"RIGHT\", \"CLICK_STICK_LEFT\", \"CLICK_STICK_RIGHT\".", - "fullName": "Gamepad button pressed", - "functionType": "Condition", - "name": "C_Button_pressed", - "sentence": "Button _PARAM2_ of gamepad _PARAM1_ is pressed", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const button = eventsFunctionContext.getArgument(\"button\").toUpperCase();\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in condition: \"Gamepad button pressed\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "if (button === \"\") {\r", - " console.error('Parameter button is not valid in condition: \"Gamepad button pressed\"');\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "let buttonId;\r", - "\r", - "switch (button) {\r", - " case 'A':\r", - " case 'CROSS':\r", - " buttonId = 0;\r", - " break;\r", - " case 'B':\r", - " case 'CIRCLE':\r", - " buttonId = 1;\r", - " break;\r", - " case 'X':\r", - " case 'SQUARE':\r", - " buttonId = 2;\r", - " break;\r", - " case 'Y':\r", - " case 'TRIANGLE':\r", - " buttonId = 3;\r", - " break;\r", - " case 'LB':\r", - " case 'L1':\r", - " buttonId = 4;\r", - " break;\r", - " case 'RB':\r", - " case 'R1':\r", - " buttonId = 5;\r", - " break;\r", - " case 'LT':\r", - " case 'L2':\r", - " buttonId = 6;\r", - " break;\r", - " case 'RT':\r", - " case 'R2':\r", - " buttonId = 7;\r", - " break;\r", - "\r", - " case 'UP':\r", - " buttonId = 12;\r", - " break;\r", - " case 'DOWN':\r", - " buttonId = 13;\r", - " break;\r", - " case 'LEFT':\r", - " buttonId = 14;\r", - " break;\r", - " case 'RIGHT':\r", - " buttonId = 15;\r", - " break;\r", - "\r", - " case 'BACK':\r", - " case 'SHARE':\r", - " buttonId = 8;\r", - " break;\r", - " case 'START':\r", - " case 'OPTIONS':\r", - " buttonId = 9;\r", - " break;\r", - "\r", - " case 'CLICK_STICK_LEFT':\r", - " buttonId = 10;\r", - " break;\r", - " case 'CLICK_STICK_RIGHT':\r", - " buttonId = 11;\r", - " break;\r", - "\r", - " //PS4\r", - " case 'PS_BUTTON':\r", - " buttonId = 16;\r", - " break;\r", - " case 'CLICK_TOUCHPAD':\r", - " buttonId = 17;\r", - " break;\r", - "\r", - " default:\r", - " console.error('The button: ' + button + ' in condition: \"Gamepad button pressed\" is not valid.');\r", - " eventsFunctionContext.returnValue = false;\r", - " break;\r", - "}\r", - "\r", - "\r", - "\r", - "if (buttonId === undefined) {\r", - " console.error('There is no buttons valid in condition: \"Gamepad button pressed\"');\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "if (gamepad.buttons == null || gamepad.buttons[buttonId] == null) {\r", - " console.error('Buttons on the gamepad are not accessible in condition: \"Gamepad button pressed\"');\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "//When a button is pressed, save the button in lastButtonUsed for each players\r", - "if (gamepad.buttons[buttonId].pressed) gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", - "eventsFunctionContext.returnValue = gamepad.buttons[buttonId].pressed;\r", - "\r", - "\r", - "\r", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], "parameters": [ { "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", + "name": "Player_ID", "type": "expression" - }, - { - "description": "Name of the button", - "name": "button", - "supplementaryInformation": "[\"A\",\"Cross\",\"B\",\"Circle\",\"X\",\"Square\",\"Y\",\"Triangle\",\"LB\",\"L1\",\"RB\",\"R1\",\"LT\",\"L2\",\"RT\",\"R2\",\"Up\",\"Down\",\"Left\",\"Right\",\"Back\",\"Share\",\"Start\",\"Options\",\"Click_Stick_Left\",\"Click_Stick_Right\",\"PS_Button\",\"Click_Touchpad\"]", - "type": "stringWithSelector" } ], "objectGroups": [] - }, + } + ], + "eventsBasedBehaviors": [ { - "description": "Return the value of the deadzone applied to a gamepad sticks, between 0 and 1.", - "fullName": "Gamepad deadzone for sticks", - "functionType": "Expression", - "name": "Deadzone", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [] - }, - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "//Get function parameter\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in expression: \"Gamepad deadzone for sticks\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "///Return the deadzone value for a given player\r", - "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].deadzone;" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Set the deadzone for sticks of the gamepad. The deadzone is an area for which movement on sticks won't be taken into account (instead, the stick will be considered as not moved). Deadzone is between 0 and 1, and is by default 0.2.", - "fullName": "Set gamepad deadzone for sticks", - "functionType": "Action", - "name": "A_Set_deadzone", - "sentence": "Set deadzone for sticks on gamepad: _PARAM1_ to _PARAM2_", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "//Get function parameter\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const newDeadzone = eventsFunctionContext.getArgument(\"deadzone\");\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in action: \"Set gamepad deadzone for sticks\", is not valid, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "\r", - "// clamp the newDeadzone in range [0, 1].\r", - "// https://github.com/4ian/GDevelop-extensions/pull/33#issuecomment-618224857\r", - "gdjs._extensionController.players[playerId].deadzone = gdjs.evtTools.common.clamp(newDeadzone, 0, 1);\r", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - }, - { - "description": "Deadzone for sticks, 0.2 by default (0 to 1)", - "name": "deadzone", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Check if a stick of a gamepad is pushed in a given direction.", - "fullName": "Gamepad stick pushed (axis)", - "functionType": "Condition", - "name": "C_Axis_pushed", - "sentence": "_PARAM2_ stick of gamepad _PARAM1_ is pushed in direction _PARAM3_", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "const stick = eventsFunctionContext.getArgument(\"stick\").toUpperCase();\r", - "const direction = eventsFunctionContext.getArgument(\"direction\").toUpperCase();\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - " console.error('Parameter gamepad identifier in condition: \"Gamepad stick pushed (axis)\", is not valid number, must be between 0 and 4.');\r", - " return;\r", - "}\r", - "if (stick != \"LEFT\" && stick != \"RIGHT\") {\r", - " console.error('Parameter stick in condition: \"Gamepad stick pushed (axis)\", is not valid, must be LEFT or RIGHT');\r", - " return;\r", - "}\r", - "if (direction != \"UP\" && direction != \"DOWN\" && direction != \"LEFT\" && direction != \"RIGHT\" && direction != \"ANY\") {\r", - " console.error('Parameter deadzone in condition: \"Gamepad stick pushed (axis)\", is not valid, must be UP, DOWN, LEFT or RIGHT');\r", - " return;\r", - "}\r", - "\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) {\r", - " eventsFunctionContext.returnValue = false;\r", - " return;\r", - "}\r", - "\r", - "\r", - "//Define in onFirstSceneLoaded function\r", - "const getNormalizedAxisValue = gdjs._extensionController.getNormalizedAxisValue;\r", - "\r", - "switch (stick) {\r", - " case 'LEFT':\r", - " switch (direction) {\r", - " case 'LEFT':\r", - " if (getNormalizedAxisValue(gamepad.axes[0], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'RIGHT':\r", - " if (getNormalizedAxisValue(gamepad.axes[0], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'UP':\r", - " if (getNormalizedAxisValue(gamepad.axes[1], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'DOWN':\r", - " if (getNormalizedAxisValue(gamepad.axes[1], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'ANY':\r", - " if ( getNormalizedAxisValue(gamepad.axes[0], playerId) < 0\r", - " || getNormalizedAxisValue(gamepad.axes[0], playerId) > 0\r", - " || getNormalizedAxisValue(gamepad.axes[1], playerId) < 0 \r", - " || getNormalizedAxisValue(gamepad.axes[1], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " default:\r", - " console.error('The value Direction on stick Left on the condition: \"Gamepad stick pushed (axis)\" is not valid.');\r", - " eventsFunctionContext.returnValue = false;\r", - " break;\r", - " }\r", - " break;\r", - "\r", - " case 'RIGHT':\r", - " switch (direction) {\r", - " case 'LEFT':\r", - " if (getNormalizedAxisValue(gamepad.axes[2], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'RIGHT':\r", - " if (getNormalizedAxisValue(gamepad.axes[2], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'UP':\r", - " if (getNormalizedAxisValue(gamepad.axes[3], playerId) < 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'DOWN':\r", - " if (getNormalizedAxisValue(gamepad.axes[3], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " case 'ANY':\r", - " if ( getNormalizedAxisValue(gamepad.axes[2], playerId) < 0\r", - " || getNormalizedAxisValue(gamepad.axes[2], playerId) > 0\r", - " || getNormalizedAxisValue(gamepad.axes[3], playerId) < 0 \r", - " || getNormalizedAxisValue(gamepad.axes[3], playerId) > 0) {\r", - " eventsFunctionContext.returnValue = true;\r", - " return;\r", - " }\r", - " break;\r", - "\r", - " default:\r", - " console.error('The value Direction on stick Right on the condition: \"Gamepad stick pushed (axis)\" is not valid.');\r", - " eventsFunctionContext.returnValue = false;\r", - " break;\r", - " }\r", - " break;\r", - "\r", - " default:\r", - " console.error('The value Stick on the condition: \"Gamepad stick pushed (axis)\" is not valid.');\r", - " eventsFunctionContext.returnValue = false;\r", - " break;\r", - "}\r", - "\r", - "eventsFunctionContext.returnValue = false;\r", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - }, - { - "description": "Stick: \"Left\" or \"Right\"", - "name": "stick", - "supplementaryInformation": "[\"Left\",\"Right\"]", - "type": "stringWithSelector" - }, - { - "description": "Direction", - "name": "direction", - "supplementaryInformation": "[\"Up\",\"Down\",\"Left\",\"Right\",\"Any\"]", - "type": "stringWithSelector" - } - ], - "objectGroups": [] - }, - { - "description": "Return the number of connected gamepads.", - "fullName": "Connected gamepads number", - "functionType": "Expression", - "name": "ConnectedGamepadsCount", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [] - }, - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "// Gamepads can be disconnected and become null, so we have to filter them.\r", - "eventsFunctionContext.returnValue = Object.keys(gamepads).filter(key => !!gamepads[key]).length;\r", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [], - "objectGroups": [] - }, - { - "description": "Return a string containing informations about the specified gamepad.", - "fullName": "Gamepad type", - "functionType": "StringExpression", - "name": "GamepadType", - "sentence": "Player _PARAM1_ use _PARAM2_ controller", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", - "", - "//Get function parameter", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;", - "", - "if (playerId < 0 || playerId > 4) {", - " console.error('Parameter gamepad identifier in string expression: \"Gamepad type\", is not valid number, must be between 0 and 4');", - " return;", - "}", - "", - "const gamepad = gamepads[playerId];", - "", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.", - "if (gamepad == null) return;", - "", - "eventsFunctionContext.returnValue = (gamepad && gamepad.id) ? gamepad.id : \"No information for player \" + (playerId + 1)", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "expressionType": { - "type": "string" - }, - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Check if the specified gamepad has the specified information in its description. Useful to know if the gamepad is a Xbox or PS4 controller.", - "fullName": "Gamepad type", - "functionType": "Condition", - "name": "C_Controller_type", - "sentence": "Gamepad _PARAM1_ is a _PARAM2_ controller", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", - "", - "//Get function parameters", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;", - "const controllerType = eventsFunctionContext.getArgument(\"controller_type\").toUpperCase();", - "", - "if (playerId < 0 || playerId > 4) {", - " console.error('Parameter gamepad identifier in condition: \"Gamepad type\", is not valid number, must be between 0 and 4.');", - " return;", - "}", - "if (controllerType === \"\") {", - " console.error('Parameter type in condition: \"Gamepad type\", is not a string.');", - " return;", - "}", - "", - "const gamepad = gamepads[playerId];", - "", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.", - "if (gamepad == null) return;", - "", - "", - "if (controllerType == \"XBOX\") {", - " eventsFunctionContext.returnValue = gdjs._extensionController.isXbox(gamepad);", - "} else {", - " eventsFunctionContext.returnValue = gamepad ? gamepad.id.toUpperCase().indexOf(controllerType) !== -1 : false;", - "}" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - }, - { - "description": "Type: \"Xbox\", \"PS4\", \"Steam\" or \"PS3\" (among other)", - "name": "controller_type", - "type": "string" - } - ], - "objectGroups": [] - }, - { - "description": "Check if a gamepad is connected.", - "fullName": "Gamepad connected", - "functionType": "Condition", - "name": "C_Controller_X_is_connected", - "sentence": "Gamepad _PARAM1_ is plugged and connected", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", - "", - "//Get function parameter", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;", - "", - "if (playerId < 0 || playerId > 4) {", - " console.error('Parameter gamepad identifier in condition: \"Gamepad connected\", is not valid number, must be between 0 and 4.');", - " return;", - "}", - "", - "// If gamepad was disconnected it will be null (so this will return false)", - "// If gamepad was never connected it will be undefined (so this will return false)", - "eventsFunctionContext.returnValue = !!gamepads[playerId];" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Generate a vibration on the specified controller. Might only work if the game is running in a recent web browser.", - "fullName": "Gamepad vibration", - "functionType": "Action", - "name": "A_Vibrate_controller", - "sentence": "Make gamepad _PARAM1_ vibrate for _PARAM2_ seconds", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */", - "//Vibration work only on game in browser.", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", - "", - "//Get function parameters", - "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;", - "const duration = eventsFunctionContext.getArgument(\"Duration\") || 1;", - "", - "if (playerId < 0 || playerId > 4) {", - " console.error('Parameter gamepad identifier in action: \"Gamepad connected\", is not valid number, must be between 0 and 4.');", - " return;", - "}", - "", - "const gamepad = gamepads[playerId];", - "", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.", - "if (gamepad == null) return;", - "", - "if (gamepad && gamepad.vibrationActuator) {", - " gamepad.vibrationActuator.playEffect(\"dual-rumble\", {", - " startDelay: 0,", - " duration: duration * 1000,", - " weakMagnitude: 1.0,", - " strongMagnitude: 1.0", - " });", - "}" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "Player_ID", - "type": "expression" - }, - { - "description": "Time of the vibration, in seconds (optional, default value is 1)", - "name": "Duration", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Generate an advanced vibration on the specified controller. Incompatible with Firefox.", - "fullName": "Advanced gamepad vibration", - "functionType": "Action", - "name": "A_Advanced_Vibration_Controller", - "sentence": "Make gamepad _PARAM1_ vibrate for _PARAM2_ seconds with the vibration magnitude of _PARAM3_ and _PARAM4_", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */", - "//Vibration work only on game in browser.", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", - "", - "//Get function parameters", - "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;", - "const duration = eventsFunctionContext.getArgument(\"Duration\") || 1;", - "const strongRumbleMagnitude = eventsFunctionContext.getArgument(\"StrongMagnitude\");", - "const weakRumbleMagnitude = eventsFunctionContext.getArgument(\"WeakMagnitude\");", - "", - "if (playerId < 0 || playerId > 4) {", - " console.error('Parameter gamepad identifier in action: \"Advanced gamepad vibration\", is not valid number, must be between 0 and 4.');", - " return;", - "}", - "if (weakRumbleMagnitude < 0 || weakRumbleMagnitude > 1) {", - " console.error('Parameter weakRumble identifier in action: \"Advanced gamepad vibration\", is not valid number, must be between 0 and 1.');", - " return;", - "}", - "if (strongRumbleMagnitude < 0 || strongRumbleMagnitude > 1) {", - " console.error('Parameter strongRumble identifier in action: \"Advanced gamepad vibration\", is not valid number, must be between 0 and 1.');", - " return;", - "}", - "", - "const gamepad = gamepads[playerId];", - "", - "//we need keep this condition because when use have not yet plug the controller we can't get the controller in the gamepad variable.", - "if (gamepad == null) return;", - "", - "if (gamepad && gamepad.vibrationActuator) {", - " gamepad.vibrationActuator.playEffect(\"dual-rumble\", {", - " startDelay: 0,", - " duration: duration * 1000,", - " weakMagnitude: weakRumbleMagnitude,", - " strongMagnitude: strongRumbleMagnitude", - " });", - "}", - "", - "gdjs._extensionController.players[playerId].rumble.duration = duration;", - "gdjs._extensionController.players[playerId].rumble.elapsedTime = 0;", - "gdjs._extensionController.players[playerId].rumble.weakMagnitude = weakRumbleMagnitude;", - "gdjs._extensionController.players[playerId].rumble.strongMagnitude = strongRumbleMagnitude;" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "Player_ID", - "type": "expression" - }, - { - "description": "Time of the vibration, in seconds (optional, default value is 1)", - "name": "Duration", - "type": "expression" - }, - { - "description": "Strong rumble magnitude (from 0 to 1)", - "name": "StrongMagnitude", - "type": "expression" - }, - { - "description": "Weak rumble magnitude (from 0 to 1)", - "name": "WeakMagnitude", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Change a vibration on the specified controller. Incompatible with Firefox.", - "fullName": "Change gamepad active vibration", - "functionType": "Action", - "name": "A_Change_Vibration_Magnitude", - "sentence": "Change the vibration magnitude of _PARAM2_ & _PARAM3_ on gamepad _PARAM1_", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */", - "//Vibration work only on game in browser.", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);", - "", - "//Get function parameters", - "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;", - "const elapsedTime = gdjs._extensionController.players[playerId].rumble.elapsedTime || 0;", - "const originalDuration = gdjs._extensionController.players[playerId].rumble.duration || 1;", - "const strongRumbleMagnitude = eventsFunctionContext.getArgument(\"StrongMagnitude\");", - "const weakRumbleMagnitude = eventsFunctionContext.getArgument(\"WeakMagnitude\");", - "", - "", - "if (playerId < 0 || playerId > 4) {", - " console.error('Parameter gamepad identifier in action: \"Change gamepad active vibration\", is not valid number, must be between 0 and 4.');", - " return;", - "}", - "if (weakRumbleMagnitude < 0 || weakRumbleMagnitude > 1) {", - " console.error('Parameter weakRumble identifier in action: \"Change gamepad active vibration\", is not valid number, must be between 0 and 1.');", - " return;", - "}", - "if (strongRumbleMagnitude < 0 || strongRumbleMagnitude > 1) {", - " console.error('Parameter strongRumble identifier in action: \"Change gamepad active vibration\", is not valid number, must be between 0 and 1.');", - " return;", - "}", - "", - "const gamepad = gamepads[playerId];", - "", - "//we need keep this condition because when use have not yet plug the controller we can't get the controller in the gamepad variable.", - "if (gamepad == null) return;", - "", - "if (originalDuration - elapsedTime <= 0) return;", - "", - "if (gamepad && gamepad.vibrationActuator) {", - " gamepad.vibrationActuator.playEffect(\"dual-rumble\", {", - " startDelay: 0,", - " duration: 1000 * (originalDuration - elapsedTime),", - " weakMagnitude: weakRumbleMagnitude,", - " strongMagnitude: strongRumbleMagnitude", - " });", - "}", - "", - "gdjs._extensionController.players[playerId].rumble.weakMagnitude = weakRumbleMagnitude;", - "gdjs._extensionController.players[playerId].rumble.strongMagnitude = strongRumbleMagnitude;" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "Player_ID", - "type": "expression" - }, - { - "description": "Strong rumble magnitude (from 0 to 1)", - "name": "StrongMagnitude", - "type": "expression" - }, - { - "description": "Weak rumble magnitude (from 0 to 1)", - "name": "WeakMagnitude", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Check if any button is released on a gamepad.", - "fullName": "Any gamepad button released", - "functionType": "Condition", - "name": "C_any_button_released", - "sentence": "Any button of gamepad _PARAM1_ is released", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [] - }, - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "/** @type {Gamepad[]} */\r", - "const gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);\r", - "\r", - "//Get function parameters\r", - "const playerId = eventsFunctionContext.getArgument(\"player_ID\") - 1;\r", - "\r", - "if (playerId < 0 || playerId > 4) {\r", - "\tconsole.error('Parameter gamepad identifier in condition: \"Any gamepad button released\", is not valid number, must be between 0 and 4.');\r", - "\treturn;\r", - "}\r", - "\r", - "const gamepad = gamepads[playerId];\r", - "\r", - "//we need keep this condition because when use have not yet plug her controller we can't get the controller in the gamepad variable.\r", - "if (gamepad == null) return;\r", - "\r", - "for (let buttonId = 0; buttonId < gamepad.buttons.length; buttonId++) { //For each buttons on current frame.\r", - "\r", - "\tif (buttonId === undefined) {\r", - "\t\teventsFunctionContext.returnValue = false;\r", - "\t\treturn;\r", - "\t}\r", - "\r", - "\t//Get previous value or define value by default for the current button\r", - "\tgdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId] || { pressed: false };\r", - "\r", - "\t//Get state of the button at previous frame\r", - "\tconst previousStateButtonIsPressed = gdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed;\r", - "\r", - "\t//Get the state of the button on the current frame.\r", - "\tconst currentFrameStateButtonIsPressed = gamepad.buttons[buttonId].pressed;\r", - "\r", - "\t//When previousStateButtonIsPressed is true and actual button state is not pressed\r", - "\t//Player have release the button\r", - "\tif (previousStateButtonIsPressed === true && currentFrameStateButtonIsPressed === false) {\r", - "\t\tgdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = true;\r", - "\t\teventsFunctionContext.returnValue = true;\r", - "\t\t//break;\r", - "\t\treturn;\r", - "\t} else {\r", - "\t\t//The player didn't released the button yet, the previous frame state is still true\r", - "\t\tgdjs._extensionController.players[playerId].previousFrameStateButtons[buttonId].pressed = false;\r", - "\t\teventsFunctionContext.returnValue = false;\r", - "\t}\r", - "\r", - "\tif (currentFrameStateButtonIsPressed) gdjs._extensionController.players[playerId].lastButtonUsed = buttonId;\r", - "}\r", - "" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": true - } - ], - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "player_ID", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Return the strength of the weak vibration motor on the gamepad of a player.", - "fullName": "Weak rumble magnitude", - "functionType": "Expression", - "name": "WeakVibrationMagnitude", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;\r", - "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].rumble.weakMagnitude;" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": false - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "Player_ID", - "type": "expression" - } - ], - "objectGroups": [] - }, - { - "description": "Return the strength of the strong vibration motor on the gamepad of a player.", - "fullName": "Strong rumble magnitude", - "functionType": "Expression", - "name": "StrongVibrationMagnitude", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::JsCode", - "inlineCode": [ - "const playerId = eventsFunctionContext.getArgument(\"Player_ID\") - 1;\r", - "eventsFunctionContext.returnValue = gdjs._extensionController.players[playerId].rumble.strongMagnitude;" - ], - "parameterObjects": "", - "useStrict": true, - "eventsSheetExpanded": false - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "The gamepad identifier: 1, 2, 3 or 4", - "name": "Player_ID", - "type": "expression" - } - ], - "objectGroups": [] - } - ], - "eventsBasedBehaviors": [ - { - "description": "Control a platformer character with a gamepad.", - "fullName": "Platformer gamepad mapper", - "name": "PlatformerGamepadMapper", - "objectType": "", - "eventsFunctions": [ - { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Controller_X_is_connected" - }, - "parameters": [ - "", - "GamepadIdentifier", - "" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyUseArrows" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Left\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateLeftKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Right\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateRightKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Up\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateUpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - }, - { - "type": { - "value": "PlatformBehavior::SimulateLadderKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Down\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateDownKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyUseLeftStick" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Left\"", - "\"Left\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateLeftKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Left\"", - "\"Right\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateRightKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Left\"", - "\"Up\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateUpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - }, - { - "type": { - "value": "PlatformBehavior::SimulateLadderKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Left\"", - "\"Down\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateDownKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyUseRightStick" - }, - "parameters": [ - "Object", - "Behavior" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Right\"", - "\"Left\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateLeftKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Right\"", - "\"Right\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateRightKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Right\"", - "\"Up\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateUpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - }, - { - "type": { - "value": "PlatformBehavior::SimulateLadderKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Axis_pushed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Right\"", - "\"Down\"", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateDownKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"A or Cross\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"A\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"B or Circle\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"B\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"X or Square\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"X\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Y or Triangle\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Y\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"LB or L1\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"LB\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"RB or R1\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"RB\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"LT or L2\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"LT\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"RT or R2\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"RT\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "PlatformBehavior::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PlatformerCharacter" - ] - } - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::PlatformerGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - } - ], - "propertyDescriptors": [ - { - "value": "", - "type": "Behavior", - "label": "Platformer character behavior", - "description": "", - "group": "", - "extraInformation": [ - "PlatformBehavior::PlatformerObjectBehavior" - ], - "name": "PlatformerCharacter" - }, - { - "value": "1", - "type": "Number", - "label": "Gamepad identifier (1, 2, 3 or 4)", - "description": "", - "group": "", - "extraInformation": [], - "name": "GamepadIdentifier" - }, - { - "value": "true", - "type": "Boolean", - "label": "Use directional pad", - "description": "", - "group": "Controls", - "extraInformation": [], - "name": "UseArrows" - }, - { - "value": "true", - "type": "Boolean", - "label": "Use left stick", - "description": "", - "group": "Controls", - "extraInformation": [], - "name": "UseLeftStick" - }, - { - "value": "", - "type": "Boolean", - "label": "Use right stick", - "description": "", - "group": "Controls", - "extraInformation": [], - "name": "UseRightStick" - }, - { - "value": "A or Cross", - "type": "Choice", - "label": "Jump button", - "description": "", - "group": "Controls", - "extraInformation": [ - "A or Cross", - "B or Circle", - "X or Square", - "Y or Triangle", - "LB or L1", - "RB or R1", - "LT or L2", - "RT or R2" - ], - "name": "JumpButton" - } - ], - "sharedPropertyDescriptors": [] - }, - { - "description": "Control a 3D physics character with a gamepad.", - "fullName": "3D platformer gamepad mapper", - "name": "Platformer3DGamepadMapper", - "objectType": "", - "eventsFunctions": [ - { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Controller_X_is_connected" - }, - "parameters": [ - "", - "GamepadIdentifier", - "" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::StickForce" - }, - "parameters": [ - "", - ">", - "0", - "GamepadIdentifier", - "JoystickIdentifier", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SetForwardAngle" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D", - "=", - "Gamepads::StickAngle(GamepadIdentifier, JoystickIdentifier) + CameraAngle(Object.Layer())" - ] - }, - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateStick" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D", - "-90", - "Gamepads::StickForce(GamepadIdentifier, JoystickIdentifier)" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"A or Cross\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"A\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"B or Circle\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"B\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"X or Square\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"X\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Y or Triangle\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Y\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"LB or L1\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"LB\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"RB or R1\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"RB\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"LT or L2\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"LT\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Platformer3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"RT or R2\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"RT\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::Platformer3DGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - } - ], - "propertyDescriptors": [ - { - "value": "", - "type": "Behavior", - "label": "3D physics character", - "description": "", - "group": "", - "extraInformation": [ - "Physics3D::PhysicsCharacter3D" - ], - "name": "PhysicsCharacter3D" - }, - { - "value": "1", - "type": "Number", - "label": "Gamepad identifier (1, 2, 3 or 4)", - "description": "", - "group": "", - "extraInformation": [], - "name": "GamepadIdentifier" - }, - { - "value": "Left", - "type": "Choice", - "label": "Walk joystick", - "description": "", - "group": "Controls", - "extraInformation": [ - "Left", - "Right" - ], - "name": "JoystickIdentifier" - }, - { - "value": "A or Cross", - "type": "Choice", - "label": "Jump button", - "description": "", - "group": "Controls", - "extraInformation": [ - "A or Cross", - "B or Circle", - "X or Square", - "Y or Triangle", - "LB or L1", - "RB or R1", - "LT or L2", - "RT or R2" - ], - "name": "JumpButton" - } - ], - "sharedPropertyDescriptors": [] - }, - { - "description": "Control a 3D physics character with a gamepad.", - "fullName": "3D shooter gamepad mapper", - "name": "Shooter3DGamepadMapper", - "objectType": "", - "eventsFunctions": [ - { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::C_Controller_X_is_connected" - }, - "parameters": [ - "", - "GamepadIdentifier", - "" - ] - } - ], - "actions": [], - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::StickForce" - }, - "parameters": [ - "", - ">", - "0", - "GamepadIdentifier", - "WalkStick", - "" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateStick" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D", - "Gamepads::StickAngle(GamepadIdentifier, WalkStick)", - "Gamepads::StickForce(GamepadIdentifier, WalkStick)" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"A or Cross\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"A\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"B or Circle\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"B\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"X or Square\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"X\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"Y or Triangle\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"Y\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"LB or L1\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"LB\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"RB or R1\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"RB\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"LT or L2\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"LT\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [ - { - "type": { - "value": "Gamepads::Shooter3DGamepadMapper::PropertyJumpButton" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "\"RT or R2\"" - ] - }, - { - "type": { - "value": "Gamepads::C_Button_pressed" - }, - "parameters": [ - "", - "GamepadIdentifier", - "\"RT\"", - "\"Left\"" - ] - } - ], - "actions": [ - { - "type": { - "value": "Physics3D::PhysicsCharacter3D::SimulateJumpKey" - }, - "parameters": [ - "Object", - "PhysicsCharacter3D" - ] - } - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::Shooter3DGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - } - ], - "propertyDescriptors": [ - { - "value": "", - "type": "Behavior", - "label": "3D physics character", - "description": "", - "group": "", - "extraInformation": [ - "Physics3D::PhysicsCharacter3D" - ], - "name": "PhysicsCharacter3D" - }, - { - "value": "1", - "type": "Number", - "label": "Gamepad identifier (1, 2, 3 or 4)", - "description": "", - "group": "", - "extraInformation": [], - "name": "GamepadIdentifier" - }, - { - "value": "Left", - "type": "Choice", - "label": "Walk joystick", - "description": "", - "group": "Controls", - "extraInformation": [ - "Left", - "Right" - ], - "name": "WalkStick" - }, - { - "value": "Right", - "type": "Choice", - "label": "Camera joystick", - "description": "", - "group": "Controls", - "extraInformation": [ - "Left", - "Right" - ], - "name": "CameraStick" - }, - { - "value": "A or Cross", - "type": "Choice", - "label": "Jump button", - "description": "", - "group": "Controls", - "extraInformation": [ - "A or Cross", - "B or Circle", - "X or Square", - "Y or Triangle", - "LB or L1", - "RB or R1", - "LT or L2", - "RT or R2" - ], - "name": "JumpButton" - } - ], - "sharedPropertyDescriptors": [] - }, - { - "description": "Control camera rotations with a gamepad.", - "fullName": "First person camera gamepad mapper", - "name": "FirstPersonGamepadMapper", - "objectType": "", - "eventsFunctions": [ - { - "fullName": "", - "functionType": "Action", - "name": "doStepPreEvents", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Comment", - "color": { - "b": 109, - "g": 230, - "r": 255, - "textB": 0, - "textG": 0, - "textR": 0 - }, - "comment": "TODO It's probably a bad idea to rotate the object around Y." - }, - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyCurrentRotationSpeedZ" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Gamepads::AcceleratedSpeed(CurrentRotationSpeedZ, Gamepads::StickForceX(GamepadIdentifier, CameraStick) * HorizontalRotationSpeedMax, HorizontalRotationSpeedMax, HorizontalRotationAcceleration, HorizontalRotationDeceleration)" - ] - }, - { - "type": { - "value": "SetAngle" - }, - "parameters": [ - "Object", - "+", - "CurrentRotationSpeedZ * TimeDelta()" - ] - }, - { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyCurrentRotationSpeedY" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Gamepads::AcceleratedSpeed(CurrentRotationSpeedY, Gamepads::StickForceY(GamepadIdentifier, CameraStick) * VerticalRotationSpeedMax, VerticalRotationSpeedMax, VerticalRotationAcceleration, VerticalRotationDeceleration)" - ] - }, - { - "type": { - "value": "Scene3D::Base3DBehavior::SetRotationY" - }, - "parameters": [ - "Object", - "Object3D", - "+", - "CurrentRotationSpeedY * TimeDelta()" - ] - }, - { - "type": { - "value": "Scene3D::Base3DBehavior::SetRotationY" - }, - "parameters": [ - "Object", - "Object3D", - "=", - "clamp(Object.Object3D::RotationY(), VerticalAngleMin, VerticalAngleMax)" - ] - }, - { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::LookFromObjectEyes" - }, - "parameters": [ - "Object", - "Behavior", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "Move the camera to look though _PARAM1_ eyes. The object must look to the right when all its angles are 0 and the top of its head be toward Z+.", - "fullName": "Look through object eyes", - "functionType": "Action", - "group": "Layers and cameras", - "name": "LookFromObjectEyes", - "private": true, - "sentence": "Move the camera to look though _PARAM0_ eyes", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "CentreCamera" - }, - "parameters": [ - "", - "Object", - "", - "Object.Layer()", - "" - ] - }, - { - "type": { - "value": "Scene3D::SetCameraZ" - }, - "parameters": [ - "", - "=", - "Object.Object3D::Z() + Object.Object3D::Depth() + OffsetZ", - "", - "" - ] - }, - { - "type": { - "value": "Scene3D::SetCameraRotationX" - }, - "parameters": [ - "", - "=", - "- Object.Object3D::RotationY() + 90", - "GetArgumentAsString(\"Layer\")", - "" - ] - }, - { - "type": { - "value": "Scene3D::SetCameraRotationY" - }, - "parameters": [ - "", - "=", - "Object.Object3D::RotationX()", - "GetArgumentAsString(\"Layer\")", - "" - ] - }, - { - "type": { - "value": "SetCameraAngle" - }, - "parameters": [ - "", - "=", - "Object.Angle() + 90", - "Object.Layer()", - "" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the maximum horizontal rotation speed of the object.", - "fullName": "Maximum horizontal rotation speed", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper horizontal rotation configuration", - "name": "HorizontalRotationSpeedMax", - "sentence": "the maximum horizontal rotation speed", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "HorizontalRotationSpeedMax" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "HorizontalRotationSpeedMax", - "name": "SetHorizontalRotationSpeedMax", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyHorizontalRotationSpeedMax" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the horizontal rotation acceleration of the object.", - "fullName": "Horizontal rotation acceleration", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper horizontal rotation configuration", - "name": "HorizontalRotationAcceleration", - "sentence": "the horizontal rotation acceleration", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "HorizontalRotationAcceleration" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "HorizontalRotationAcceleration", - "name": "SetHorizontalRotationAcceleration", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyHorizontalRotationAcceleration" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the horizontal rotation deceleration of the object.", - "fullName": "Horizontal rotation deceleration", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper horizontal rotation configuration", - "name": "HorizontalRotationDeceleration", - "sentence": "the horizontal rotation deceleration", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "HorizontalRotationDeceleration" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "HorizontalRotationDeceleration", - "name": "SetHorizontalRotationDeceleration", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyHorizontalRotationDeceleration" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" - ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the maximum vertical rotation speed of the object.", - "fullName": "Maximum vertical rotation speed", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper vertical rotation configuration", - "name": "VerticalRotationSpeedMax", - "sentence": "the maximum vertical rotation speed", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "VerticalRotationSpeedMax" - ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, + "description": "Control a platformer character with a gamepad.", + "fullName": "Platformer gamepad mapper", + "name": "PlatformerGamepadMapper", + "objectType": "", + "eventsFunctions": [ { "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalRotationSpeedMax", - "name": "SetVerticalRotationSpeedMax", + "functionType": "Action", + "name": "doStepPreEvents", "sentence": "", "events": [ { "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + "conditions": [ { "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyVerticalRotationSpeedMax" + "value": "Gamepads::C_Controller_X_is_connected" }, "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "" ] } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the vertical rotation acceleration of the object.", - "fullName": "Vertical rotation acceleration", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper vertical rotation configuration", - "name": "VerticalRotationAcceleration", - "sentence": "the vertical rotation acceleration", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + ], + "actions": [], + "events": [ { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "VerticalRotationAcceleration" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyUseArrows" + }, + "parameters": [ + "Object", + "Behavior" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Left\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateLeftKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Right\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateRightKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Up\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateUpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + }, + { + "type": { + "value": "PlatformBehavior::SimulateLadderKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Down\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateDownKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + } ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalRotationAcceleration", - "name": "SetVerticalRotationAcceleration", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyVerticalRotationAcceleration" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyUseLeftStick" + }, + "parameters": [ + "Object", + "Behavior" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Left\"", + "\"Left\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateLeftKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Left\"", + "\"Right\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateRightKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Left\"", + "\"Up\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateUpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + }, + { + "type": { + "value": "PlatformBehavior::SimulateLadderKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Left\"", + "\"Down\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateDownKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + } ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the vertical rotation deceleration of the object.", - "fullName": "Vertical rotation deceleration", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper vertical rotation configuration", - "name": "VerticalRotationDeceleration", - "sentence": "the vertical rotation deceleration", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "VerticalRotationDeceleration" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyUseRightStick" + }, + "parameters": [ + "Object", + "Behavior" + ] + } + ], + "actions": [], + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Right\"", + "\"Left\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateLeftKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Right\"", + "\"Right\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateRightKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Right\"", + "\"Up\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateUpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + }, + { + "type": { + "value": "PlatformBehavior::SimulateLadderKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::C_Axis_pushed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Right\"", + "\"Down\"", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateDownKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + } ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalRotationDeceleration", - "name": "SetVerticalRotationDeceleration", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyVerticalRotationDeceleration" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"A or Cross\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"A\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the minimum vertical camera angle of the object.", - "fullName": "Minimum vertical camera angle", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper vertical rotation configuration", - "name": "VerticalAngleMin", - "sentence": "the minimum vertical camera angle", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "VerticalAngleMin" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"B or Circle\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"B\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalAngleMin", - "name": "SetVerticalAngleMin", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyVerticalAngleMin" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"X or Square\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"X\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the maximum vertical camera angle of the object.", - "fullName": "Maximum vertical camera angle", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper vertical rotation configuration", - "name": "VerticalAngleMax", - "sentence": "the maximum vertical camera angle", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "VerticalAngleMax" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"Y or Triangle\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"Y\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "VerticalAngleMax", - "name": "SetVerticalAngleMax", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"LB or L1\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"LB\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } + ] + }, { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyVerticalAngleMax" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"RB or R1\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"RB\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } ] - } - ] - } - ], - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "description": "the z position offset of the object.", - "fullName": "Z position offset", - "functionType": "ExpressionAndCondition", - "group": "First person camera gamepad mapper position configuration", - "name": "OffsetZ", - "sentence": "the z position offset", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "SetReturnNumber" - }, - "parameters": [ - "OffsetZ" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"LT or L2\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"LT\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } ] - } - ] - } - ], - "expressionType": { - "type": "expression" - }, - "parameters": [ - { - "description": "Object", - "name": "Object", - "type": "object" - }, - { - "description": "Behavior", - "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", - "type": "behavior" - } - ], - "objectGroups": [] - }, - { - "fullName": "", - "functionType": "ActionWithOperator", - "getterName": "OffsetZ", - "name": "SetOffsetZ", - "sentence": "", - "events": [ - { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ + }, { - "type": { - "value": "Gamepads::FirstPersonGamepadMapper::SetPropertyOffsetZ" - }, - "parameters": [ - "Object", - "Behavior", - "=", - "Value" + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "Gamepads::PlatformerGamepadMapper::PropertyJumpButton" + }, + "parameters": [ + "Object", + "Behavior", + "=", + "\"RT or R2\"" + ] + }, + { + "type": { + "value": "Gamepads::C_Button_pressed" + }, + "parameters": [ + "", + "Object.Behavior::PropertyGamepadIdentifier()", + "\"RT\"", + "\"Left\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlatformBehavior::SimulateJumpKey" + }, + "parameters": [ + "Object", + "PlatformerCharacter" + ] + } ] } ] @@ -21580,7 +17108,7 @@ { "description": "Behavior", "name": "Behavior", - "supplementaryInformation": "Gamepads::FirstPersonGamepadMapper", + "supplementaryInformation": "Gamepads::PlatformerGamepadMapper", "type": "behavior" } ], @@ -21591,13 +17119,13 @@ { "value": "", "type": "Behavior", - "label": "3D capability", + "label": "Platformer character behavior", "description": "", "group": "", "extraInformation": [ - "Scene3D::Base3DBehavior" + "PlatformBehavior::PlatformerObjectBehavior" ], - "name": "Object3D" + "name": "PlatformerCharacter" }, { "value": "1", @@ -21609,124 +17137,49 @@ "name": "GamepadIdentifier" }, { - "value": "Right", - "type": "Choice", - "label": "Camera joystick", - "description": "", - "group": "", - "extraInformation": [ - "Left", - "Right" - ], - "name": "CameraStick" - }, - { - "value": "180", - "type": "Number", - "unit": "AngularSpeed", - "label": "Maximum rotation speed", - "description": "", - "group": "Horizontal rotation", - "extraInformation": [], - "name": "HorizontalRotationSpeedMax" - }, - { - "value": "360", - "type": "Number", - "label": "Rotation acceleration", - "description": "", - "group": "Horizontal rotation", - "extraInformation": [], - "name": "HorizontalRotationAcceleration" - }, - { - "value": "720", - "type": "Number", - "label": "Rotation deceleration", - "description": "", - "group": "Horizontal rotation", - "extraInformation": [], - "name": "HorizontalRotationDeceleration" - }, - { - "value": "120", - "type": "Number", - "unit": "AngularSpeed", - "label": "Maximum rotation speed", - "description": "", - "group": "Vertical rotation", - "extraInformation": [], - "name": "VerticalRotationSpeedMax" - }, - { - "value": "240", - "type": "Number", - "label": "Rotation acceleration", - "description": "", - "group": "Vertical rotation", - "extraInformation": [], - "name": "VerticalRotationAcceleration" - }, - { - "value": "480", - "type": "Number", - "label": "Rotation deceleration", - "description": "", - "group": "Vertical rotation", - "extraInformation": [], - "name": "VerticalRotationDeceleration" - }, - { - "value": "-90", - "type": "Number", - "unit": "DegreeAngle", - "label": "Minimum angle", - "description": "", - "group": "Vertical rotation", - "extraInformation": [], - "name": "VerticalAngleMin" - }, - { - "value": "90", - "type": "Number", - "unit": "DegreeAngle", - "label": "Maximum angle", + "value": "true", + "type": "Boolean", + "label": "Use directional pad", "description": "", - "group": "Vertical rotation", + "group": "Controls", "extraInformation": [], - "name": "VerticalAngleMax" + "name": "UseArrows" }, { - "value": "0", - "type": "Number", - "unit": "Pixel", - "label": "Z position offset", + "value": "true", + "type": "Boolean", + "label": "Use left stick", "description": "", - "group": "Position", + "group": "Controls", "extraInformation": [], - "name": "OffsetZ" + "name": "UseLeftStick" }, { - "value": "0", - "type": "Number", - "unit": "AngularSpeed", - "label": "Current rotation speed Z", + "value": "", + "type": "Boolean", + "label": "Use right stick", "description": "", - "group": "", + "group": "Controls", "extraInformation": [], - "hidden": true, - "name": "CurrentRotationSpeedZ" + "name": "UseRightStick" }, { - "value": "0", - "type": "Number", - "unit": "AngularSpeed", - "label": "Current rotation speed Y", + "value": "A or Cross", + "type": "Choice", + "label": "Jump button", "description": "", - "group": "", - "extraInformation": [], - "hidden": true, - "name": "CurrentRotationSpeedY" + "group": "Controls", + "extraInformation": [ + "A or Cross", + "B or Circle", + "X or Square", + "Y or Triangle", + "LB or L1", + "RB or R1", + "LT or L2", + "RT or R2" + ], + "name": "JumpButton" } ], "sharedPropertyDescriptors": [] @@ -21752,7 +17205,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "" ] } @@ -21764,7 +17217,7 @@ "conditions": [ { "type": { - "value": "Gamepads::TopDownGamepadMapper::PropertyUseArrows" + "value": "Gamepads::PlatformerGamepadMapper::PropertyUseArrows" }, "parameters": [ "Object", @@ -21783,7 +17236,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Left\"", "\"Left\"" ] @@ -21810,7 +17263,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Right\"", "\"Left\"" ] @@ -21837,7 +17290,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Up\"", "\"Left\"" ] @@ -21864,7 +17317,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Down\"", "\"Left\"" ] @@ -21889,7 +17342,7 @@ "conditions": [ { "type": { - "value": "Gamepads::TopDownGamepadMapper::PropertyUseLeftStick" + "value": "Gamepads::PlatformerGamepadMapper::PropertyUseLeftStick" }, "parameters": [ "Object", @@ -21922,8 +17375,8 @@ "parameters": [ "Object", "TopDownMovement", - "Gamepads::StickRotationValue(GamepadIdentifier, \"Left\")", - "Gamepads::StickForce(GamepadIdentifier, \"Left\")" + "Gamepads::StickRotationValue(Object.Behavior::PropertyGamepadIdentifier(), \"Left\")", + "Gamepads::StickForce(Object.Behavior::PropertyGamepadIdentifier(), \"Left\")" ] } ] @@ -21951,8 +17404,8 @@ "parameters": [ "Object", "TopDownMovement", - "Gamepads::StickRotationValue(GamepadIdentifier, \"Left\")", - "sign(Gamepads::StickForce(GamepadIdentifier, \"Left\"))" + "Gamepads::StickRotationValue(Object.Behavior::PropertyGamepadIdentifier(), \"Left\")", + "sign(Gamepads::StickForce(Object.Behavior::PropertyGamepadIdentifier(), \"Left\"))" ] } ] @@ -21983,7 +17436,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Left\"", "\"Left\"", "" @@ -22011,7 +17464,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Left\"", "\"Right\"", "" @@ -22039,7 +17492,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Left\"", "\"Up\"", "" @@ -22067,7 +17520,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Left\"", "\"Down\"", "" @@ -22095,7 +17548,7 @@ "conditions": [ { "type": { - "value": "Gamepads::TopDownGamepadMapper::PropertyUseRightStick" + "value": "Gamepads::PlatformerGamepadMapper::PropertyUseRightStick" }, "parameters": [ "Object", @@ -22128,8 +17581,8 @@ "parameters": [ "Object", "TopDownMovement", - "Gamepads::StickRotationValue(GamepadIdentifier, \"Right\")", - "Gamepads::StickForce(GamepadIdentifier, \"Right\")" + "Gamepads::StickRotationValue(Object.Behavior::PropertyGamepadIdentifier(), \"Right\")", + "Gamepads::StickForce(Object.Behavior::PropertyGamepadIdentifier(), \"Right\")" ] } ] @@ -22157,7 +17610,7 @@ "parameters": [ "Object", "TopDownMovement", - "sign(Gamepads::StickForce(GamepadIdentifier, \"Right\"))", + "sign(Gamepads::StickForce(Object.Behavior::PropertyGamepadIdentifier(), \"Right\"))", "1" ] } @@ -22189,7 +17642,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Right\"", "\"Left\"", "" @@ -22217,7 +17670,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Right\"", "\"Right\"", "" @@ -22245,7 +17698,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Right\"", "\"Up\"", "" @@ -22273,7 +17726,7 @@ }, "parameters": [ "", - "GamepadIdentifier", + "Object.Behavior::PropertyGamepadIdentifier()", "\"Right\"", "\"Down\"", "" @@ -23010,7 +18463,7 @@ "name": "PlatformerCharacterAnimator", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Glyphster Pack/Master/SVG/Sports and Fitness/Sports and Fitness_training_running_run.svg", "shortDescription": "Change animations and horizontal flipping of a platformer character automatically.", - "version": "1.1.2", + "version": "1.1.0", "description": [ "Automatically change the animations and horizontal flipping of a platformer character based on movement and interaction with platform objects.", "", @@ -23215,7 +18668,7 @@ "Object", "Animation", "=", - "JumpAnimationName" + "Object.Behavior::PropertyJumpAnimationName()" ] } ] @@ -23248,7 +18701,7 @@ "Object", "Animation", "=", - "FallAnimationName" + "Object.Behavior::PropertyFallAnimationName()" ] } ] @@ -23296,7 +18749,7 @@ "Object", "Animation", "=", - "RunAnimationName" + "Object.Behavior::PropertyRunAnimationName()" ] } ] @@ -23330,7 +18783,7 @@ "Object", "Animation", "=", - "IdleAnimationName" + "Object.Behavior::PropertyIdleAnimationName()" ] } ] @@ -23371,7 +18824,7 @@ "Object", "Animation", "=", - "ClimbAnimationName" + "Object.Behavior::PropertyClimbAnimationName()" ] } ] @@ -23651,7 +19104,7 @@ "Object", "Animation", "=", - "JumpAnimationName" + "Object.Behavior::PropertyJumpAnimationName()" ] } ] @@ -23678,7 +19131,7 @@ "Object", "Animation", "=", - "FallAnimationName" + "Object.Behavior::PropertyFallAnimationName()" ] } ] @@ -23720,7 +19173,7 @@ "Object", "Animation", "=", - "RunAnimationName" + "Object.Behavior::PropertyRunAnimationName()" ] } ] @@ -23748,7 +19201,7 @@ "Object", "Animation", "=", - "IdleAnimationName" + "Object.Behavior::PropertyIdleAnimationName()" ] } ] @@ -23782,7 +19235,7 @@ "Object", "Animation", "=", - "ClimbAnimationName" + "Object.Behavior::PropertyClimbAnimationName()" ] } ] @@ -23918,7 +19371,7 @@ "value": "GetArgumentAsBoolean" }, "parameters": [ - "\"Value\"" + "\"EnableAnimationChanges\"" ] } ], @@ -23951,7 +19404,7 @@ { "defaultValue": "yes", "description": "Change animations automatically", - "name": "Value", + "name": "EnableAnimationChanges", "optional": true, "type": "yesorno" } @@ -23989,7 +19442,7 @@ "value": "GetArgumentAsBoolean" }, "parameters": [ - "\"Value\"" + "\"EnableHorizontalFlipping\"" ] } ], @@ -24022,7 +19475,7 @@ { "defaultValue": "yes", "description": "Enable horizontal flipping", - "name": "Value", + "name": "EnableHorizontalFlipping", "optional": true, "type": "yesorno" } @@ -24049,7 +19502,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsString(\"AnimationName\")" ] } ] @@ -24069,7 +19522,7 @@ }, { "description": "Animation name", - "name": "Value", + "name": "AnimationName", "type": "string" } ], @@ -24095,7 +19548,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsString(\"AnimationName\")" ] } ] @@ -24115,7 +19568,7 @@ }, { "description": "Animation name", - "name": "Value", + "name": "AnimationName", "type": "string" } ], @@ -24141,7 +19594,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsString(\"AnimationName\")" ] } ] @@ -24161,7 +19614,7 @@ }, { "description": "Animation name", - "name": "Value", + "name": "AnimationName", "type": "string" } ], @@ -24187,7 +19640,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsString(\"AnimationName\")" ] } ] @@ -24207,7 +19660,7 @@ }, { "description": "Animation name", - "name": "Value", + "name": "AnimationName", "type": "string" } ], @@ -24233,7 +19686,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsString(\"AnimationName\")" ] } ] @@ -24253,7 +19706,7 @@ }, { "description": "Animation name", - "name": "Value", + "name": "AnimationName", "type": "string" } ], @@ -24373,7 +19826,7 @@ "name": "TiledUnitsBar", "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/063e9152cf65bc0f3be2a828afd950c3ecf1b1fc72feefdc2467252fe987dc0f_dots-horizontal.svg", "shortDescription": "A bar that represents a resource in the game (health, mana, ammo, etc).", - "version": "1.1.4", + "version": "1.1.3", "description": [ "A bar that represents a resource in the game (health, mana, ammo, etc).", "", @@ -25399,84 +20852,69 @@ ] } ], - "actions": [], - "events": [ + "actions": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Width", - "=", - "Object.Width()" - ] - }, - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Height", - "=", - "Object.Height()" - ] - }, - { - "type": { - "value": "ScalableCapability::ScalableBehavior::SetValue" - }, - "parameters": [ - "Object", - "Scale", - "=", - "1" - ] - }, - { - "type": { - "value": "PanelSpriteObject::Width" - }, - "parameters": [ - "Background", - "=", - "Width" - ] - }, - { - "type": { - "value": "PanelSpriteObject::Height" - }, - "parameters": [ - "Background", - "=", - "Height" - ] - }, - { - "type": { - "value": "TiledUnitsBar::TiledUnitsBar::CenterBar" - }, - "parameters": [ - "Object", - "" - ] - } - ], - "variables": [ - { - "name": "Width", - "type": "number", - "value": 0 - }, - { - "name": "Height", - "type": "number", - "value": 0 - } + "type": { + "value": "ModVarObjet" + }, + "parameters": [ + "Background", + "Width", + "=", + "Object.Width()" + ] + }, + { + "type": { + "value": "ModVarObjet" + }, + "parameters": [ + "Background", + "Height", + "=", + "Object.Height()" + ] + }, + { + "type": { + "value": "ScalableCapability::ScalableBehavior::SetValue" + }, + "parameters": [ + "Object", + "Scale", + "=", + "1" + ] + }, + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetWidth" + }, + "parameters": [ + "Background", + "Resizable", + "=", + "Background.Variable(Width)" + ] + }, + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetHeight" + }, + "parameters": [ + "Background", + "Resizable", + "=", + "Background.Variable(Height)" + ] + }, + { + "type": { + "value": "TiledUnitsBar::TiledUnitsBar::CenterBar" + }, + "parameters": [ + "Object", + "" ] } ] @@ -26052,7 +21490,7 @@ "name": "ScreenWrap", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/monitor-screenshot.svg", "shortDescription": "Teleport object when it moves off the screen and immediately appear on the opposite side while maintaining speed and trajectory.", - "version": "0.2.5", + "version": "0.2.4", "description": [ "The teleport happens when the center point of the object crosses a border (this can be adjusted with an offset).", "By default, the borders of the wrapping area match the screen size, but they can alo be changed.", @@ -26228,7 +21666,7 @@ "parameters": [ "Object", "<", - "BorderLeft - (Object.Width()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderLeft() - (Object.Width()/2) - Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -26240,7 +21678,7 @@ "parameters": [ "Object", "=", - "BorderRight - (Object.Width()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderRight() - (Object.Width()/2) + Object.Behavior::PropertyTriggerOffset()" ] } ] @@ -26255,7 +21693,7 @@ "parameters": [ "Object", ">", - "BorderRight - (Object.Width()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderRight() - (Object.Width()/2) + Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -26267,7 +21705,7 @@ "parameters": [ "Object", "=", - "BorderLeft - (Object.Width()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderLeft() - (Object.Width()/2) - Object.Behavior::PropertyTriggerOffset()" ] } ] @@ -26299,7 +21737,7 @@ "parameters": [ "Object", "<", - "BorderTop - (Object.Height()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderTop() - (Object.Height()/2) - Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -26311,7 +21749,7 @@ "parameters": [ "Object", "=", - "BorderBottom - (Object.Height()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderBottom() - (Object.Height()/2) + Object.Behavior::PropertyTriggerOffset()" ] } ] @@ -26326,7 +21764,7 @@ "parameters": [ "Object", ">", - "BorderBottom - (Object.Height()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderBottom() - (Object.Height()/2) + Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -26338,7 +21776,7 @@ "parameters": [ "Object", "=", - "BorderTop - (Object.Height()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderTop() - (Object.Height()/2) - Object.Behavior::PropertyTriggerOffset()" ] } ] @@ -26682,7 +22120,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderTop" + "Object.Behavior::PropertyBorderTop()" ] } ] @@ -26722,7 +22160,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderLeft" + "Object.Behavior::PropertyBorderLeft()" ] } ] @@ -26762,7 +22200,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderRight" + "Object.Behavior::PropertyBorderRight()" ] } ] @@ -26802,7 +22240,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderBottom" + "Object.Behavior::PropertyBorderBottom()" ] } ] @@ -26842,7 +22280,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "TriggerOffset" + "Object.Behavior::PropertyTriggerOffset()" ] } ] @@ -26885,7 +22323,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -26930,7 +22368,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -26975,7 +22413,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -27020,7 +22458,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -27065,7 +22503,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -27326,7 +22764,7 @@ "parameters": [ "Object", "<", - "BorderLeft - (Object.Width()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderLeft() - (Object.Width()/2) - Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -27348,7 +22786,7 @@ "parameters": [ "Object", "=", - "BorderRight - (Object.Width()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderRight() - (Object.Width()/2) + Object.Behavior::PropertyTriggerOffset()" ] }, { @@ -27373,7 +22811,7 @@ "parameters": [ "Object", ">", - "BorderRight - (Object.Width()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderRight() - (Object.Width()/2) + Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -27395,7 +22833,7 @@ "parameters": [ "Object", "=", - "BorderLeft - (Object.Width()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderLeft() - (Object.Width()/2) - Object.Behavior::PropertyTriggerOffset()" ] }, { @@ -27438,7 +22876,7 @@ "parameters": [ "Object", "<", - "BorderTop - (Object.Height()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderTop() - (Object.Height()/2) - Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -27460,7 +22898,7 @@ "parameters": [ "Object", "=", - "BorderBottom - (Object.Height()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderBottom() - (Object.Height()/2) + Object.Behavior::PropertyTriggerOffset()" ] }, { @@ -27485,7 +22923,7 @@ "parameters": [ "Object", ">", - "BorderBottom - (Object.Height()/2) + TriggerOffset" + "Object.Behavior::PropertyBorderBottom() - (Object.Height()/2) + Object.Behavior::PropertyTriggerOffset()" ] } ], @@ -27507,7 +22945,7 @@ "parameters": [ "Object", "=", - "BorderTop - (Object.Height()/2) - TriggerOffset" + "Object.Behavior::PropertyBorderTop() - (Object.Height()/2) - Object.Behavior::PropertyTriggerOffset()" ] }, { @@ -27861,7 +23299,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderTop" + "Object.Behavior::PropertyBorderTop()" ] } ] @@ -27901,7 +23339,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderLeft" + "Object.Behavior::PropertyBorderLeft()" ] } ] @@ -27941,7 +23379,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderRight" + "Object.Behavior::PropertyBorderRight()" ] } ] @@ -27981,7 +23419,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "BorderBottom" + "Object.Behavior::PropertyBorderBottom()" ] } ] @@ -28021,7 +23459,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "TriggerOffset" + "Object.Behavior::PropertyTriggerOffset()" ] } ] @@ -28064,7 +23502,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -28109,7 +23547,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -28154,7 +23592,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -28199,7 +23637,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -28244,7 +23682,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"Value\")" ] } ] @@ -28351,7 +23789,7 @@ "Object", "RequiredPhysicsBehavior", "=", - "AngularVelocity" + "Object.Behavior::PropertyAngularVelocity()" ] }, { @@ -28362,7 +23800,7 @@ "Object", "RequiredPhysicsBehavior", "=", - "LinearVelocityX" + "Object.Behavior::PropertyLinearVelocityX()" ] }, { @@ -28373,7 +23811,7 @@ "Object", "RequiredPhysicsBehavior", "=", - "LinearVelocityY" + "Object.Behavior::PropertyLinearVelocityY()" ] } ] @@ -28521,7 +23959,7 @@ "name": "AdvancedJump", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/Sports and Fitness/Sports and Fitness_training_running_run.svg", "shortDescription": "Let platformer characters: air jump, wall jump wall sliding, coyote time and dashing.", - "version": "0.1.4", + "version": "0.1.2", "description": [ "This extension provides behaviors to:", "", @@ -28733,7 +24171,7 @@ "Object", "\"__CoyoteTime_CoyoteJump\"", ">=", - "CoyoteTimeFrameDuration" + "Object.Behavior::PropertyCoyoteTimeFrameDuration()" ] } ], @@ -28970,7 +24408,7 @@ "value": "DebuggerTools::ConsoleLog" }, "parameters": [ - "\"Floor jump: \" + ToString(AirJumpCountMaximum - AirJumpCount) + \" + 0\"", + "\"Floor jump: \" + ToString(Object.Behavior::PropertyAirJumpCountMaximum() - Object.Behavior::PropertyAirJumpCount()) + \" + 0\"", "\"info\"", "\"AirJump\"" ] @@ -29094,7 +24532,7 @@ "value": "DebuggerTools::ConsoleLog" }, "parameters": [ - "\"Jump released: \" + ToString(AirJumpCountMaximum - AirJumpCount) + \" + 0\"", + "\"Jump released: \" + ToString(Object.Behavior::PropertyAirJumpCountMaximum() - Object.Behavior::PropertyAirJumpCount()) + \" + 0\"", "\"info\"", "\"AirJump\"" ] @@ -29222,7 +24660,7 @@ "Object", "Behavior", "<", - "AirJumpCountMaximum" + "Object.Behavior::PropertyAirJumpCountMaximum()" ] }, { @@ -29278,7 +24716,7 @@ "value": "DebuggerTools::ConsoleLog" }, "parameters": [ - "\"Jump allowed: \" + ToString(AirJumpCountMaximum - AirJumpCount) + \" + 1\"", + "\"Jump allowed: \" + ToString(Object.Behavior::PropertyAirJumpCountMaximum() - Object.Behavior::PropertyAirJumpCount()) + \" + 1\"", "\"info\"", "\"AirJump\"" ] @@ -29491,7 +24929,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"CoyoteTime\")" ] } ] @@ -29512,7 +24950,7 @@ { "description": "Duration", "longDescription": "Coyote time duration in seconds.", - "name": "Value", + "name": "CoyoteTime", "type": "expression" } ], @@ -29684,7 +25122,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "AirJumpCountMaximum" + "Object.Behavior::PropertyAirJumpCountMaximum()" ] } ] @@ -29736,7 +25174,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "max(0, AirJumpCountMaximum - AirJumpCount)" + "max(0, Object.Behavior::PropertyAirJumpCountMaximum() - Object.Behavior::PropertyAirJumpCount())" ] } ] @@ -29772,7 +25210,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "clamp(1 + AirJumpCountMaximum - AirJumpCount, 0, AirJumpCountMaximum)" + "clamp(1 + Object.Behavior::PropertyAirJumpCountMaximum() - Object.Behavior::PropertyAirJumpCount(), 0, Object.Behavior::PropertyAirJumpCountMaximum())" ] } ] @@ -29816,7 +25254,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"AirJumpCountMaximum\")" ] } ] @@ -29836,7 +25274,7 @@ }, { "description": "Number of air jumps", - "name": "Value", + "name": "AirJumpCountMaximum", "type": "expression" } ], @@ -30789,7 +26227,7 @@ "parameters": [ "Object", "Behavior", - "JumpTimeFrame", + "Object.Behavior::PropertyJumpTimeFrame()", "" ] } @@ -30820,7 +26258,7 @@ "parameters": [ "Object", "Behavior", - "JumpTimeFrame", + "Object.Behavior::PropertyJumpTimeFrame()", "\"Jump\"", "" ] @@ -30921,7 +26359,7 @@ "Object", "PlatformerCharacter", "=", - "-WallJumpSpeedX" + "-Object.Behavior::PropertyWallJumpSpeedX()" ] } ] @@ -30949,7 +26387,7 @@ "Object", "PlatformerCharacter", "=", - "WallJumpSpeedX" + "Object.Behavior::PropertyWallJumpSpeedX()" ] } ] @@ -31007,7 +26445,7 @@ "Object", "\"__WallJump_TimeFromJumpStart\"", "<=", - "SideSpeedSustainTime" + "Object.Behavior::PropertySideSpeedSustainTime()" ] } ], @@ -31035,7 +26473,7 @@ "Object", "PlatformerCharacter", "=", - "-WallJumpSpeedX" + "-Object.Behavior::PropertyWallJumpSpeedX()" ] } ] @@ -31063,7 +26501,7 @@ "Object", "PlatformerCharacter", "=", - "WallJumpSpeedX" + "Object.Behavior::PropertyWallJumpSpeedX()" ] } ] @@ -31182,7 +26620,7 @@ "parameters": [ "Object", "Behavior", - "WallSlidingSpeedAbsorption", + "Object.Behavior::PropertyWallSlidingSpeedAbsorption()", "" ] }, @@ -31699,7 +27137,7 @@ "Object", "\"__WallJump_IsAgainstWall\"", "<=", - "TimeFrame" + "GetArgumentAsNumber(\"TimeFrame\")" ] } ], @@ -31755,7 +27193,7 @@ }, "parameters": [ "Object", - "\"__WallJump_KeyPressed_\" + Key" + "\"__WallJump_KeyPressed_\" + GetArgumentAsString(\"Key\")" ] } ] @@ -31801,7 +27239,7 @@ }, "parameters": [ "Object", - "\"__WallJump_KeyPressed_\" + Key" + "\"__WallJump_KeyPressed_\" + GetArgumentAsString(\"Key\")" ] } ] @@ -31860,9 +27298,9 @@ }, "parameters": [ "Object", - "\"__WallJump_KeyPressed_\" + Key", + "\"__WallJump_KeyPressed_\" + GetArgumentAsString(\"Key\")", "<=", - "TimeFrame" + "GetArgumentAsNumber(\"TimeFrame\")" ] } ], @@ -31946,7 +27384,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "WallJumpAccelerationX", + "Object.Behavior::PropertyWallJumpAccelerationX()", "\"WallJumpLeap\"", "" ] @@ -31964,7 +27402,7 @@ "Object", "PlatformerCharacter", "<", - "WallJumpSpeedX" + "Object.Behavior::PropertyWallJumpSpeedX()" ] } ], @@ -31976,7 +27414,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "WallJumpSpeedX", + "Object.Behavior::PropertyWallJumpSpeedX()", "\"WallJumpLeap\"", "" ] @@ -32086,7 +27524,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "WallSlidingGravity", + "Object.Behavior::PropertyWallSlidingGravity()", "\"WallJumpSliding\"", "" ] @@ -32098,7 +27536,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "WallSlidingMaxFallingSpeed", + "Object.Behavior::PropertyWallSlidingMaxFallingSpeed()", "\"WallJumpSliding\"", "" ] @@ -32195,7 +27633,7 @@ "Object", "PlatformerCharacter", "=", - "max(WallSlidingFallingSpeedMin, Object.PlatformerCharacter::CurrentFallSpeed() - Object.PlatformerCharacter::CurrentJumpSpeed() - SpeedAbsorption) + Object.PlatformerCharacter::CurrentJumpSpeed()" + "max(Object.Behavior::PropertyWallSlidingFallingSpeedMin(), Object.PlatformerCharacter::CurrentFallSpeed() - Object.PlatformerCharacter::CurrentJumpSpeed() - GetArgumentAsNumber(\"SpeedAbsorption\")) + Object.PlatformerCharacter::CurrentJumpSpeed()" ] } ] @@ -32238,7 +27676,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "JumpTimeFrame" + "Object.Behavior::PropertyJumpTimeFrame()" ] } ] @@ -32282,7 +27720,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"JumpTimeFrame\")" ] } ] @@ -32302,8 +27740,8 @@ }, { "description": "Jump detection time frame (in seconds)", - "name": "Value", - "type": "expression" + "name": "JumpTimeFrame", + "type": "objectList" } ], "objectGroups": [] @@ -32325,7 +27763,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "WallJumpSpeedX" + "Object.Behavior::PropertyWallJumpSpeedX()" ] } ] @@ -32369,7 +27807,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"WallJumpSpeedX\")" ] } ] @@ -32389,7 +27827,7 @@ }, { "description": "Side speed", - "name": "Value", + "name": "WallJumpSpeedX", "type": "expression" } ], @@ -32412,7 +27850,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "WallJumpAccelerationX" + "Object.Behavior::PropertyWallJumpAccelerationX()" ] } ] @@ -32456,7 +27894,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"WallJumpAccelerationX\")" ] } ] @@ -32476,7 +27914,7 @@ }, { "description": "Side acceleration", - "name": "Value", + "name": "WallJumpAccelerationX", "type": "expression" } ], @@ -32499,7 +27937,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "WallSlidingGravity" + "Object.Behavior::PropertyWallSlidingGravity()" ] } ] @@ -32543,7 +27981,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"WallSlidingGravity\")" ] } ] @@ -32563,7 +28001,7 @@ }, { "description": "Gravity", - "name": "Value", + "name": "WallSlidingGravity", "type": "expression" } ], @@ -32586,7 +28024,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "WallSlidingMaxFallingSpeed" + "Object.Behavior::PropertyWallSlidingMaxFallingSpeed()" ] } ] @@ -32630,7 +28068,7 @@ "Object", "Behavior", "=", - "Value" + "GetArgumentAsNumber(\"WallSlidingMaxFallingSpeed\")" ] } ] @@ -32650,7 +28088,7 @@ }, { "description": "Maximum falling speed", - "name": "Value", + "name": "WallSlidingMaxFallingSpeed", "type": "expression" } ], @@ -32673,7 +28111,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "WallSlidingSpeedAbsorption" + "Object.Behavior::PropertyWallSlidingSpeedAbsorption()" ] } ] @@ -32717,7 +28155,7 @@ "Object", "Behavior", "=", - "Value" + "Firebase::GetRemoteConfigNumber(\"WallSlidingSpeedAbsorption\")" ] } ] @@ -32737,7 +28175,7 @@ }, { "description": "Impact speed absorption", - "name": "Value", + "name": "WallSlidingSpeedAbsorption", "type": "expression" } ], @@ -33075,7 +28513,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "DiveMaxFallingSpeed", + "Object.Behavior::PropertyDiveMaxFallingSpeed()", "\"DiveDash\"", "" ] @@ -33087,7 +28525,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "DiveGravity", + "Object.Behavior::PropertyDiveGravity()", "\"DiveDash\"", "" ] @@ -33100,7 +28538,7 @@ "Object", "PlatformerCharacter", "=", - "DiveInitialFallingSpeed" + "Object.Behavior::PropertyDiveInitialFallingSpeed()" ] }, { @@ -33440,7 +28878,7 @@ "Object", "\"__PlatformerDash_CoolDown\"", "<", - "CoolDownDuration" + "Object.Behavior::PropertyCoolDownDuration()" ] } ], @@ -33615,7 +29053,7 @@ "Object", "\"__PlatformerDash_SustainTime\"", ">", - "DashSustainDurationMax" + "Object.Behavior::PropertyDashSustainDurationMax()" ] }, { @@ -33642,7 +29080,7 @@ "Object", "\"__PlatformerDash_SustainTime\"", "<=", - "DashSustainDurationMin" + "Object.Behavior::PropertyDashSustainDurationMin()" ] } ] @@ -33668,7 +29106,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "DashDecceleration", + "Object.Behavior::PropertyDashDecceleration()", "\"HorizontalDash\"", "" ] @@ -33697,7 +29135,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "DashGravity", + "Object.Behavior::PropertyDashGravity()", "\"HorizontalDashGravity\"", "" ] @@ -33978,7 +29416,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "DashSustainGravity", + "Object.Behavior::PropertyDashSustainGravity()", "\"HorizontalDashGravity\"", "" ] @@ -33990,7 +29428,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "DashSustainSpeedMax", + "Object.Behavior::PropertyDashSustainSpeedMax()", "\"HorizontalDash\"", "" ] @@ -34002,7 +29440,7 @@ "parameters": [ "Object", "PlatformerConfigurationStack", - "DashSustainAcceleration", + "Object.Behavior::PropertyDashSustainAcceleration()", "\"HorizontalDash\"", "" ] @@ -34053,7 +29491,7 @@ "Object", "PlatformerCharacter", "=", - "-DashInitialSpeed" + "-Object.Behavior::PropertyDashInitialSpeed()" ] } ] @@ -34081,7 +29519,7 @@ "Object", "PlatformerCharacter", "=", - "DashInitialSpeed" + "Object.Behavior::PropertyDashInitialSpeed()" ] } ] @@ -34805,8 +30243,8 @@ "Object", "Behavior", "\"gravity\"", - "SettingValue", - "Identifier", + "GetArgumentAsNumber(\"SettingValue\")", + "GetArgumentAsString(\"Identifier\")", "" ] }, @@ -34818,7 +30256,7 @@ "Object", "PlatformerCharacter", "=", - "SettingValue" + "GetArgumentAsNumber(\"SettingValue\")" ] } ] @@ -34868,8 +30306,8 @@ "Object", "Behavior", "\"deceleration\"", - "SettingValue", - "Identifier", + "GetArgumentAsNumber(\"SettingValue\")", + "GetArgumentAsString(\"Identifier\")", "" ] }, @@ -34881,7 +30319,7 @@ "Object", "PlatformerCharacter", "=", - "SettingValue" + "GetArgumentAsNumber(\"SettingValue\")" ] } ] @@ -34931,8 +30369,8 @@ "Object", "Behavior", "\"maxSpeed\"", - "SettingValue", - "Identifier", + "GetArgumentAsNumber(\"SettingValue\")", + "GetArgumentAsString(\"Identifier\")", "" ] }, @@ -34944,7 +30382,7 @@ "Object", "PlatformerCharacter", "=", - "SettingValue" + "GetArgumentAsNumber(\"SettingValue\")" ] } ] @@ -34994,8 +30432,8 @@ "Object", "Behavior", "\"acceleration\"", - "SettingValue", - "Identifier", + "GetArgumentAsNumber(\"SettingValue\")", + "GetArgumentAsString(\"Identifier\")", "" ] }, @@ -35007,7 +30445,7 @@ "Object", "PlatformerCharacter", "=", - "SettingValue" + "GetArgumentAsNumber(\"SettingValue\")" ] } ] @@ -35057,8 +30495,8 @@ "Object", "Behavior", "\"maxFallSpeed\"", - "SettingValue", - "Identifier", + "GetArgumentAsNumber(\"SettingValue\")", + "GetArgumentAsString(\"Identifier\")", "" ] }, @@ -35070,7 +30508,7 @@ "Object", "PlatformerCharacter", "=", - "SettingValue", + "GetArgumentAsNumber(\"SettingValue\")", "yes" ] } @@ -35131,7 +30569,7 @@ "name": "PanelSpriteButton", "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/Interface Elements/Interface Elements_interface_ui_button_ok_cta_clock_tap.svg", "shortDescription": "A button that can be customized.", - "version": "1.4.6", + "version": "1.4.4", "description": [ "The button can be customized with a background for each state and a label. It handles user interactions and a simple condition can be used to check if it is clicked.", "", @@ -35337,8 +30775,8 @@ }, "parameters": [ "Object", - "TouchX(TouchId, Object.Layer(), 0)", - "TouchY(TouchId, Object.Layer(), 0)" + "TouchX(Object.Behavior::PropertyTouchId(), Object.Layer(), 0)", + "TouchY(Object.Behavior::PropertyTouchId(), Object.Layer(), 0)" ] } ], @@ -35408,8 +30846,8 @@ }, "parameters": [ "Object", - "TouchX(StartedTouchOrMouseId(Index), Object.Layer(), 0)", - "TouchY(StartedTouchOrMouseId(Index), Object.Layer(), 0)" + "TouchX(StartedTouchOrMouseId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)", + "TouchY(StartedTouchOrMouseId(Object.Behavior::PropertyIndex()), Object.Layer(), 0)" ] } ], @@ -35422,7 +30860,7 @@ "Object", "Behavior", "=", - "StartedTouchOrMouseId(Index)" + "StartedTouchOrMouseId(Object.Behavior::PropertyIndex())" ] }, { @@ -35695,7 +31133,7 @@ }, "parameters": [ "", - "TouchId" + "Object.Behavior::PropertyTouchId()" ] } ], @@ -36234,7 +31672,7 @@ "value": "SetReturnNumber" }, "parameters": [ - "TouchId" + "Object.Behavior::PropertyTouchId()" ] } ] @@ -36970,83 +32408,66 @@ ] } ], - "actions": [], - "events": [ + "actions": [ { - "type": "BuiltinCommonInstructions::Standard", - "conditions": [], - "actions": [ - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Width", - "=", - "Object.Width()" - ] - }, - { - "type": { - "value": "SetNumberVariable" - }, - "parameters": [ - "Height", - "=", - "Object.Height()" - ] - }, - { - "type": { - "value": "PanelSpriteButton::Scale" - }, - "parameters": [ - "Object", - "=", - "1" - ] - }, - { - "type": { - "value": "PanelSpriteObject::Width" - }, - "parameters": [ - "Background", - "=", - "Width" - ] - }, - { - "type": { - "value": "PanelSpriteObject::Height" - }, - "parameters": [ - "Background", - "=", - "Height" - ] - }, - { - "type": { - "value": "PanelSpriteButton::PanelSpriteButton::CenterLabel" - }, - "parameters": [ - "Object", - "" - ] - } - ], - "variables": [ - { - "name": "Width", - "type": "number", - "value": 0 - }, - { - "name": "Height", - "type": "number", - "value": 0 - } + "type": { + "value": "ModVarObjet" + }, + "parameters": [ + "Idle", + "Width", + "=", + "Object.Width()" + ] + }, + { + "type": { + "value": "ModVarObjet" + }, + "parameters": [ + "Idle", + "Height", + "=", + "Object.Height()" + ] + }, + { + "type": { + "value": "PanelSpriteButton::Scale" + }, + "parameters": [ + "Object", + "=", + "1" + ] + }, + { + "type": { + "value": "PanelSpriteObject::Width" + }, + "parameters": [ + "Background", + "=", + "Idle.Variable(Width)" + ] + }, + { + "type": { + "value": "PanelSpriteObject::Height" + }, + "parameters": [ + "Background", + "=", + "Idle.Variable(Height)" + ] + }, + { + "type": { + "value": "PanelSpriteButton::PanelSpriteButton::CenterLabel" + }, + "parameters": [ + "Object", + "" ] } ] @@ -37313,7 +32734,7 @@ "parameters": [ "Label", "=", - "LabelText" + "GetArgumentAsString(\"LabelText\")" ] }, { @@ -37872,6 +33293,536 @@ "instances": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Player avatar", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQoJLnN0MXtmaWxsOm5vbmU7c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjI7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjEwO30NCjwvc3R5bGU+DQo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMjIuNywyMi45Yy0yLjItMC41LTMuNy0yLjUtMy43LTQuN2MxLjgtMSwzLTMsMy01LjJ2MGMwLTEuMSwwLjktMiwyLTJoMGwwLTIuM2MwLTIuOC0yLjEtNS40LTQuOS01LjcNCgljLTItMC4yLTMuOCwwLjYtNC45LDIuMWMtMC44LTAuMi0xLjYtMC4xLTIuNiwwLjZjLTEsMC44LTEuNiwyLTEuNiwzLjNsMCwxdjEuNXYxLjNjMCwyLjIsMS4yLDQuMywzLDUuNHYwYzAsMi4zLTEuNiw0LjItMy44LDQuOA0KCWMtMi42LDAuNy00LjUsMi44LTUuMSw1LjRDNC4xLDI4LjcsNC4zLDI5LDQuNywyOWwyMi43LDBjMC40LDAsMC42LTAuMywwLjUtMC43QzI3LjMsMjUuNywyNS4zLDIzLjYsMjIuNywyMi45eiIvPg0KPC9zdmc+DQo=", + "name": "PlayerAvatar", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/Users/1f89f002e87f1e836320f69725d21e3294e7e2e18ff7dd645c6973e9775d24c3_Users_avatar_user_profile_male.svg", + "shortDescription": "Display player avatars according to their GDevelop account.", + "version": "1.0.0", + "description": "An object that displays a player avatar according to their GDevelop account. It can be used for multiplayer games.", + "tags": [ + "UI", + "Avatar", + "GDevelop" + ], + "authorIds": [ + "2OwwM8ToR9dx9RJ2sAKTcrLmCB92" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [ + { + "description": "Return the UserID from a lobby player number.", + "fullName": "UserID", + "functionType": "StringExpression", + "name": "UserID", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "/** @type {number} */", + "const parameterPlayerNumber = eventsFunctionContext.getArgument(\"PlayerNumber\");", + "", + "eventsFunctionContext.returnValue = gdjs.multiplayerMessageManager ? gdjs.multiplayerMessageManager.getPlayerId(parameterPlayerNumber) : \"\";", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Lobby player number", + "name": "PlayerNumber", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onFirstSceneLoaded", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "//Define an new private object javascript for the Avatar extension", + "gdjs._extensionAvatar = {};", + "", + "gdjs._extensionAvatar.getGDevelopProfile = async function (url) {", + "", + " // Get the URL of the avatar from the GDevelop profile API", + " try {", + " const response = await fetch(url);", + " if (!response.ok) {", + " throw new Error(`Response status: ${response.status}`);", + " }", + "", + " const json = await response.json();", + " return json;", + "", + " } catch (error) {", + " console.error(error.message);", + " return null;", + " }", + "}", + "" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": true + } + ], + "parameters": [], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 100, + "areaMaxY": 100, + "areaMaxZ": 64, + "areaMinX": 0, + "areaMinY": 0, + "areaMinZ": 0, + "defaultName": "Avatar", + "description": "Display a player avatar according to their GDevelop account.", + "fullName": "Multiplayer Avatar", + "isUsingLegacyInstancesRenderer": false, + "name": "PlayerAvatar", + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "PlayerAvatar::PlayerAvatar::PropertyBorderEnabled" + }, + "parameters": [ + "Object" + ] + } + ], + "actions": [ + { + "type": { + "value": "Delete" + }, + "parameters": [ + "Border", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "PlayerNumber", + "!=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "PlayerAvatar::PlayerAvatar::SetUserID" + }, + "parameters": [ + "Object", + "=", + "PlayerAvatar::UserID(PlayerNumber)", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "PlayerAvatar::PlayerAvatar", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "description": "the player unique ID of the avatar.", + "fullName": "Player unique ID", + "functionType": "ExpressionAndCondition", + "name": "UserID", + "sentence": "the player unique ID", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnString" + }, + "parameters": [ + "UserID" + ] + } + ] + } + ], + "expressionType": { + "type": "string" + }, + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "PlayerAvatar::PlayerAvatar", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "getterName": "UserID", + "name": "SetUserID", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "Value", + "!=", + "UserID" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "UserID", + "=", + "Value" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "// Check if there is no multiplayer in game, exit the function.", + "if (!gdjs.multiplayerMessageManager) return;", + "", + "/** @type {string} */", + "const parameterUserID = eventsFunctionContext.getArgument(\"Value\");", + "", + "// If the userID isn't valid, exit the function.", + "if (parameterUserID.length < 20 ||", + " parameterUserID.length > 36) return;", + "", + "// Get the PixiJS renderer of the Avatar Sprite", + "const spriteRenderer = objects[0].getRendererObject();", + "", + "// Build the URL to request to the API the profile from a GDevelop userID.", + "const url = \"https://api.gdevelop.io/user/user-public-profile/\" + parameterUserID;", + "", + "// Get the reponse from the API when possible then change the texture by the image from the GDevelop user profile.", + "gdjs._extensionAvatar.getGDevelopProfile(url).then((json) => {", + " const baseTexture = PIXI.BaseTexture.from(json.iconUrl.split(\"?\")[0] + \"?s=200\");", + " spriteRenderer.texture = new PIXI.Texture(baseTexture);", + "});", + "" + ], + "parameterObjects": "Avatar", + "useStrict": true, + "eventsSheetExpanded": true + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "PlayerAvatar::PlayerAvatar", + "type": "object" + } + ], + "objectGroups": [] + } + ], + "propertyDescriptors": [ + { + "value": "0", + "type": "Number", + "unit": "Dimensionless", + "label": "Lobby player number", + "description": "", + "group": "", + "extraInformation": [], + "name": "PlayerNumber" + }, + { + "value": "true", + "type": "Boolean", + "label": "Border enabled", + "description": "Enable the border on the avatar.", + "group": "", + "extraInformation": [], + "name": "BorderEnabled" + }, + { + "value": "", + "type": "String", + "label": "Player unique ID", + "description": "", + "group": "", + "extraInformation": [], + "hidden": true, + "name": "UserID" + } + ], + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Avatar", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": true, + "image": "assets\\unknown.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 0, + "y": 0 + }, + "centerPoint": { + "automatic": true, + "name": "centre", + "x": 0, + "y": 0 + }, + "customCollisionMask": [ + [ + { + "x": 0, + "y": 0 + }, + { + "x": 200, + "y": 0 + }, + { + "x": 200, + "y": 200 + }, + { + "x": 0, + "y": 200 + } + ] + ] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Border", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Border", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "metadata": "{\"pskl\":{}}", + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": true, + "image": "assets\\avatar_border_white.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 0, + "y": 0 + }, + "centerPoint": { + "automatic": true, + "name": "centre", + "x": 0, + "y": 0 + }, + "customCollisionMask": [ + [ + { + "x": 0, + "y": 0 + }, + { + "x": 200, + "y": 0 + }, + { + "x": 200, + "y": 200 + }, + { + "x": 0, + "y": 200 + } + ] + ] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Avatar" + }, + { + "objectName": "Border" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera3DFarPlaneDistance": 10000, + "camera3DFieldOfView": 45, + "camera3DNearPlaneDistance": 3, + "cameraType": "", + "followBaseLayerCamera": false, + "isLightingLayer": false, + "isLocked": false, + "name": "", + "renderingType": "", + "visibility": true, + "cameras": [ + { + "defaultSize": true, + "defaultViewport": true, + "height": 0, + "viewportBottom": 1, + "viewportLeft": 0, + "viewportRight": 1, + "viewportTop": 0, + "width": 0 + } + ], + "effects": [] + } + ], + "instances": [ + { + "angle": 0, + "customSize": true, + "depth": 0, + "height": 100, + "keepRatio": true, + "layer": "", + "name": "Avatar", + "persistentUuid": "39e3ba66-0223-4d8b-a78e-a45d367c277d", + "width": 100, + "x": 0, + "y": 0, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "depth": 0, + "height": 100, + "keepRatio": true, + "layer": "", + "name": "Border", + "persistentUuid": "4dc03ef7-9424-4db7-b752-a44ba07ddd10", + "width": 100, + "x": 0, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] } ], "externalLayouts": []