Hey,
I'm trying to get a random number for a small game which lights up random lights. I can't figure out a way to get the number random. I've tried seeding the Random() function with current time, but it's not working. It always lights up the third light.
Here's my code. It's the onTriggered part of a timer in QML.
onTriggered: {
var now = new Date();
var seed = now.getSeconds();
var num = (Math.floor(4 * Math.random(seed)));
switch(num % 4) {
case 0:
btn1.color = "#ff0000";
break;
case 1:
btn2.color = "#0000ff";
break;
case 2:
btn3.color = "#00ffff";
break;
case 3:
btn4.color = "#00ff00";
break;
}
}