Skip to content

Commit f3ce457

Browse files
committed
Automated Extension submission for issue #1629
1 parent ff60615 commit f3ce457

File tree

1 file changed

+369
-0
lines changed

1 file changed

+369
-0
lines changed

extensions/community/Coin.json

+369
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,369 @@
1+
{
2+
"author": "",
3+
"category": "Game mechanic",
4+
"extensionNamespace": "",
5+
"fullName": "Coin Destroy with Tween Fade and Sound",
6+
"gdevelopVersion": "",
7+
"helpPath": "",
8+
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWN1cnJlbmN5LXVzZC1jaXJjbGUtb3V0bGluZSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0xMiwyQTEwLDEwIDAgMCwxIDIyLDEyQTEwLDEwIDAgMCwxIDEyLDIyQTEwLDEwIDAgMCwxIDIsMTJBMTAsMTAgMCAwLDEgMTIsMk0xMiw0QTgsOCAwIDAsMCA0LDEyQTgsOCAwIDAsMCAxMiwyMEE4LDggMCAwLDAgMjAsMTJBOCw4IDAgMCwwIDEyLDRNMTEsMTdWMTZIOVYxNEgxM1YxM0gxMEExLDEgMCAwLDEgOSwxMlY5QTEsMSAwIDAsMSAxMCw4SDExVjdIMTNWOEgxNVYxMEgxMVYxMUgxNEExLDEgMCAwLDEgMTUsMTJWMTVBMSwxIDAgMCwxIDE0LDE2SDEzVjE3SDExWiIgLz48L3N2Zz4=",
9+
"name": "Coin",
10+
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/af9b1fb88a22a37beb06970c360a7ce2860facf6eb5b5d0105181a1ffaeabb29_currency-usd-circle-outline.svg",
11+
"shortDescription": "Coin Destroy with Tween Fade and Sound.",
12+
"version": "1.0.0",
13+
"description": [
14+
"Nice Destruction of Coin ( or any other object ) with Tween movement, fade and sound with dynamic pitch change between each deletion.",
15+
"",
16+
"Add this behavior to an Object, and activate it in the event sheet as an action when you want to delete the coin (Object or Group).",
17+
"Use Delete Coin action - (e.g. Player collides with a coin).",
18+
""
19+
],
20+
"tags": [
21+
"Coin",
22+
"Fade",
23+
"Sound",
24+
"Delete"
25+
],
26+
"authorIds": [
27+
"1uZgGgHkqobtw1Iueyo7bkqahy92"
28+
],
29+
"dependencies": [],
30+
"globalVariables": [],
31+
"sceneVariables": [],
32+
"eventsFunctions": [],
33+
"eventsBasedBehaviors": [
34+
{
35+
"description": "Add action to delete objects with tween, fade and sound.",
36+
"fullName": "Coin",
37+
"name": "Coin",
38+
"objectType": "",
39+
"eventsFunctions": [
40+
{
41+
"description": "Delete with tween fade and sound.",
42+
"fullName": "Delete Coin",
43+
"functionType": "Action",
44+
"name": "DeleteCoin",
45+
"sentence": "_PARAM0_ Deleted with tween fade and sound",
46+
"events": [
47+
{
48+
"type": "BuiltinCommonInstructions::Comment",
49+
"color": {
50+
"b": 109,
51+
"g": 230,
52+
"r": 255,
53+
"textB": 0,
54+
"textG": 0,
55+
"textR": 0
56+
},
57+
"comment": "Tween , Fade and play sound"
58+
},
59+
{
60+
"type": "BuiltinCommonInstructions::JsCode",
61+
"inlineCode": [
62+
"if (!objects.length)",
63+
" return;",
64+
"",
65+
"const obj = objects[0];",
66+
"//almost dead , no need to active nothing twice",
67+
"if (obj.markAsDead)",
68+
" return;",
69+
"obj.markAsDead = true;",
70+
"",
71+
"//get data from behavior",
72+
"const behavior = obj.getBehavior(\"Coin\");",
73+
"const soundName = behavior._getSound();",
74+
"const volume = behavior._getVolume();",
75+
"const time = Math.min(behavior._getTime() * 1000, 1000); //animation up to 1 second",
76+
"const deltaY = behavior._getDeltaY();",
77+
"const deltaX = behavior._getDeltaX();",
78+
"const deltaPitch = behavior._getDeltaPitch();",
79+
"const pitchResetTime = behavior._getPitchRestTime() * 1000;",
80+
"",
81+
"//check for time is greater then pitchResetTime",
82+
"//if so , reset pitch factor to 1.0",
83+
"const ctx = gdjs._coinExtension;",
84+
"const now = Date.now();",
85+
"if (now - ctx.lastTime > pitchResetTime)",
86+
" ctx.coinPitchFactor = 1.0;",
87+
"ctx.lastTime = now;",
88+
"",
89+
"//play sound with the right pitch",
90+
"if (soundName.length) {",
91+
" gdjs.evtTools.sound.playSound(runtimeScene, soundName, false, volume, ctx.coinPitchFactor);",
92+
" //increase pitch",
93+
" ctx.coinPitchFactor += deltaPitch;",
94+
"}",
95+
"",
96+
"//generate if needed coin tween animation for move and fade",
97+
"if (!obj.hasBehavior(\"CoinTween\")) {",
98+
" const tweenBehavior = new gdjs.TweenRuntimeBehavior(runtimeScene,",
99+
" { type: \"Tween::TweenBehavior\", name: \"CoinTween\" }",
100+
" );",
101+
" obj.addNewBehavior(tweenBehavior);",
102+
"}",
103+
"const tween = obj.getBehavior(\"CoinTween\");",
104+
"if (tween) {",
105+
" //position tween",
106+
" tween.addObjectPositionTween(\"MoveTween\",",
107+
" obj.x + deltaX, obj.y + deltaY, \"easeInOutQuad\", time, false);",
108+
" //fade",
109+
" tween.addObjectOpacityTween(\"Opacity\", 0, \"easeInOutQuad\", time, false);",
110+
"}",
111+
""
112+
],
113+
"parameterObjects": "Object",
114+
"useStrict": true,
115+
"eventsSheetExpanded": true
116+
},
117+
{
118+
"type": "BuiltinCommonInstructions::Comment",
119+
"color": {
120+
"b": 109,
121+
"g": 230,
122+
"r": 255,
123+
"textB": 0,
124+
"textG": 0,
125+
"textR": 0
126+
},
127+
"comment": "Delete the coin After 1 Second (Max animation time)"
128+
},
129+
{
130+
"type": "BuiltinCommonInstructions::Standard",
131+
"conditions": [],
132+
"actions": [
133+
{
134+
"type": {
135+
"value": "Wait"
136+
},
137+
"parameters": [
138+
"1"
139+
]
140+
},
141+
{
142+
"type": {
143+
"value": "Delete"
144+
},
145+
"parameters": [
146+
"Object",
147+
""
148+
]
149+
}
150+
]
151+
}
152+
],
153+
"parameters": [
154+
{
155+
"description": "Object",
156+
"name": "Object",
157+
"type": "object"
158+
},
159+
{
160+
"description": "Behavior",
161+
"name": "Behavior",
162+
"supplementaryInformation": "Coin::Coin",
163+
"type": "behavior"
164+
}
165+
],
166+
"objectGroups": []
167+
},
168+
{
169+
"fullName": "",
170+
"functionType": "Action",
171+
"name": "onCreated",
172+
"sentence": "",
173+
"events": [
174+
{
175+
"type": "BuiltinCommonInstructions::Standard",
176+
"conditions": [],
177+
"actions": []
178+
},
179+
{
180+
"type": "BuiltinCommonInstructions::JsCode",
181+
"inlineCode": [
182+
"if (gdjs._coinExtension)",
183+
" return;",
184+
"",
185+
"//init Extension global parameters ",
186+
"gdjs._coinExtension = ",
187+
"{",
188+
" coinPitchFactor: 1.0,",
189+
" lastTime: Date.now()",
190+
"}"
191+
],
192+
"parameterObjects": "",
193+
"useStrict": true,
194+
"eventsSheetExpanded": false
195+
}
196+
],
197+
"parameters": [
198+
{
199+
"description": "Object",
200+
"name": "Object",
201+
"type": "object"
202+
},
203+
{
204+
"description": "Behavior",
205+
"name": "Behavior",
206+
"supplementaryInformation": "Coin::Coin",
207+
"type": "behavior"
208+
}
209+
],
210+
"objectGroups": []
211+
}
212+
],
213+
"propertyDescriptors": [
214+
{
215+
"value": "",
216+
"type": "Resource",
217+
"label": "Sound",
218+
"description": "Sound that will be played once the coin is collected (Empty for no sound)",
219+
"group": "Sound",
220+
"extraInformation": [
221+
"audio"
222+
],
223+
"name": "Sound"
224+
},
225+
{
226+
"value": "0.5",
227+
"type": "Number",
228+
"unit": "Second",
229+
"label": "Time",
230+
"description": "Time in Seconds for the coin to be dissolved, use values between 0 - 1.0",
231+
"group": "",
232+
"extraInformation": [],
233+
"advanced": true,
234+
"name": "Time"
235+
},
236+
{
237+
"value": "0",
238+
"type": "Number",
239+
"unit": "Pixel",
240+
"label": "DeltaX",
241+
"description": "Movement offset in X ",
242+
"group": "",
243+
"extraInformation": [],
244+
"advanced": true,
245+
"name": "DeltaX"
246+
},
247+
{
248+
"value": "-20",
249+
"type": "Number",
250+
"unit": "Pixel",
251+
"label": "DeltaY",
252+
"description": "Movement offset in Y",
253+
"group": "",
254+
"extraInformation": [],
255+
"advanced": true,
256+
"name": "DeltaY"
257+
},
258+
{
259+
"value": "80",
260+
"type": "Number",
261+
"label": "Sound Volume",
262+
"description": "Set the volume of the attached sound",
263+
"group": "Sound",
264+
"extraInformation": [],
265+
"advanced": true,
266+
"name": "Volume"
267+
},
268+
{
269+
"value": "0.05",
270+
"type": "Number",
271+
"label": "Delta Pitch",
272+
"description": "Change in pitch every time an object is collected",
273+
"group": "Sound",
274+
"extraInformation": [],
275+
"advanced": true,
276+
"name": "DeltaPitch"
277+
},
278+
{
279+
"value": "0.3",
280+
"type": "Number",
281+
"unit": "Second",
282+
"label": "Pitch Reset Time",
283+
"description": "Time need to elapsed without picking an object ,to reset the Pitch back to default",
284+
"group": "Sound",
285+
"extraInformation": [],
286+
"advanced": true,
287+
"name": "PitchRestTime"
288+
}
289+
],
290+
"sharedPropertyDescriptors": []
291+
}
292+
],
293+
"eventsBasedObjects": [
294+
{
295+
"areaMaxX": 64,
296+
"areaMaxY": 64,
297+
"areaMaxZ": 64,
298+
"areaMinX": 0,
299+
"areaMinY": 0,
300+
"areaMinZ": 0,
301+
"defaultName": "",
302+
"description": "Dummy object to make sure Engine will keep the Tween Behavior.\nOtherwise, the javascript code cannot create a Tween object dynamically by code.",
303+
"fullName": "Coin Tween Dummy Object",
304+
"isUsingLegacyInstancesRenderer": false,
305+
"name": "CoinTweenDummy",
306+
"private": true,
307+
"eventsFunctions": [],
308+
"propertyDescriptors": [],
309+
"objects": [
310+
{
311+
"adaptCollisionMaskAutomatically": true,
312+
"assetStoreId": "",
313+
"name": "NewSprite",
314+
"type": "Sprite",
315+
"updateIfNotVisible": false,
316+
"variables": [],
317+
"effects": [],
318+
"behaviors": [
319+
{
320+
"name": "Tween",
321+
"type": "Tween::TweenBehavior"
322+
}
323+
],
324+
"animations": []
325+
}
326+
],
327+
"objectsFolderStructure": {
328+
"folderName": "__ROOT",
329+
"children": [
330+
{
331+
"objectName": "NewSprite"
332+
}
333+
]
334+
},
335+
"objectsGroups": [],
336+
"layers": [
337+
{
338+
"ambientLightColorB": 200,
339+
"ambientLightColorG": 200,
340+
"ambientLightColorR": 200,
341+
"camera3DFarPlaneDistance": 10000,
342+
"camera3DFieldOfView": 45,
343+
"camera3DNearPlaneDistance": 3,
344+
"cameraType": "",
345+
"followBaseLayerCamera": false,
346+
"isLightingLayer": false,
347+
"isLocked": false,
348+
"name": "",
349+
"renderingType": "",
350+
"visibility": true,
351+
"cameras": [
352+
{
353+
"defaultSize": true,
354+
"defaultViewport": true,
355+
"height": 0,
356+
"viewportBottom": 1,
357+
"viewportLeft": 0,
358+
"viewportRight": 1,
359+
"viewportTop": 0,
360+
"width": 0
361+
}
362+
],
363+
"effects": []
364+
}
365+
],
366+
"instances": []
367+
}
368+
]
369+
}

0 commit comments

Comments
 (0)