41
Beginners' Technical Questions / Some advice with timers please. (SOLVED).
« on: 28 Apr 2011, 23:20 »
Hi peeps.
I wonder if anyone could help me with this piece of code I have.
I haven't worked with timers before as I haven't needed them but now I do.
If at all possible I am looking for advice for the best way of using them.
Now I have a couple of stars that twinkle (star objects) I want them to twinkle a pause and then twinkle and so on.
In 'Player enters room before fadein' I put this.
In my room script I have made the 'function repeatedly_execute_always()' and put this.
This works as I want it to but it just seems clunky somehow. Is there a better way of doing this?
Many thanks.
Jay.
I wonder if anyone could help me with this piece of code I have.
I haven't worked with timers before as I haven't needed them but now I do.
If at all possible I am looking for advice for the best way of using them.
Now I have a couple of stars that twinkle (star objects) I want them to twinkle a pause and then twinkle and so on.
In 'Player enters room before fadein' I put this.
Code: Adventure Game Studio
- SetTimer(1,300);
- SetTimer(2,212);
In my room script I have made the 'function repeatedly_execute_always()' and put this.
Code: Adventure Game Studio
- function repeatedly_execute_always() {
- // Script for twinkling stars. //
- if (IsTimerExpired(1) == 1) {
- object[3].Animate(0,5,eOnce,eNoBlock);
- SetTimer(1,300);
- return;
- }
- if (IsTimerExpired(2) == 1) {
- object[4].Animate(0,5,eOnce,eNoBlock);
- SetTimer(2,212);
- return;
- }
- }
This works as I want it to but it just seems clunky somehow. Is there a better way of doing this?
Many thanks.
Jay.