SWSGKloss November 28th, 2016 Got another question,
In my Memory game there should be a timer as well as a highscore.
The more important thing is a working timer. So is there an easy way coding it?
Have read this answer: Click
But I just want to stop how long the users will need to find all pairs. So the timer should start when the first card is flipped and stop when the last pair is found. Refering to your YT-Tutorial the timer should stop when your cards "fade out".
Don't know if it is easier to import some java lib's and code it that way or if there is a quick solution in your framework.
Blessings,
Flo
SWSGKloss November 29th, 2016 Okay, this solution works quite well.
I've changed it to an 100ms interval so I am able to measure .1 secs.
Last Question to this topic:
Any way to format the written text? Checked a way where I've added .1 on the time in the tick function, but it's a text, no float ...
So I got literally no idea how to format the count.
Gio November 29th, 2016 If you are doing 100ms intervals, it makes sense to increment the time variable by 0.1 rather than 1. In other words, I'd change your tick function to this:
this.time += 0.1;
this.getSprite().setText(this.time);
Note that this.time is a number, it gets automatically converted to a string when you pass it to setText. You could do anything you like to it before passing it to setText, for example the argument of setText could be this.time.toFixed(1) to force 1 decimal digit, or this.time.toString(16) to convert it to a hex string, or you know, any sort of formatting that you like :)
SWSGKloss November 29th, 2016 Tried it with 0.1 in "tick", but then I get results like 4.99999999 or 5.000000001...
Checked it also with:
this.time += 0.1;
this.time.toFixed(1,2); //Also tried (1)
this.getSprite().setText(this.time);
No changes.
Is ther any documentation of wade where I can read through all functions and stuff like that? Maybe then I don't have to ask that much questions :-P
Gio November 29th, 2016 The documentation for all WADE functions is here:
WADE API reference
However it's more a JavaScript question than a WADE question. The problem with the code above is that toFixed() doesn't modify the original number, it returns a new string, so you want
this.time += 0.1;
this.getSprite().setText(this.time.toFixed(1));
SWSGKloss November 29th, 2016 Oh, okay. That worked.
Again: Thank you for your fast responses and effort you put in this project and the questions around it!