贝斯特,
今天我用javascript制作了一个旋转图像程序。
HTML:
<img id="image" src="http://static.kuikr.com/images/quikr_logo_f3.png" >
<button onclick="start()">Start</button>
<button onclick="stop()">Stop</button>
JS:
var deg = 2; // starting
var rotation_diff = 30;
var rotation;
function start()
{
rotation=1;
myFunction();
}
function stop()
{
rotation=0;
}
function myFunction()
{
var img = document.getElementById("image");
img.style.webkitTransform = "rotate("+deg+"deg)";
img.style.transform = "rotate("+deg+"deg)";
img.style.MozTransform = "rotate("+deg+"deg)";
img.style.msTransform = "rotate("+deg+"deg)";
img.style.OTransform = "rotate("+deg+"deg)";
if(rotation==1) {
setTimeout("myFunction()",1000); }
deg = deg + rotation_diff;
}
你看我已经制作了一个开始和停止按钮,但我希望这有一个幸运之轮。当它以数字停止时,我希望javascript可以提醒数字。
感谢您的时间,
答案 0 :(得分:1)
你可以算出你的命运数字所在的度数,然后使用它们。 例如(伪代码)
if rotation is greater than 0 and less than 90 then score = 50
if rotation is greater than 90 and less than 180 ect.