soy nuevo en actionscript3 flash. Tengo una variable int y me gustaría agregar +2 cada segundo desde que comenzó el juego. Cómo puedo hacer esto ? ¿Cómo sé cuánto tiempo ha transcurrido? ¡gracias por adelantado!actionscript 3 cómo hacer un seguimiento del tiempo transcurrido?
6
A
Respuesta
19
getTimer() devolverá un int de exactamente cuántos milisegundos desde el inicio del flash.
import flash.utils.getTimer;
var myInt:int = getTimer() * 0.001;
myInt ahora serán los segundos que el programa haya estado funcionando.
editar: oh, para decir cuánto tiempo ha estado funcionando solo mantenga el myInt inicial y compruébelo con el temporizador actual.
cuando comienza el juego por primera vez.
var startTime:int = getTimer();
luego, cada cuadro o cada vez que necesite comprobarlo.
var currentTime:int = getTimer();
var timeRunning:int = (currentTime - startTime) * 0.001; // this is how many seconds the game has been running.
1
var a:int = 0;
var onTimer:Function = function (e:TimerEvent):void {
a += 2;
}
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
0
var countdown:Timer = new Timer(1000);
countdown.addEventListener(TimerEvent.TIMER, timerHandler);
countdown.start();
function timerHandler(e:TimerEvent):void
{
var minute = Math.floor(countdown.currentCount/60);
if(minute < 10)
minute = '0'+minute;
var second = countdown.currentCount % 60;
if(second < 10)
second = '0'+second;
var timeElapsed = minute +':'+second;
trace(timeElapsed);
}
Cuestiones relacionadas
- 1. Manipulación y almacenamiento del tiempo transcurrido
- 2. Cálculo del tiempo transcurrido en un programa C en milisegundos
- 3. ¿Cómo hacer seguimiento de marcas de tiempo
- 4. Medición del tiempo transcurrido en python
- 5. localizando el tiempo transcurrido
- 6. tiempo transcurrido en Qt
- 7. actionscript 3 init()
- 8. actionscript 3 y JSON
- 9. ActionScript 3: animación programática Smooth
- 10. Powershell mostrar el tiempo transcurrido
- 11. Obtener URL del navegador actual - ActionScript 3
- 12. Trigonometría triangular (ActionScript 3)
- 13. rápido tiempo transcurrido en Linux
- 14. Actionscript 3 REPL
- 15. Depuración Haxe (ActionScript 3)
- 16. Colecciones Inmutables Actionscript 3
- 17. Descarga de un ByteArray con Actionscript 3
- 18. Dynamic Audio Generation Actionscript 3
- 19. ¿Cómo funciona Vector map() en actionscript 3?
- 20. ¿Es el diccionario ActionScript 3 un hashmap?
- 21. ¿cómo elimino/gc un objeto en Actionscript 3?
- 22. transcurrido el tiempo para cada regla
- 23. Python - ¿Cómo calcular el tiempo transcurrido desde la fecha X?
- 24. Seguimiento automático del tiempo de desarrollo
- 25. Herencia múltiple en ActionScript 3
- 26. Obteniendo el tiempo transcurrido (Objective-c)
- 27. Actionscript 3 - Importar archivo SVG
- 28. Transact-SQL para resumir el tiempo transcurrido
- 29. ActionScript 3 ¿Especificación como PDF?
- 30. ¿Cómo dibujo texto en un sprite de ActionScript 3?
http://help.adobe.com/en_US/as2/reference/flashlite/WS5b3ccc516d4fbf351e63e3d118cd9b5f6e-7a54.html hay poca ambigüedad, veo en getTimer del IDE entero de retorno, mientras que la documentación de flash dice getTimer devuelve Número. Sería útil saber cuál es el correcto. cheers – GameDeveloper
la declaración de función en los encabezados (biblioteca) es "función pública getTimer(): int" por lo que devuelve un int. por cierto, esas son las referencias de ActionScript 2 y no las de ActionScript 3. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html#getTimer() – Feltope
me salvaste headhackes :) – GameDeveloper