Actionscript 3 带有动作脚本3的倒计时计时器的随机开始数
我正在尝试制作一个带有倒计时的flash游戏,它将以一个随机数开始。从10秒开始以任何数字开头的东西。-15秒。我对动作脚本非常陌生,这是我的第一个游戏。我让计时器从10点开始工作到1点 以下是我到目前为止得到的信息:Actionscript 3 带有动作脚本3的倒计时计时器的随机开始数,actionscript-3,random,timer,Actionscript 3,Random,Timer,我正在尝试制作一个带有倒计时的flash游戏,它将以一个随机数开始。从10秒开始以任何数字开头的东西。-15秒。我对动作脚本非常陌生,这是我的第一个游戏。我让计时器从10点开始工作到1点 以下是我到目前为止得到的信息: var fl_SecondsToCountDown_2:Number = 10; var fl_CountDownTimerInstance_2:Timer = new Timer(1000, fl_SecondsToCountDown_2); fl_CountDownTim
var fl_SecondsToCountDown_2:Number = 10;
var fl_CountDownTimerInstance_2:Timer = new Timer(1000, fl_SecondsToCountDown_2);
fl_CountDownTimerInstance_2.addEventListener(TimerEvent.TIMER, fl_CountDownTimerHandler_2);
fl_CountDownTimerInstance_2.start();
function fl_CountDownTimerHandler_2(event:TimerEvent):void
{
if (fl_SecondsToCountDown_2 <= 1) {
gotoAndStop(2);
}
trace(fl_SecondsToCountDown_2 + " seconds");
fl_SecondsToCountDown_2--;
}
var fl\u seconds to倒计时2:数字=10;
var fl_CountDownTimerInstance_2:计时器=新计时器(1000,fl_Second至倒计时_2);
fl_CountDownTimerInstance_2.addEventListener(TimerEvent.TIMER,fl_CountDownTimerHandler_2);
fl_CountDownTimerInstance_2.start();
函数fl_CountDownTimerHandler_2(事件:TimerEvent):无效
{
如果(fl_second to倒计时_2Math.random()
返回一个从0到小于1的随机数。因此,如果将其与n
相乘,则得到一个从0到小于n的随机数。将其转换为int将生成一个从0到n-1
的随机整数。如果将m
添加到它,则得到从m
到n-1
的随机整数。因此从10到15得到一个您需要执行以下操作:
var r:int = 10 + int(Math.random() * 6);
我应该把这个放在哪里?@Therobinson兄弟,你正在使用fl\u seconds to countdown\u 2
作为计数器。所以用这个作为fl\u seconds to countdown\u 2
的值。非常感谢!我得到了我需要的东西。