|
8 | 8 | "name": "Sticker", |
9 | 9 | "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/sticker-outline.svg", |
10 | 10 | "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", |
12 | 12 | "description": [ |
13 | 13 | "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", |
16 | 17 | "", |
17 | 18 | "An example allows to check it out ([open the project online](https://editor.gdevelop.io/?project=example://stick-objects))." |
18 | 19 | ], |
|
114 | 115 | "const behavior = object.getBehavior(behaviorName);", |
115 | 116 | "", |
116 | 117 | "// 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();", |
119 | 119 | "", |
120 | 120 | "// Set up the behavior extra methods - if not done already.", |
121 | 121 | "const prototype = Object.getPrototypeOf(behavior);", |
122 | 122 | "if (!prototype.updateRelativeCoordinates) {", |
123 | 123 | " // Unstick from deleted objects.", |
124 | 124 | " gdjs.registerObjectDeletedFromSceneCallback(function (runtimeScene, deletedObject) {", |
125 | | - " if (!runtimeScene.__allStickers) return;", |
| 125 | + " const allStickers = runtimeScene.__allStickers;", |
| 126 | + " if (!allStickers) return;", |
126 | 127 | "", |
127 | | - " for (const sticker of runtimeScene.__allStickers) {", |
| 128 | + " for (const sticker of allStickers) {", |
128 | 129 | " if (sticker.basisObject === deletedObject) {", |
| 130 | + " if (sticker._getIsDestroyedWithParent()) {", |
| 131 | + " sticker.owner.deleteFromScene(runtimeScene);", |
| 132 | + " }", |
129 | 133 | " sticker.basisObject = null;", |
130 | 134 | " }", |
131 | 135 | " }", |
|
503 | 507 | "extraInformation": [], |
504 | 508 | "hidden": false, |
505 | 509 | "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" |
506 | 520 | } |
507 | 521 | ], |
508 | 522 | "sharedPropertyDescriptors": [] |
|
0 commit comments