GDevelop-examples
GDevelop-examples copied to clipboard
TIME JavaScript (simple code)
In this example you will see how to display real time in a very simple way via javascript editor.
I made it so that there are no gaps. For example: 4: 7: 8 is 04:07:08
Checklist
- [x] I've followed all of the best practices.
- [x] My game has a proper name in the game properties.
- [x] My game package name behind with
com.example.
. - [x] My game has all events unfolded.
- [x] I've added myself as the author in the game properties.
- [x] I've included a file called "README.md" with a description in proper English, explaining what this example is doing.
- [x] I confirm that this game and all of its resources can be integrated to this GitHub repository, distributed and MIT licensed.
- [x] I've cleaned unused resources.
Game folder
Hi, Nice example Here is my review
- This: var currentHours = today.getHours(); var currentMins = today.getMinutes(); var currentSecs = today.getSeconds();
Does the same as:
var currentHours = ('0'+today.getHours()).substr(-2);
var currentMins = ('0'+today.getMinutes()).substr(-2);
var currentSecs = ('0'+today.getSeconds()).substr(-2);
Then why add 0
and then remove it using substr
?
- There is a unused
NewExternalLayout
, please remove it - There is no real reason to have the JS events inside a external event. Move to the Event sheet
- Change the package name to
com.example.systemtime
- There is an invalid resource. Please remove it
- You can change the background color by right clicking in the scene editor ->
Scene properties
->Scene background color
. No need to use an action - It is not important that the scene variable name is the same as the var in the Js codeblock. It's the opposite (as far as I know). In the Js codeblock, your are getting the value of the scene variable. So, the comment is a bit misleading
- There is an unsed
year
scene variable - Initialize the variable
time
in the variables editor - There is an unused instance variable of the text
- Please follow the best practices
:)
Hello, thank you for your interest
.
I tried to put this code instead of mine, but what I get is a clock where there is no “0” in the first place. That doesn't really look good to me
I will try to explain a bit how my code works (picture below)
As you can see. Our program first gets a "0", then gets a "number" from the system time. But if the system gives only the second number in a row, "0" is still valid in our code. If we get both two numbers, then we subtract 0.
Please include the whole project file and not only the json file :)
My bad for misunderstanding the use of the code :sweat_smile:
What about submitting an extension instead of an example?