Add Objects Timers example to GD5 and remove now deprecated example

This commit is contained in:
Florian Rival
2018-08-30 21:24:15 +01:00
parent 642e64d3ea
commit a1ea7ad0e3
12 changed files with 2084 additions and 867 deletions

View File

@@ -1 +0,0 @@
Learn how to have your objects on the scene have their own timers.

View File

@@ -1,415 +0,0 @@
{
"firstLayout": "",
"gdVersion": {
"build": 96,
"major": 4,
"minor": 0,
"revision": 0
},
"properties": {
"folderProject": false,
"linuxExecutableFilename": "",
"macExecutableFilename": "",
"orientation": "landscape",
"packageName": "com.example.gamename",
"projectFile": "C:\\Users\\szoszo\\Desktop\\Projects\\gametemplates\\gdevelop5\\instance-timer\\game.json",
"useExternalSourceFiles": false,
"winExecutableFilename": "",
"winExecutableIconFile": "",
"name": "Project",
"author": "",
"windowWidth": 800,
"windowHeight": 600,
"latestCompilationDirectory": "C:\\Users\\szoszo\\Desktop\\instance-timer",
"maxFPS": 60,
"minFPS": 10,
"verticalSync": false,
"platformSpecificAssets": {},
"extensions": [
{
"name": "BuiltinObject"
},
{
"name": "BuiltinAudio"
},
{
"name": "BuiltinVariables"
},
{
"name": "BuiltinTime"
},
{
"name": "BuiltinMouse"
},
{
"name": "BuiltinKeyboard"
},
{
"name": "BuiltinJoystick"
},
{
"name": "BuiltinCamera"
},
{
"name": "BuiltinWindow"
},
{
"name": "BuiltinFile"
},
{
"name": "BuiltinNetwork"
},
{
"name": "BuiltinScene"
},
{
"name": "BuiltinAdvanced"
},
{
"name": "Sprite"
},
{
"name": "BuiltinCommonInstructions"
},
{
"name": "BuiltinCommonConversions"
},
{
"name": "BuiltinStringInstructions"
},
{
"name": "BuiltinMathematicalTools"
},
{
"name": "BuiltinExternalLayouts"
}
],
"platforms": [
{
"name": "GDevelop JS platform"
}
],
"currentPlatform": "GDevelop JS platform"
},
"resources": {
"resources": [],
"resourceFolders": []
},
"objects": [],
"objectsGroups": [],
"variables": [],
"layouts": [
{
"b": 209,
"disableInputWhenNotFocused": true,
"mangledName": "NewScene",
"name": "NewScene",
"oglFOV": 90,
"oglZFar": 500,
"oglZNear": 1,
"r": 209,
"standardSortMethod": true,
"stopSoundsOnStartup": true,
"title": "",
"v": 209,
"uiSettings": {
"grid": false,
"gridB": 255,
"gridG": 180,
"gridHeight": 32,
"gridOffsetX": 0,
"gridOffsetY": 0,
"gridR": 158,
"gridWidth": 32,
"snap": true,
"windowMask": false,
"zoomFactor": 1
},
"objectsGroups": [],
"variables": [],
"instances": [
{
"angle": 0,
"customSize": false,
"height": 0,
"layer": "",
"locked": false,
"name": "message",
"width": 0,
"x": 158.204,
"y": 20.0816,
"zOrder": 1,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
}
],
"objects": [
{
"bold": false,
"italic": false,
"name": "time",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"behaviors": [],
"string": "0",
"font": "",
"characterSize": 20,
"color": {
"b": 0,
"g": 0,
"r": 0
}
},
{
"bold": false,
"italic": false,
"name": "message",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"behaviors": [],
"string": "Click/Touch to create a text object displaying a timer.\nClick/Touch a text object to reset the timer.",
"font": "",
"characterSize": 20,
"color": {
"b": 0,
"g": 0,
"r": 0
}
}
],
"events": [
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Comment",
"color": {
"b": 109,
"g": 230,
"r": 255,
"textB": 0,
"textG": 0,
"textR": 0
},
"comment": "when left mouse button is released and the mouse is not on a timer, create a new time object\nIn case the mouse is on a time object, reset the timer variable of the time object",
"comment2": ""
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "MouseButtonReleased"
},
"parameters": [
"",
"Left"
],
"subInstructions": []
}
],
"actions": [],
"events": [
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "BuiltinCommonInstructions::Not"
},
"parameters": [],
"subInstructions": [
{
"type": {
"inverted": false,
"value": "SourisSurObjet"
},
"parameters": [
"time",
"",
"",
""
],
"subInstructions": []
}
]
}
],
"actions": [
{
"type": {
"inverted": false,
"value": "Create"
},
"parameters": [
"",
"time",
"MouseX(\"\",0)",
"MouseY(\"\",0)",
""
],
"subInstructions": []
},
{
"type": {
"inverted": false,
"value": "ModVarObjet"
},
"parameters": [
"time",
"timer",
"=",
"0"
],
"subInstructions": []
}
],
"events": []
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "SourisSurObjet"
},
"parameters": [
"time",
"",
"yes",
""
],
"subInstructions": []
}
],
"actions": [
{
"type": {
"inverted": false,
"value": "ModVarObjet"
},
"parameters": [
"time",
"timer",
"=",
"0"
],
"subInstructions": []
}
],
"events": []
}
]
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Comment",
"color": {
"b": 109,
"g": 230,
"r": 255,
"textB": 0,
"textG": 0,
"textR": 0
},
"comment": "For each time object, increase the value of the timer variable by TimeDelta() and update the text object to display this value",
"comment2": ""
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "NbObjet"
},
"parameters": [
"time",
">",
"0"
],
"subInstructions": []
}
],
"actions": [],
"events": [
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::ForEach",
"object": "time",
"conditions": [],
"actions": [
{
"type": {
"inverted": false,
"value": "ModVarObjet"
},
"parameters": [
"time",
"timer",
"+",
"TimeDelta()"
],
"subInstructions": []
},
{
"type": {
"inverted": false,
"value": "TextObject::String"
},
"parameters": [
"time",
"=",
"\"Timer: \" + ToString(floor(time.Variable(timer))) + \"s\""
],
"subInstructions": []
}
],
"events": []
}
]
}
],
"layers": [
{
"name": "",
"visibility": true,
"cameras": [
{
"defaultSize": true,
"defaultViewport": true,
"height": 0,
"viewportBottom": 1,
"viewportLeft": 0,
"viewportRight": 1,
"viewportTop": 0,
"width": 0
}
],
"effects": []
}
],
"behaviorsSharedData": []
}
],
"externalEvents": [],
"externalLayouts": [],
"externalSourceFiles": []
}

View File

@@ -1,6 +0,0 @@
Images and Sounds included for testing purposes only, no commercial use allowed!
The actual source, project file is free to use for any purposes.
Have fun!
Find more templates and examples at https://gametemplates.itch.io/

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1 @@
Example showing various usage of objects timers (timers that are stored into instances of objects on the scene, as opposed to scene timers which are stored by the scene).

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

View File

@@ -38,7 +38,6 @@ const exampleNames = [
'find-diagonals',
'health-bar',
'infinite-scrolling-background',
'instance-timer',
'inventory-system',
'isometric-game',
'javascript-blocks-in-platformer',
@@ -53,6 +52,7 @@ const exampleNames = [
'multitouch',
'object-gravity',
'object-selection',
'objects-timers',
'open-url-in-browser',
'parallax-scrolling',
'parallax',

View File

@@ -993,27 +993,6 @@ module.exports = {
}
]
},
"instance-timer": {
"description": "Learn how to have your objects on the scene have their own timers.",
"usedExtensions": [
{
"fullName": "Text object",
"name": "TextObject"
},
{
"fullName": "Mouse features",
"name": "BuiltinMouse"
},
{
"fullName": "Standard events",
"name": "BuiltinCommonInstructions"
},
{
"fullName": "Base object",
"name": "BuiltinObject"
}
]
},
"inventory-system": {
"description": "Learn how to display an inventory, with object that can be addded or removed, and how to persist it in storage.",
"usedExtensions": [
@@ -1480,6 +1459,35 @@ module.exports = {
}
]
},
"objects-timers": {
"description": "Example showing various usage of objects timers (timers that are stored into instances of objects on the scene, as opposed to scene timers which are stored by the scene).",
"usedExtensions": [
{
"fullName": "Sprite",
"name": "Sprite"
},
{
"fullName": "Text object",
"name": "TextObject"
},
{
"fullName": "Scene management features",
"name": "BuiltinScene"
},
{
"fullName": "Base object",
"name": "BuiltinObject"
},
{
"fullName": "Mouse features",
"name": "BuiltinMouse"
},
{
"fullName": "Standard events",
"name": "BuiltinCommonInstructions"
}
]
},
"open-url-in-browser": {
"description": "This shows how to open a website on the system default browser.",
"usedExtensions": [

View File

@@ -27,7 +27,6 @@ import facebookInstantGame from '../fixtures/facebook-instant-game/facebook-inst
import findDiagonals from '../fixtures/find-diagonals/find-diagonals.json';
import healthBar from '../fixtures/health-bar/health-bar.json';
import infiniteScrollingBackground from '../fixtures/infinite-scrolling-background/infinite-scrolling-background.json';
import instanceTimer from '../fixtures/instance-timer/instance-timer.json';
import inventorySystem from '../fixtures/inventory-system/inventory-system.json';
import isometricGame from '../fixtures/isometric-game/isometric-game.json';
import javascriptBlocksInPlatformer from '../fixtures/javascript-blocks-in-platformer/javascript-blocks-in-platformer.json';
@@ -42,6 +41,7 @@ import moveObjectWithPhysics from '../fixtures/move-object-with-physics/move-obj
import multitouch from '../fixtures/multitouch/multitouch.json';
import objectGravity from '../fixtures/object-gravity/object-gravity.json';
import objectSelection from '../fixtures/object-selection/object-selection.json';
import objectsTimers from '../fixtures/objects-timers/objects-timers.json';
import openUrlInBrowser from '../fixtures/open-url-in-browser/open-url-in-browser.json';
import parallax from '../fixtures/parallax/parallax.json';
import parallaxScrolling from '../fixtures/parallax-scrolling/parallax-scrolling.json';
@@ -145,8 +145,6 @@ export default class BrowserProjectOpener {
return Promise.resolve(healthBar);
} else if (url === 'example://infinite-scrolling-background') {
return Promise.resolve(infiniteScrollingBackground);
} else if (url === 'example://instance-timer') {
return Promise.resolve(instanceTimer);
} else if (url === 'example://inventory-system') {
return Promise.resolve(inventorySystem);
} else if (url === 'example://isometric-game') {
@@ -175,6 +173,8 @@ export default class BrowserProjectOpener {
return Promise.resolve(objectGravity);
} else if (url === 'example://object-selection') {
return Promise.resolve(objectSelection);
} else if (url === 'example://objects-timers') {
return Promise.resolve(objectsTimers);
} else if (url === 'example://open-url-in-browser') {
return Promise.resolve(openUrlInBrowser);
} else if (url === 'example://parallax') {

View File

@@ -1,420 +0,0 @@
{
"firstLayout": "",
"gdVersion": {
"build": 97,
"major": 4,
"minor": 0,
"revision": 0
},
"properties": {
"folderProject": false,
"linuxExecutableFilename": "",
"macExecutableFilename": "",
"orientation": "landscape",
"packageName": "com.example.gamename",
"projectFile": "C:\\Users\\szoszo\\Desktop\\Projects\\gametemplates\\gdevelop5\\instance-timer\\game.json",
"sizeOnStartupMode": "",
"useExternalSourceFiles": false,
"version": "1.0.0",
"winExecutableFilename": "",
"winExecutableIconFile": "",
"name": "Project",
"author": "",
"windowWidth": 800,
"windowHeight": 600,
"latestCompilationDirectory": "C:\\Users\\szoszo\\Desktop\\instance-timer",
"maxFPS": 60,
"minFPS": 10,
"verticalSync": false,
"platformSpecificAssets": {},
"loadingScreen": {
"showGDevelopSplash": true
},
"extensions": [
{
"name": "BuiltinObject"
},
{
"name": "BuiltinAudio"
},
{
"name": "BuiltinVariables"
},
{
"name": "BuiltinTime"
},
{
"name": "BuiltinMouse"
},
{
"name": "BuiltinKeyboard"
},
{
"name": "BuiltinJoystick"
},
{
"name": "BuiltinCamera"
},
{
"name": "BuiltinWindow"
},
{
"name": "BuiltinFile"
},
{
"name": "BuiltinNetwork"
},
{
"name": "BuiltinScene"
},
{
"name": "BuiltinAdvanced"
},
{
"name": "Sprite"
},
{
"name": "BuiltinCommonInstructions"
},
{
"name": "BuiltinCommonConversions"
},
{
"name": "BuiltinStringInstructions"
},
{
"name": "BuiltinMathematicalTools"
},
{
"name": "BuiltinExternalLayouts"
}
],
"platforms": [
{
"name": "GDevelop JS platform"
}
],
"currentPlatform": "GDevelop JS platform"
},
"resources": {
"resources": [],
"resourceFolders": []
},
"objects": [],
"objectsGroups": [],
"variables": [],
"layouts": [
{
"b": 209,
"disableInputWhenNotFocused": true,
"mangledName": "NewScene",
"name": "NewScene",
"oglFOV": 90,
"oglZFar": 500,
"oglZNear": 1,
"r": 209,
"standardSortMethod": true,
"stopSoundsOnStartup": true,
"title": "",
"v": 209,
"uiSettings": {
"grid": false,
"gridB": 255,
"gridG": 180,
"gridHeight": 32,
"gridOffsetX": 0,
"gridOffsetY": 0,
"gridR": 158,
"gridWidth": 32,
"snap": true,
"windowMask": false,
"zoomFactor": 1
},
"objectsGroups": [],
"variables": [],
"instances": [
{
"angle": 0,
"customSize": false,
"height": 0,
"layer": "",
"locked": false,
"name": "message",
"width": 0,
"x": 158.204,
"y": 20.0816,
"zOrder": 1,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
}
],
"objects": [
{
"bold": false,
"italic": false,
"name": "time",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"behaviors": [],
"string": "0",
"font": "",
"characterSize": 20,
"color": {
"b": 0,
"g": 0,
"r": 0
}
},
{
"bold": false,
"italic": false,
"name": "message",
"smoothed": true,
"type": "TextObject::Text",
"underlined": false,
"variables": [],
"behaviors": [],
"string": "Click/Touch to create a text object displaying a timer.\nClick/Touch a text object to reset the timer.",
"font": "",
"characterSize": 20,
"color": {
"b": 0,
"g": 0,
"r": 0
}
}
],
"events": [
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Comment",
"color": {
"b": 109,
"g": 230,
"r": 255,
"textB": 0,
"textG": 0,
"textR": 0
},
"comment": "when left mouse button is released and the mouse is not on a timer, create a new time object\nIn case the mouse is on a time object, reset the timer variable of the time object",
"comment2": ""
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "MouseButtonReleased"
},
"parameters": [
"",
"Left"
],
"subInstructions": []
}
],
"actions": [],
"events": [
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "BuiltinCommonInstructions::Not"
},
"parameters": [],
"subInstructions": [
{
"type": {
"inverted": false,
"value": "SourisSurObjet"
},
"parameters": [
"time",
"",
"",
""
],
"subInstructions": []
}
]
}
],
"actions": [
{
"type": {
"inverted": false,
"value": "Create"
},
"parameters": [
"",
"time",
"MouseX(\"\",0)",
"MouseY(\"\",0)",
""
],
"subInstructions": []
},
{
"type": {
"inverted": false,
"value": "ModVarObjet"
},
"parameters": [
"time",
"timer",
"=",
"0"
],
"subInstructions": []
}
],
"events": []
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "SourisSurObjet"
},
"parameters": [
"time",
"",
"yes",
""
],
"subInstructions": []
}
],
"actions": [
{
"type": {
"inverted": false,
"value": "ModVarObjet"
},
"parameters": [
"time",
"timer",
"=",
"0"
],
"subInstructions": []
}
],
"events": []
}
]
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Comment",
"color": {
"b": 109,
"g": 230,
"r": 255,
"textB": 0,
"textG": 0,
"textR": 0
},
"comment": "For each time object, increase the value of the timer variable by TimeDelta() and update the text object to display this value",
"comment2": ""
},
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::Standard",
"conditions": [
{
"type": {
"inverted": false,
"value": "NbObjet"
},
"parameters": [
"time",
">",
"0"
],
"subInstructions": []
}
],
"actions": [],
"events": [
{
"disabled": false,
"folded": false,
"type": "BuiltinCommonInstructions::ForEach",
"object": "time",
"conditions": [],
"actions": [
{
"type": {
"inverted": false,
"value": "ModVarObjet"
},
"parameters": [
"time",
"timer",
"+",
"TimeDelta()"
],
"subInstructions": []
},
{
"type": {
"inverted": false,
"value": "TextObject::String"
},
"parameters": [
"time",
"=",
"\"Timer: \" + ToString(floor(time.Variable(timer))) + \"s\""
],
"subInstructions": []
}
],
"events": []
}
]
}
],
"layers": [
{
"name": "",
"visibility": true,
"cameras": [
{
"defaultSize": true,
"defaultViewport": true,
"height": 0,
"viewportBottom": 1,
"viewportLeft": 0,
"viewportRight": 1,
"viewportTop": 0,
"width": 0
}
],
"effects": []
}
],
"behaviorsSharedData": []
}
],
"externalEvents": [],
"externalLayouts": [],
"externalSourceFiles": []
}

File diff suppressed because it is too large Load Diff