diff --git a/examples/starting-expanded-first-person-farming/assets/Dot Crosshair Center.png b/examples/starting-expanded-first-person-farming/assets/Dot Crosshair Center.png new file mode 100644 index 000000000..36da75f78 Binary files /dev/null and b/examples/starting-expanded-first-person-farming/assets/Dot Crosshair Center.png differ diff --git a/examples/starting-expanded-first-person-farming/assets/Dot Crosshair Hit Marker.png b/examples/starting-expanded-first-person-farming/assets/Dot Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-expanded-first-person-farming/assets/Dot Crosshair Hit Marker.png differ diff --git a/examples/starting-expanded-first-person-farming/assets/crosshair037.png b/examples/starting-expanded-first-person-farming/assets/crosshair037.png deleted file mode 100644 index 73c9f032d..000000000 Binary files a/examples/starting-expanded-first-person-farming/assets/crosshair037.png and /dev/null differ diff --git a/examples/starting-expanded-first-person-farming/starting-expanded-first-person-farming.json b/examples/starting-expanded-first-person-farming/starting-expanded-first-person-farming.json index faf1fcc19..f69c2264d 100644 --- a/examples/starting-expanded-first-person-farming/starting-expanded-first-person-farming.json +++ b/examples/starting-expanded-first-person-farming/starting-expanded-first-person-farming.json @@ -150,14 +150,6 @@ "name": "assets\\NotoSansArabicUI-Black.ttf", "userAdded": false }, - { - "file": "assets/crosshair037.png", - "kind": "image", - "metadata": "", - "name": "assets\\crosshair037.png", - "smoothed": false, - "userAdded": false - }, { "file": "assets/StartingInventorySlot.png", "kind": "image", @@ -492,6 +484,22 @@ "metadata": "", "name": "assets/Rock Moss 3.glb", "userAdded": true + }, + { + "file": "assets/Dot Crosshair Center.png", + "kind": "image", + "name": "Dot Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Dot Crosshair Hit Marker.png", + "kind": "image", + "name": "Dot Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -3046,65 +3054,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "persistentUuid": "ec6994ff-090b-47db-92e5-2a56e358b21d", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Dot Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\crosshair037.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 32, - "y": 32 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 20, - "y": 20 - }, - { - "x": 44, - "y": 20 - }, - { - "x": 44, - "y": 44 - }, - { - "x": 20, - "y": 44 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "80;255;140", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 0, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "ec6994ff-090b-47db-92e5-2a56e358b21d" }, { "assetStoreId": "", @@ -7856,7 +7822,7 @@ "elevation": 45, "frustumSize": 4000, "intensity": 0.75, - "minimumShadowBias": 0.00001, + "minimumShadowBias": 1e-05, "rotation": 30, "shadowDistance": 2000, "shadowNormalBias": 1 @@ -59621,7 +59587,1579 @@ ] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 16.0, + "areaMaxY": 16.0, + "areaMaxZ": 64, + "areaMinX": -16.0, + "areaMinY": -16.0, + "areaMinZ": 0, + "name": "Dot Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 6.5, + "y": 6.5 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 6.5, + "y": 6.5 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "cda8374c-c49c-42fc-915d-f7e2551fa9cb", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "3f624e16-fa34-4faf-b2c1-bb519680c59e", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Arm.png b/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Arm.png new file mode 100644 index 000000000..2be27b1f9 Binary files /dev/null and b/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Arm.png differ diff --git a/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Center.png b/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Center.png new file mode 100644 index 000000000..21d8a0de3 Binary files /dev/null and b/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Center.png differ diff --git a/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Hit Marker.png b/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-expanded-first-person-shooter-enemies/assets/Classic Crosshair Hit Marker.png differ diff --git a/examples/starting-expanded-first-person-shooter-enemies/assets/Crosshair.png b/examples/starting-expanded-first-person-shooter-enemies/assets/Crosshair.png deleted file mode 100644 index 7bdc27d3b..000000000 Binary files a/examples/starting-expanded-first-person-shooter-enemies/assets/Crosshair.png and /dev/null differ diff --git a/examples/starting-expanded-first-person-shooter-enemies/starting-expanded-first-person-shooter-enemies.json b/examples/starting-expanded-first-person-shooter-enemies/starting-expanded-first-person-shooter-enemies.json index 73343a68a..11b305c5b 100644 --- a/examples/starting-expanded-first-person-shooter-enemies/starting-expanded-first-person-shooter-enemies.json +++ b/examples/starting-expanded-first-person-shooter-enemies/starting-expanded-first-person-shooter-enemies.json @@ -159,14 +159,6 @@ "smoothed": true, "userAdded": false }, - { - "file": "assets/Crosshair.png", - "kind": "image", - "metadata": "", - "name": "assets\\Crosshair.png", - "smoothed": true, - "userAdded": false - }, { "file": "assets/Gunshot.mp3", "kind": "audio", @@ -381,6 +373,30 @@ "metadata": "", "name": "assets/Plant 2.glb", "userAdded": true + }, + { + "file": "assets/Classic Crosshair Center.png", + "kind": "image", + "name": "Classic Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Arm.png", + "kind": "image", + "name": "Classic Crosshair Arm.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Hit Marker.png", + "kind": "image", + "name": "Classic Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -2207,65 +2223,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "persistentUuid": "11ae5291-e969-4aed-8852-989f275b4b5a", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Classic Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\Crosshair.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 64, - "y": 64 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 12, - "y": 12 - }, - { - "x": 116, - "y": 12 - }, - { - "x": 116, - "y": 116 - }, - { - "x": 12, - "y": 116 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "255;255;255", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 20, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "11ae5291-e969-4aed-8852-989f275b4b5a" }, { "adaptCollisionMaskAutomatically": true, @@ -50969,7 +50943,1669 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "name": "Classic Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Arm.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 4.5, + "y": 9.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 4.5, + "y": 9.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 5.0, + "y": 5.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 5.0, + "y": 5.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "1da1d2e9-d37e-486a-a1e4-4295d202522b", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "8399244e-1fdf-4c11-bc8a-c887daf11013", + "width": 0, + "x": 0, + "y": -13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 90, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "6743462d-3bbe-4fc7-b24b-dd38cfa04ddf", + "width": 0, + "x": 13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 180, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "e75b8da6-19d7-4687-bfed-c35be7703e2f", + "width": 0, + "x": 0, + "y": 13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 270, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "0a09c66e-4bc4-46be-ae3e-1ae6a5a4d74e", + "width": 0, + "x": -13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "34c3eab4-7258-480f-82f9-2e09fcc39996", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-expanded-first-person-shooter-horror/assets/Crosshair.png b/examples/starting-expanded-first-person-shooter-horror/assets/Crosshair.png deleted file mode 100644 index 7bdc27d3b..000000000 Binary files a/examples/starting-expanded-first-person-shooter-horror/assets/Crosshair.png and /dev/null differ diff --git a/examples/starting-expanded-first-person-shooter-horror/assets/Dot Crosshair Center.png b/examples/starting-expanded-first-person-shooter-horror/assets/Dot Crosshair Center.png new file mode 100644 index 000000000..36da75f78 Binary files /dev/null and b/examples/starting-expanded-first-person-shooter-horror/assets/Dot Crosshair Center.png differ diff --git a/examples/starting-expanded-first-person-shooter-horror/assets/Dot Crosshair Hit Marker.png b/examples/starting-expanded-first-person-shooter-horror/assets/Dot Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-expanded-first-person-shooter-horror/assets/Dot Crosshair Hit Marker.png differ diff --git a/examples/starting-expanded-first-person-shooter-horror/starting-expanded-first-person-shooter-horror.json b/examples/starting-expanded-first-person-shooter-horror/starting-expanded-first-person-shooter-horror.json index a51a07efc..fa48325e6 100644 --- a/examples/starting-expanded-first-person-shooter-horror/starting-expanded-first-person-shooter-horror.json +++ b/examples/starting-expanded-first-person-shooter-horror/starting-expanded-first-person-shooter-horror.json @@ -151,14 +151,6 @@ "smoothed": true, "userAdded": false }, - { - "file": "assets/Crosshair.png", - "kind": "image", - "metadata": "", - "name": "assets\\Crosshair.png", - "smoothed": true, - "userAdded": false - }, { "file": "assets/Gunshot.mp3", "kind": "audio", @@ -394,6 +386,22 @@ "metadata": "", "name": "assets/Rocks Tall.glb", "userAdded": true + }, + { + "file": "assets/Dot Crosshair Center.png", + "kind": "image", + "name": "Dot Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Dot Crosshair Hit Marker.png", + "kind": "image", + "name": "Dot Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -2352,65 +2360,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "persistentUuid": "4042c849-efac-4735-b45f-c167048b1562", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Dot Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\Crosshair.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 64, - "y": 64 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 12, - "y": 12 - }, - { - "x": 116, - "y": 12 - }, - { - "x": 116, - "y": 116 - }, - { - "x": 12, - "y": 116 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "255;255;255", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 0, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "4042c849-efac-4735-b45f-c167048b1562" }, { "adaptCollisionMaskAutomatically": true, @@ -56806,7 +56772,1579 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 16.0, + "areaMaxY": 16.0, + "areaMaxZ": 64, + "areaMinX": -16.0, + "areaMinY": -16.0, + "areaMinZ": 0, + "name": "Dot Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 6.5, + "y": 6.5 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 6.5, + "y": 6.5 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "cda8374c-c49c-42fc-915d-f7e2551fa9cb", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "3f624e16-fa34-4faf-b2c1-bb519680c59e", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Arm.png b/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Arm.png new file mode 100644 index 000000000..2be27b1f9 Binary files /dev/null and b/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Arm.png differ diff --git a/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Center.png b/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Center.png new file mode 100644 index 000000000..21d8a0de3 Binary files /dev/null and b/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Center.png differ diff --git a/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Hit Marker.png b/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-expanded-first-person-survival-crafting/assets/Classic Crosshair Hit Marker.png differ diff --git a/examples/starting-expanded-first-person-survival-crafting/assets/crosshair037.png b/examples/starting-expanded-first-person-survival-crafting/assets/crosshair037.png deleted file mode 100644 index 73c9f032d..000000000 Binary files a/examples/starting-expanded-first-person-survival-crafting/assets/crosshair037.png and /dev/null differ diff --git a/examples/starting-expanded-first-person-survival-crafting/starting-expanded-first-person-survival-crafting.json b/examples/starting-expanded-first-person-survival-crafting/starting-expanded-first-person-survival-crafting.json index cb6cdfa6f..de437d3a4 100644 --- a/examples/starting-expanded-first-person-survival-crafting/starting-expanded-first-person-survival-crafting.json +++ b/examples/starting-expanded-first-person-survival-crafting/starting-expanded-first-person-survival-crafting.json @@ -158,14 +158,6 @@ "name": "assets\\NotoSansArabicUI-Black.ttf", "userAdded": false }, - { - "file": "assets/crosshair037.png", - "kind": "image", - "metadata": "", - "name": "assets\\crosshair037.png", - "smoothed": false, - "userAdded": false - }, { "file": "assets/StartingInventorySlot.png", "kind": "image", @@ -411,6 +403,30 @@ "metadata": "", "name": "assets/Flowers.glb", "userAdded": true + }, + { + "file": "assets/Classic Crosshair Center.png", + "kind": "image", + "name": "Classic Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Arm.png", + "kind": "image", + "name": "Classic Crosshair Arm.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Hit Marker.png", + "kind": "image", + "name": "Classic Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -3306,64 +3322,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Classic Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\crosshair037.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 32, - "y": 32 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 20, - "y": 20 - }, - { - "x": 44, - "y": 20 - }, - { - "x": 44, - "y": 44 - }, - { - "x": 20, - "y": 44 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "255;255;255", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 20, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "" }, { "assetStoreId": "", @@ -46233,7 +46208,1669 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "name": "Classic Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Arm.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 4.5, + "y": 9.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 4.5, + "y": 9.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 5.0, + "y": 5.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 5.0, + "y": 5.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "1da1d2e9-d37e-486a-a1e4-4295d202522b", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "8399244e-1fdf-4c11-bc8a-c887daf11013", + "width": 0, + "x": 0, + "y": -13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 90, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "6743462d-3bbe-4fc7-b24b-dd38cfa04ddf", + "width": 0, + "x": 13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 180, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "e75b8da6-19d7-4687-bfed-c35be7703e2f", + "width": 0, + "x": 0, + "y": 13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 270, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "0a09c66e-4bc4-46be-ae3e-1ae6a5a4d74e", + "width": 0, + "x": -13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "34c3eab4-7258-480f-82f9-2e09fcc39996", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-first-person-farming/assets/Dot Crosshair Center.png b/examples/starting-first-person-farming/assets/Dot Crosshair Center.png new file mode 100644 index 000000000..36da75f78 Binary files /dev/null and b/examples/starting-first-person-farming/assets/Dot Crosshair Center.png differ diff --git a/examples/starting-first-person-farming/assets/Dot Crosshair Hit Marker.png b/examples/starting-first-person-farming/assets/Dot Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-first-person-farming/assets/Dot Crosshair Hit Marker.png differ diff --git a/examples/starting-first-person-farming/assets/crosshair037.png b/examples/starting-first-person-farming/assets/crosshair037.png deleted file mode 100644 index 73c9f032d..000000000 Binary files a/examples/starting-first-person-farming/assets/crosshair037.png and /dev/null differ diff --git a/examples/starting-first-person-farming/starting-first-person-farming.json b/examples/starting-first-person-farming/starting-first-person-farming.json index 17fa1fe03..ecdf84180 100644 --- a/examples/starting-first-person-farming/starting-first-person-farming.json +++ b/examples/starting-first-person-farming/starting-first-person-farming.json @@ -158,14 +158,6 @@ "name": "assets\\NotoSansArabicUI-Black.ttf", "userAdded": false }, - { - "file": "assets/crosshair037.png", - "kind": "image", - "metadata": "", - "name": "assets\\crosshair037.png", - "smoothed": false, - "userAdded": false - }, { "file": "assets/StartingInventorySlot.png", "kind": "image", @@ -353,6 +345,22 @@ "name": "assets/StartingGround.png", "smoothed": true, "userAdded": false + }, + { + "file": "assets/Dot Crosshair Center.png", + "kind": "image", + "name": "Dot Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Dot Crosshair Hit Marker.png", + "kind": "image", + "name": "Dot Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -2100,65 +2108,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "persistentUuid": "ec6994ff-090b-47db-92e5-2a56e358b21d", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Dot Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\crosshair037.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 32, - "y": 32 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 20, - "y": 20 - }, - { - "x": 44, - "y": 20 - }, - { - "x": 44, - "y": 44 - }, - { - "x": 20, - "y": 44 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "80;255;140", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 0, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "ec6994ff-090b-47db-92e5-2a56e358b21d" }, { "assetStoreId": "", @@ -6182,7 +6148,7 @@ "elevation": 45, "frustumSize": 4000, "intensity": 0.75, - "minimumShadowBias": 0.00001, + "minimumShadowBias": 1e-05, "rotation": 30, "shadowDistance": 2000, "shadowNormalBias": 1 @@ -56884,7 +56850,1579 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 16.0, + "areaMaxY": 16.0, + "areaMaxZ": 64, + "areaMinX": -16.0, + "areaMinY": -16.0, + "areaMinZ": 0, + "name": "Dot Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 6.5, + "y": 6.5 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 6.5, + "y": 6.5 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "cda8374c-c49c-42fc-915d-f7e2551fa9cb", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "3f624e16-fa34-4faf-b2c1-bb519680c59e", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Arm.png b/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Arm.png new file mode 100644 index 000000000..2be27b1f9 Binary files /dev/null and b/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Arm.png differ diff --git a/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Center.png b/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Center.png new file mode 100644 index 000000000..21d8a0de3 Binary files /dev/null and b/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Center.png differ diff --git a/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Hit Marker.png b/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-first-person-shooter-enemies/assets/Classic Crosshair Hit Marker.png differ diff --git a/examples/starting-first-person-shooter-enemies/assets/Crosshair.png b/examples/starting-first-person-shooter-enemies/assets/Crosshair.png deleted file mode 100644 index 7bdc27d3b..000000000 Binary files a/examples/starting-first-person-shooter-enemies/assets/Crosshair.png and /dev/null differ diff --git a/examples/starting-first-person-shooter-enemies/starting-first-person-shooter-enemies.json b/examples/starting-first-person-shooter-enemies/starting-first-person-shooter-enemies.json index f16c95c84..a53491c3d 100644 --- a/examples/starting-first-person-shooter-enemies/starting-first-person-shooter-enemies.json +++ b/examples/starting-first-person-shooter-enemies/starting-first-person-shooter-enemies.json @@ -167,14 +167,6 @@ "smoothed": true, "userAdded": false }, - { - "file": "assets/Crosshair.png", - "kind": "image", - "metadata": "", - "name": "assets\\Crosshair.png", - "smoothed": true, - "userAdded": false - }, { "file": "assets/Gunshot.mp3", "kind": "audio", @@ -270,6 +262,30 @@ "name": "assets/StartingGround.png", "smoothed": true, "userAdded": false + }, + { + "file": "assets/Classic Crosshair Center.png", + "kind": "image", + "name": "Classic Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Arm.png", + "kind": "image", + "name": "Classic Crosshair Arm.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Hit Marker.png", + "kind": "image", + "name": "Classic Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -1594,65 +1610,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "persistentUuid": "11ae5291-e969-4aed-8852-989f275b4b5a", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Classic Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\Crosshair.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 64, - "y": 64 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 12, - "y": 12 - }, - { - "x": 116, - "y": 12 - }, - { - "x": 116, - "y": 116 - }, - { - "x": 12, - "y": 116 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "255;255;255", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 20, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "11ae5291-e969-4aed-8852-989f275b4b5a" }, { "adaptCollisionMaskAutomatically": true, @@ -49780,7 +49754,1669 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "name": "Classic Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Arm.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 4.5, + "y": 9.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 4.5, + "y": 9.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 5.0, + "y": 5.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 5.0, + "y": 5.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "1da1d2e9-d37e-486a-a1e4-4295d202522b", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "8399244e-1fdf-4c11-bc8a-c887daf11013", + "width": 0, + "x": 0, + "y": -13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 90, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "6743462d-3bbe-4fc7-b24b-dd38cfa04ddf", + "width": 0, + "x": 13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 180, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "e75b8da6-19d7-4687-bfed-c35be7703e2f", + "width": 0, + "x": 0, + "y": 13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 270, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "0a09c66e-4bc4-46be-ae3e-1ae6a5a4d74e", + "width": 0, + "x": -13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "34c3eab4-7258-480f-82f9-2e09fcc39996", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-first-person-shooter-horror/assets/Crosshair.png b/examples/starting-first-person-shooter-horror/assets/Crosshair.png deleted file mode 100644 index 7bdc27d3b..000000000 Binary files a/examples/starting-first-person-shooter-horror/assets/Crosshair.png and /dev/null differ diff --git a/examples/starting-first-person-shooter-horror/assets/Dot Crosshair Center.png b/examples/starting-first-person-shooter-horror/assets/Dot Crosshair Center.png new file mode 100644 index 000000000..36da75f78 Binary files /dev/null and b/examples/starting-first-person-shooter-horror/assets/Dot Crosshair Center.png differ diff --git a/examples/starting-first-person-shooter-horror/assets/Dot Crosshair Hit Marker.png b/examples/starting-first-person-shooter-horror/assets/Dot Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-first-person-shooter-horror/assets/Dot Crosshair Hit Marker.png differ diff --git a/examples/starting-first-person-shooter-horror/starting-first-person-shooter-horror.json b/examples/starting-first-person-shooter-horror/starting-first-person-shooter-horror.json index 095d588f7..c7cc5ef4a 100644 --- a/examples/starting-first-person-shooter-horror/starting-first-person-shooter-horror.json +++ b/examples/starting-first-person-shooter-horror/starting-first-person-shooter-horror.json @@ -175,14 +175,6 @@ "smoothed": true, "userAdded": false }, - { - "file": "assets/Crosshair.png", - "kind": "image", - "metadata": "", - "name": "assets\\Crosshair.png", - "smoothed": true, - "userAdded": false - }, { "file": "assets/Gunshot.mp3", "kind": "audio", @@ -278,6 +270,22 @@ "name": "assets/StartingGround.png", "smoothed": true, "userAdded": false + }, + { + "file": "assets/Dot Crosshair Center.png", + "kind": "image", + "name": "Dot Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Dot Crosshair Hit Marker.png", + "kind": "image", + "name": "Dot Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -1649,65 +1657,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "persistentUuid": "4042c849-efac-4735-b45f-c167048b1562", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Dot Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\Crosshair.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 64, - "y": 64 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 12, - "y": 12 - }, - { - "x": 116, - "y": 12 - }, - { - "x": 116, - "y": 116 - }, - { - "x": 12, - "y": 116 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "255;255;255", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 0, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "4042c849-efac-4735-b45f-c167048b1562" }, { "adaptCollisionMaskAutomatically": true, @@ -54833,7 +54799,1579 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 16.0, + "areaMaxY": 16.0, + "areaMaxZ": 64, + "areaMinX": -16.0, + "areaMinY": -16.0, + "areaMinZ": 0, + "name": "Dot Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 6.5, + "y": 6.5 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 6.5, + "y": 6.5 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Dot Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "cda8374c-c49c-42fc-915d-f7e2551fa9cb", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "3f624e16-fa34-4faf-b2c1-bb519680c59e", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-first-person-shooter/assets/Classic Crosshair Arm.png b/examples/starting-first-person-shooter/assets/Classic Crosshair Arm.png new file mode 100644 index 000000000..2be27b1f9 Binary files /dev/null and b/examples/starting-first-person-shooter/assets/Classic Crosshair Arm.png differ diff --git a/examples/starting-first-person-shooter/assets/Classic Crosshair Center.png b/examples/starting-first-person-shooter/assets/Classic Crosshair Center.png new file mode 100644 index 000000000..21d8a0de3 Binary files /dev/null and b/examples/starting-first-person-shooter/assets/Classic Crosshair Center.png differ diff --git a/examples/starting-first-person-shooter/assets/Classic Crosshair Hit Marker.png b/examples/starting-first-person-shooter/assets/Classic Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-first-person-shooter/assets/Classic Crosshair Hit Marker.png differ diff --git a/examples/starting-first-person-shooter/assets/Crosshair.png b/examples/starting-first-person-shooter/assets/Crosshair.png deleted file mode 100644 index 7bdc27d3b..000000000 Binary files a/examples/starting-first-person-shooter/assets/Crosshair.png and /dev/null differ diff --git a/examples/starting-first-person-shooter/starting-first-person-shooter.json b/examples/starting-first-person-shooter/starting-first-person-shooter.json index d165b16df..98f580ace 100644 --- a/examples/starting-first-person-shooter/starting-first-person-shooter.json +++ b/examples/starting-first-person-shooter/starting-first-person-shooter.json @@ -167,14 +167,6 @@ "smoothed": true, "userAdded": false }, - { - "file": "assets/Crosshair.png", - "kind": "image", - "metadata": "", - "name": "assets\\Crosshair.png", - "smoothed": true, - "userAdded": false - }, { "file": "assets/StartingGun_orange.glb", "kind": "model3D", @@ -274,6 +266,30 @@ "name": "assets/StartingGround.png", "smoothed": true, "userAdded": false + }, + { + "file": "assets/Classic Crosshair Center.png", + "kind": "image", + "name": "Classic Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Arm.png", + "kind": "image", + "name": "Classic Crosshair Arm.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Hit Marker.png", + "kind": "image", + "name": "Classic Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -1292,65 +1308,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "persistentUuid": "c7b55774-1557-4b79-9545-4e6c8c63d8b0", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Classic Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\Crosshair.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 64, - "y": 64 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 12, - "y": 12 - }, - { - "x": 116, - "y": 12 - }, - { - "x": 116, - "y": 116 - }, - { - "x": 12, - "y": 116 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "255;255;255", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 20, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "c7b55774-1557-4b79-9545-4e6c8c63d8b0" }, { "assetStoreId": "", @@ -48566,7 +48540,1669 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "name": "Classic Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Arm.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 4.5, + "y": 9.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 4.5, + "y": 9.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 5.0, + "y": 5.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 5.0, + "y": 5.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "1da1d2e9-d37e-486a-a1e4-4295d202522b", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "8399244e-1fdf-4c11-bc8a-c887daf11013", + "width": 0, + "x": 0, + "y": -13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 90, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "6743462d-3bbe-4fc7-b24b-dd38cfa04ddf", + "width": 0, + "x": 13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 180, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "e75b8da6-19d7-4687-bfed-c35be7703e2f", + "width": 0, + "x": 0, + "y": 13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 270, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "0a09c66e-4bc4-46be-ae3e-1ae6a5a4d74e", + "width": 0, + "x": -13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "34c3eab4-7258-480f-82f9-2e09fcc39996", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file diff --git a/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Arm.png b/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Arm.png new file mode 100644 index 000000000..2be27b1f9 Binary files /dev/null and b/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Arm.png differ diff --git a/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Center.png b/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Center.png new file mode 100644 index 000000000..21d8a0de3 Binary files /dev/null and b/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Center.png differ diff --git a/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Hit Marker.png b/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Hit Marker.png new file mode 100644 index 000000000..d193dc38e Binary files /dev/null and b/examples/starting-first-person-survival-crafting/assets/Classic Crosshair Hit Marker.png differ diff --git a/examples/starting-first-person-survival-crafting/assets/crosshair037.png b/examples/starting-first-person-survival-crafting/assets/crosshair037.png deleted file mode 100644 index 73c9f032d..000000000 Binary files a/examples/starting-first-person-survival-crafting/assets/crosshair037.png and /dev/null differ diff --git a/examples/starting-first-person-survival-crafting/starting-first-person-survival-crafting.json b/examples/starting-first-person-survival-crafting/starting-first-person-survival-crafting.json index 5bb029768..82d1ea56d 100644 --- a/examples/starting-first-person-survival-crafting/starting-first-person-survival-crafting.json +++ b/examples/starting-first-person-survival-crafting/starting-first-person-survival-crafting.json @@ -166,14 +166,6 @@ "name": "assets\\NotoSansArabicUI-Black.ttf", "userAdded": false }, - { - "file": "assets/crosshair037.png", - "kind": "image", - "metadata": "", - "name": "assets\\crosshair037.png", - "smoothed": false, - "userAdded": false - }, { "file": "assets/StartingInventorySlot.png", "kind": "image", @@ -307,6 +299,30 @@ "name": "assets/StartingGround.png", "smoothed": true, "userAdded": false + }, + { + "file": "assets/Classic Crosshair Center.png", + "kind": "image", + "name": "Classic Crosshair Center.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Arm.png", + "kind": "image", + "name": "Classic Crosshair Arm.png", + "userAdded": false, + "smoothed": true, + "metadata": "" + }, + { + "file": "assets/Classic Crosshair Hit Marker.png", + "kind": "image", + "name": "Classic Crosshair Hit Marker.png", + "userAdded": false, + "smoothed": true, + "metadata": "" } ] }, @@ -1418,64 +1434,23 @@ } }, { - "adaptCollisionMaskAutomatically": true, "assetStoreId": "", "name": "Crosshair", - "type": "Sprite", - "updateIfNotVisible": false, + "type": "Crosshair::Crosshair", + "variant": "Classic Crosshair", "variables": [], "effects": [], "behaviors": [], - "animations": [ - { - "name": "", - "useMultipleDirections": false, - "directions": [ - { - "looping": false, - "timeBetweenFrames": 0.08, - "sprites": [ - { - "hasCustomCollisionMask": true, - "image": "assets\\crosshair037.png", - "points": [], - "originPoint": { - "name": "origine", - "x": 32, - "y": 32 - }, - "centerPoint": { - "automatic": true, - "name": "centre", - "x": 0, - "y": 0 - }, - "customCollisionMask": [ - [ - { - "x": 20, - "y": 20 - }, - { - "x": 44, - "y": 20 - }, - { - "x": 44, - "y": 44 - }, - { - "x": 20, - "y": 44 - } - ] - ] - } - ] - } - ] - } - ] + "content": { + "Color": "255;255;255", + "TargetColor": "255;64;64", + "FollowCursor": false, + "ShouldHideCursor": false, + "MaxSpread": 20, + "SpreadRecovery": 60, + "HitMarkerDuration": 0.25 + }, + "persistentUuid": "" }, { "assetStoreId": "", @@ -44086,7 +44061,1669 @@ "variants": [] } ] + }, + { + "author": "", + "category": "User interface", + "extensionNamespace": "", + "fullName": "Crosshair", + "gdevelopVersion": ">=5.5.230", + "helpPath": "", + "iconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "name": "Crosshair", + "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/UI Essentials/UI Essentials_dart_mission_goal_success.svg", + "shortDescription": "A crosshair following the mouse or touch, with spread when shooting, a hit marker and a color on targets.", + "version": "1.0.0", + "description": [ + "A crosshair (or a reticle) for shooters. Its position is its center: put it at the cursor, the center of the screen or anywhere without any offset.", + "", + "By default it follows the mouse cursor (or the touch) and hides the mouse cursor. Then, optionally:", + "- **Add spread** when shooting: its arms move apart and come back by themselves (the \"Spread\" expression can make shots less precise),", + "- **Show the hit marker** when a shot hits,", + "- **On a target**: it takes another color while aiming at an enemy.", + "", + "Ready-to-use crosshairs are in the asset store [crosshairs pack](https://editor.gdevelop.io/?initial-dialog=asset-store&asset-pack=crosshairs-crosshairs)." + ], + "origin": { + "identifier": "Crosshair", + "name": "gdevelop-extension-store" + }, + "tags": [ + "crosshair", + "reticle", + "aim", + "shooter", + "fps", + "cursor", + "hit marker", + "ui" + ], + "authorIds": [ + "R0F5QGNCzgOY5w2cxGeKJOq2UaD2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [], + "eventsFunctions": [], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "assetStoreTag": "crosshairs", + "defaultName": "Crosshair", + "description": "A crosshair centered on its position, following the mouse or touch. Its arms move apart when shooting, it flashes a hit marker and changes color on a target.", + "fullName": "Crosshair", + "isInnerAreaFollowingParentSize": false, + "isUsingLegacyInstancesRenderer": false, + "name": "Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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, + "height": 14, + "layer": "", + "name": "Arm", + "persistentUuid": "c2dfb1af-d57c-4d1a-833d-fcf81f667f2a", + "width": 6, + "x": -3, + "y": -26, + "zOrder": 1, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": true, + "height": 6, + "layer": "", + "name": "Center", + "persistentUuid": "767067a4-c57e-4c1b-b201-c8991a357c7d", + "width": 6, + "x": -3, + "y": -3, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ], + "propertyDescriptors": [ + { + "value": "255;255;255", + "type": "Color", + "label": "Color", + "name": "Color", + "description": "The tint of the crosshair (its images are white)." + }, + { + "value": "255;64;64", + "type": "Color", + "label": "Color on a target", + "name": "TargetColor", + "description": "The tint of the crosshair when it is on a target (see the action \"On a target\")." + }, + { + "value": "true", + "type": "Boolean", + "label": "Follow the mouse or touch", + "name": "FollowCursor", + "description": "Move the crosshair to the mouse cursor (or the touch) every frame, on its layer." + }, + { + "value": "true", + "type": "Boolean", + "label": "Hide the mouse cursor", + "name": "ShouldHideCursor", + "description": "Hide the mouse cursor while the crosshair exists." + }, + { + "value": "24", + "type": "Number", + "label": "Maximum spread", + "name": "MaxSpread", + "description": "How far the arms can move apart when shooting (in pixels).", + "group": "Spread", + "unit": "Pixel" + }, + { + "value": "60", + "type": "Number", + "label": "Spread recovery speed", + "name": "SpreadRecovery", + "description": "How fast the arms come back after shooting (in pixels per second).", + "group": "Spread", + "unit": "PixelSpeed" + }, + { + "value": "0.25", + "type": "Number", + "label": "Hit marker duration", + "name": "HitMarkerDuration", + "group": "Hit marker", + "unit": "Second" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "Spread", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsOnTarget", + "hidden": true + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "HitMarkerTime", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseWidth", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "0", + "type": "Number", + "label": "", + "name": "RingBaseHeight", + "hidden": true, + "unit": "Dimensionless" + }, + { + "value": "", + "type": "String", + "label": "", + "name": "AppliedColor", + "hidden": true + }, + { + "value": "", + "type": "String", + "label": "", + "name": "WantedColor", + "hidden": true + }, + { + "value": "", + "type": "Boolean", + "label": "", + "name": "IsCursorHidden", + "hidden": true + } + ], + "eventsFunctions": [ + { + "fullName": "", + "functionType": "Action", + "name": "onCreated", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The arms move apart from the center when the crosshair spreads: each one along the line from the center (the origin of the crosshair) to its own center." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseX", + "=", + "Arm.X()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "BaseY", + "=", + "Arm.Y()" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionX", + "=", + "Arm.CenterX() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "SetNumberObjectVariable" + }, + "parameters": [ + "Arm", + "DirectionY", + "=", + "Arm.CenterY() / max(0.0001, sqrt(pow(Arm.CenterX(), 2) + pow(Arm.CenterY(), 2)))" + ] + }, + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneInstancesCount" + }, + "parameters": [ + "", + "Ring", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseWidth", + "=", + "Ring.Width()" + ] + }, + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "RingBaseHeight", + "=", + "Ring.Height()" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "ShouldHideCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "HideCursor" + }, + "parameters": [ + "" + ] + }, + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + }, + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "onDestroy", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsCursorHidden", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ShowCursor" + }, + "parameters": [ + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPreEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The crosshair follows the cursor before the events of the scene, so that they use its position of this frame." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::FollowCursorPosition" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "", + "functionType": "Action", + "name": "doStepPostEvents", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "Crosshair::Crosshair::Update" + }, + "parameters": [ + "Object", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [] + }, + { + "fullName": "Follow the cursor", + "functionType": "Action", + "name": "FollowCursorPosition", + "sentence": "Move _PARAM0_ to the cursor", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "In the events of the crosshair, the cursor position is relative to the crosshair (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Object", + "=", + "Object.X() + CursorX(\"\", 0) * Object.Scale::X()", + "=", + "Object.Y() + CursorY(\"\", 0) * Object.Scale::Y()" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the crosshair to the cursor.", + "private": true + }, + { + "fullName": "Update", + "functionType": "Action", + "name": "Update", + "sentence": "Update _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "max(0, Spread - SpreadRecovery * TimeDelta())" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "MettreXY" + }, + "parameters": [ + "Arm", + "=", + "Arm.Variable(BaseX) + Arm.Variable(DirectionX) * Spread", + "=", + "Arm.Variable(BaseY) + Arm.Variable(DirectionY) * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The ring grows with the spread (its origin is its center)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "RingBaseWidth", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResizableCapability::ResizableBehavior::SetSize" + }, + "parameters": [ + "Ring", + "Resizable", + "RingBaseWidth + 2 * Spread", + "RingBaseHeight + 2 * Spread" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The hit marker fades out." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + ">", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "-", + "TimeDelta()" + ] + }, + { + "type": { + "value": "Show" + }, + "parameters": [ + "HitMarker" + ] + }, + { + "type": { + "value": "Opacity" + }, + "parameters": [ + "HitMarker", + "=", + "clamp(255 * HitMarkerTime / max(0.0001, HitMarkerDuration), 0, 255)" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "NumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "<=", + "0" + ] + } + ], + "actions": [ + { + "type": { + "value": "Hide" + }, + "parameters": [ + "HitMarker" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "The images are white: they are tinted with the color (or the color on a target)." + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "Color" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "WantedColor", + "=", + "TargetColor" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "StringVariable" + }, + "parameters": [ + "AppliedColor", + "!=", + "WantedColor" + ] + } + ], + "actions": [ + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Center", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Arm", + "WantedColor" + ] + }, + { + "type": { + "value": "ChangeColor" + }, + "parameters": [ + "Ring", + "WantedColor" + ] + }, + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "AppliedColor", + "=", + "WantedColor" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Move the arms, fade the hit marker and tint the crosshair.", + "private": true + }, + { + "fullName": "Add spread", + "functionType": "Action", + "name": "AddSpread", + "sentence": "Add _PARAM1_ px of spread to _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Spread + Amount, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Spread to add (in pixels)", + "name": "Amount", + "type": "expression" + } + ], + "objectGroups": [], + "description": "Move the arms of the crosshair apart (for example when shooting). They come back by themselves.", + "group": "Spread" + }, + { + "fullName": "Spread", + "functionType": "ExpressionAndCondition", + "name": "Spread", + "sentence": "the spread", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "Spread" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "the spread of the crosshair (how far its arms moved apart, in pixels). It can be used to make shots less precise.", + "group": "Spread", + "expressionType": { + "type": "number" + } + }, + { + "fullName": "", + "functionType": "ActionWithOperator", + "name": "SetSpread", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "Spread", + "=", + "clamp(Value, 0, MaxSpread)" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "group": "Spread", + "getterName": "Spread" + }, + { + "fullName": "Show the hit marker", + "functionType": "Action", + "name": "ShowHitMarker", + "sentence": "Show the hit marker on _PARAM0_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetNumberVariable" + }, + "parameters": [ + "HitMarkerTime", + "=", + "HitMarkerDuration" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Flash a hit marker on the crosshair (for example when a shot hits an enemy).", + "group": "Hit marker" + }, + { + "fullName": "On a target", + "functionType": "Action", + "name": "SetOnTarget", + "sentence": "_PARAM0_ is on a target: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"OnTarget\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "On a target?", + "name": "OnTarget", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Show that the crosshair is on a target (or not): it takes its color on a target.", + "group": "Target" + }, + { + "fullName": "Is on a target", + "functionType": "Condition", + "name": "IsOnTarget", + "sentence": "_PARAM0_ is on a target", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "BooleanVariable" + }, + "parameters": [ + "IsOnTarget", + "True", + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + } + ], + "objectGroups": [], + "description": "Check if the crosshair is on a target.", + "group": "Target" + }, + { + "fullName": "Color", + "functionType": "Action", + "name": "SetColor", + "sentence": "Change the color of _PARAM0_ to _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetStringVariable" + }, + "parameters": [ + "Color", + "=", + "Color" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Color", + "name": "Color", + "type": "color" + } + ], + "objectGroups": [], + "description": "Change the color of the crosshair.", + "group": "Appearance" + }, + { + "fullName": "Follow the mouse or touch", + "functionType": "Action", + "name": "SetFollowCursor", + "sentence": "_PARAM0_ follows the cursor: _PARAM1_", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "True", + "" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "inverted": true, + "value": "GetArgumentAsBoolean" + }, + "parameters": [ + "\"ShouldFollow\"" + ] + } + ], + "actions": [ + { + "type": { + "value": "SetBooleanVariable" + }, + "parameters": [ + "FollowCursor", + "False", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Object", + "name": "Object", + "supplementaryInformation": "Crosshair::Crosshair", + "type": "object" + }, + { + "description": "Follow the cursor?", + "name": "ShouldFollow", + "type": "yesorno" + } + ], + "objectGroups": [], + "description": "Make the crosshair follow the mouse cursor (or the touch), or not (to move it with events, for example to the center of the screen or with a gamepad)." + } + ], + "variants": [ + { + "areaMaxX": 32.0, + "areaMaxY": 32.0, + "areaMaxZ": 64, + "areaMinX": -32.0, + "areaMinY": -32.0, + "areaMinZ": 0, + "name": "Classic Crosshair", + "objects": [ + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Ring", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Arm", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [ + { + "name": "BaseX", + "type": "number", + "value": 0 + }, + { + "name": "BaseY", + "type": "number", + "value": 0 + }, + { + "name": "DirectionX", + "type": "number", + "value": 0 + }, + { + "name": "DirectionY", + "type": "number", + "value": 0 + } + ], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Arm.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 4.5, + "y": 9.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 4.5, + "y": 9.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "Center", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Center.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 5.0, + "y": 5.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 5.0, + "y": 5.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + }, + { + "adaptCollisionMaskAutomatically": true, + "assetStoreId": "", + "name": "HitMarker", + "type": "Sprite", + "updateIfNotVisible": false, + "variables": [], + "effects": [], + "behaviors": [], + "animations": [ + { + "name": "Idle", + "useMultipleDirections": false, + "directions": [ + { + "looping": false, + "timeBetweenFrames": 0.08, + "sprites": [ + { + "hasCustomCollisionMask": false, + "image": "Classic Crosshair Hit Marker.png", + "points": [], + "originPoint": { + "name": "origine", + "x": 15.0, + "y": 15.0 + }, + "centerPoint": { + "automatic": false, + "name": "centre", + "x": 15.0, + "y": 15.0 + }, + "customCollisionMask": [] + } + ] + } + ] + } + ] + } + ], + "objectsFolderStructure": { + "folderName": "__ROOT", + "children": [ + { + "objectName": "Ring" + }, + { + "objectName": "Arm" + }, + { + "objectName": "Center" + }, + { + "objectName": "HitMarker" + } + ] + }, + "objectsGroups": [], + "layers": [ + { + "ambientLightColorB": 200, + "ambientLightColorG": 200, + "ambientLightColorR": 200, + "camera2DPlaneMaxDrawingDistance": 5000, + "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": false, + "height": 0, + "layer": "", + "name": "Center", + "persistentUuid": "1da1d2e9-d37e-486a-a1e4-4295d202522b", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 3, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "8399244e-1fdf-4c11-bc8a-c887daf11013", + "width": 0, + "x": 0, + "y": -13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 90, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "6743462d-3bbe-4fc7-b24b-dd38cfa04ddf", + "width": 0, + "x": 13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 180, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "e75b8da6-19d7-4687-bfed-c35be7703e2f", + "width": 0, + "x": 0, + "y": 13, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 270, + "customSize": false, + "height": 0, + "layer": "", + "name": "Arm", + "persistentUuid": "0a09c66e-4bc4-46be-ae3e-1ae6a5a4d74e", + "width": 0, + "x": -13, + "y": 0, + "zOrder": 2, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + }, + { + "angle": 0, + "customSize": false, + "height": 0, + "layer": "", + "name": "HitMarker", + "persistentUuid": "34c3eab4-7258-480f-82f9-2e09fcc39996", + "width": 0, + "x": 0, + "y": 0, + "zOrder": 4, + "numberProperties": [], + "stringProperties": [], + "initialVariables": [] + } + ] + } + ] + } + ] } ], "externalLayouts": [] -} +} \ No newline at end of file