加速斜坡“增量”适用于计数器 AS3

发布于 2024-08-21 00:45:36 字数 1302 浏览 5 评论 0原文

我的计数器以恒定速度达到 100。 有没有办法提高计数器的速度?

Flash 可以使用三角函数值来影响速度, 但我不知道这是否可以改变计时器类别 即时。

它有几个部分。
(a.) 提高计数器的速度?

(b.) 提高某些部分的速度?
- 有一个范围
- 90-100 开始逐渐增加

增量三角函数的任何一个示例都会有所帮助

替代文本 http://www.ashcraftband.com/myspace/videodnd/icon10.jpg

我想应用的触发示例

var xVel:Number = Math.cos(radians) * speed;
var yVel:Number = Math.sin(radians) * speed;
//-------------------------------------------//
return deg * (Math.PI/180);

加速计数器< /strong>“所有好例子”

//EVERYONE HELPED "decimals corrected" 
var timer:Timer = new Timer(10);  
var count:int = 0; //start at -1 if you want the first decimal to be 0  
var fcount:int = 0; 

timer.addEventListener(TimerEvent.TIMER, incrementCounter);  
timer.start();  


function incrementCounter(event:TimerEvent) {  
  count++;  
  //
  fcount=int(count*count/10000);//starts out slow... then speeds up 
  //
  var whole_value:int = int(fcount / 100); //change value 
  var tenths:int = int(fcount / 10) % 10;   
  var hundredths:int = int(fcount) % 10; 

“感谢您花时间提供帮助”

My counter goes to 100 at a constant speed.
Is there a way to ramp the speed of a counter?

Flash can use trigonometry values to effect speed,
but I don't know if that can change the timer class
on-the-fly.

There's a couple parts to it.
(a.) ramp the speed of a counter?

(b.) ramp in certain parts?
- have a range
- 90-100 starts ramping

either example of trigonometry of increments would be helpful

alt text http://www.ashcraftband.com/myspace/videodnd/icon10.jpg

TRIG EXAMPLE I WANT TO APPLY

var xVel:Number = Math.cos(radians) * speed;
var yVel:Number = Math.sin(radians) * speed;
//-------------------------------------------//
return deg * (Math.PI/180);

ACCELLERATING COUNTER "all good examples"

//EVERYONE HELPED "decimals corrected" 
var timer:Timer = new Timer(10);  
var count:int = 0; //start at -1 if you want the first decimal to be 0  
var fcount:int = 0; 

timer.addEventListener(TimerEvent.TIMER, incrementCounter);  
timer.start();  


function incrementCounter(event:TimerEvent) {  
  count++;  
  //
  fcount=int(count*count/10000);//starts out slow... then speeds up 
  //
  var whole_value:int = int(fcount / 100); //change value 
  var tenths:int = int(fcount / 10) % 10;   
  var hundredths:int = int(fcount) % 10; 

"thanks for spending the time to help"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初见 2024-08-28 00:45:37

为什么不使用众多 ActionScript 补间引擎之一,例如 TweenLite

它可以为您完成所有数学计算,您只需给它要插值的变量、其最终值、插值的总持续时间,并在不同的缓动函数之间进行选择。

在某些情况下,如果您需要真正自定义的内容,您只需将 Number 变量从 0 调整为 1,持续时间 & 即可。您想要使用的缓动函数,然后定义一个 onUpdate 函数来让您使用该值进行工作,该值将随时间进行插值。

Why don't you use one of the many ActionScript tweening engines such as TweenLite?

It can do all the math for you, you just need to give it what variable to interpolate, its final value, the total duration of the interpolation, and chose between the differents easing functions.

In some cases, if you need something really custom, you can just tween a Number variable from 0 to 1, with the duration & easing function you want to use, and then define an onUpdate function to let you do your work with this value, which will be interpolated through time.

花开半夏魅人心 2024-08-28 00:45:37

您可以通过将公式应用于计数变量来获得加速效果的简单近似值,如下所示:

var timer:Timer = new Timer(10); 
var count:int = 0; //start at -1 if you want the first decimal to be 0 
var fcount:int = 0;

timer.addEventListener(TimerEvent.TIMER, incrementCounter); 
timer.start(); 


function incrementCounter(event:TimerEvent) { 
  count++; 
  fcount=int(count*count/10000);//starts out slow... then speeds up 
  var whole_value:int = int(fcount/100); 
  var decimal_value:int = int(fcount/10) % 10;
  var hun_value:int = fcount % 10;
  mytext.text = whole_value + " : " + decimal_value + hun_value; 
} 

即:计数有规律地增加,但 fcount 与计数的平方成比例地加速。

如果您想要三角函数,可以尝试 fcount=int(acos(count/10000)*10000/(2*Math.PI)); 但这仅适用于 count<=10000。

You can get an simple approximation of a speeding-up effect by applying a formula to your count variable, like this:

var timer:Timer = new Timer(10); 
var count:int = 0; //start at -1 if you want the first decimal to be 0 
var fcount:int = 0;

timer.addEventListener(TimerEvent.TIMER, incrementCounter); 
timer.start(); 


function incrementCounter(event:TimerEvent) { 
  count++; 
  fcount=int(count*count/10000);//starts out slow... then speeds up 
  var whole_value:int = int(fcount/100); 
  var decimal_value:int = int(fcount/10) % 10;
  var hun_value:int = fcount % 10;
  mytext.text = whole_value + " : " + decimal_value + hun_value; 
} 

ie: count is increasing regularly, but fcount speeds up in proportion to the square of count.

If you want a trig function, you could try fcount=int(acos(count/10000)*10000/(2*Math.PI)); but this would only work for count<=10000.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文