Skip to content

Commit dbf8753

Browse files
authored
[Reviewed] [Sticker] Allow to destroy stuck objects with their parent (#975)
1 parent fe7e073 commit dbf8753

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

extensions/reviewed/Sticker.json

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
"name": "Sticker",
99
"previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/sticker-outline.svg",
1010
"shortDescription": "Make objects follow the position and rotation of the object they are stuck to.",
11-
"version": "0.3.5",
11+
"version": "0.4.0",
1212
"description": [
1313
"This extension can be useful to:",
14-
"* Stick accessories to moving objects,",
15-
"* Animate a skeleton.",
14+
"* Stick accessories to moving objects",
15+
"* Animate a skeleton",
16+
"* Delete an object with another one",
1617
"",
1718
"An example allows to check it out ([open the project online](https://editor.gdevelop.io/?project=example://stick-objects))."
1819
],
@@ -114,18 +115,21 @@
114115
"const behavior = object.getBehavior(behaviorName);",
115116
"",
116117
"// Set up the scene sticker objects list - if not done already.",
117-
"if (!runtimeScene.__allStickers)",
118-
" runtimeScene.__allStickers = new Set();",
118+
"runtimeScene.__allStickers = runtimeScene.__allStickers || new Set();",
119119
"",
120120
"// Set up the behavior extra methods - if not done already.",
121121
"const prototype = Object.getPrototypeOf(behavior);",
122122
"if (!prototype.updateRelativeCoordinates) {",
123123
" // Unstick from deleted objects.",
124124
" gdjs.registerObjectDeletedFromSceneCallback(function (runtimeScene, deletedObject) {",
125-
" if (!runtimeScene.__allStickers) return;",
125+
" const allStickers = runtimeScene.__allStickers;",
126+
" if (!allStickers) return;",
126127
"",
127-
" for (const sticker of runtimeScene.__allStickers) {",
128+
" for (const sticker of allStickers) {",
128129
" if (sticker.basisObject === deletedObject) {",
130+
" if (sticker._getIsDestroyedWithParent()) {",
131+
" sticker.owner.deleteFromScene(runtimeScene);",
132+
" }",
129133
" sticker.basisObject = null;",
130134
" }",
131135
" }",
@@ -503,6 +507,16 @@
503507
"extraInformation": [],
504508
"hidden": false,
505509
"name": "OnlyFollowPosition"
510+
},
511+
{
512+
"value": "",
513+
"type": "Boolean",
514+
"label": "Destroy when the object it's stuck on is destroyed",
515+
"description": "",
516+
"group": "",
517+
"extraInformation": [],
518+
"hidden": false,
519+
"name": "IsDestroyedWithParent"
506520
}
507521
],
508522
"sharedPropertyDescriptors": []

0 commit comments

Comments
 (0)