[Gambas-user] Timer question
JB Skaggs
jbskaggs at ...1871...
Wed Apr 1 10:45:41 CEST 2009
If I understand what you mean this is what I did to be able to pause and
start a timer as the same spot and continue.
Mind you I am just beginning to understand this stuff. So bear with the
inefficient coding.
' Gambas class file
PUBLIC a AS Integer ' for seconds
PUBLIC i AS Integer ' for new timer1.delay
' timer1.delay set to 10000 for ten seconds, timer 2 for 1000, and
timer3 for 1
'button1 stops and displays seconds passed
'button 2 starts and displays new seconds to go and counts up to it.
'if timer1 counts all the way down it will turn the button1 red
PUBLIC SUB Form_Open()
a = 0 'integer for seconds
Timer1.Enabled = TRUE 'starts main timer
Timer2.Enabled = TRUE 'starts seconds counter
END
PUBLIC SUB Timer2_Timer() ' this is little counter that counts seconds
a += 1
Timer3.enabled = TRUE
END
PUBLIC SUB timer3_timer() 'resets timer2 AND displays seconds
ValueBox1.Value = a
Timer2.Start
END
PUBLIC SUB Button1_Click() 'stops timers and gets time from A and
converts to seconds
Timer3.Stop
Timer2.Stop
i = (10000 - (a * 1000)) 'the new delay setting for timer.delat to start
where left off
ValueBox1.Value = a
END
PUBLIC SUB Button2_Click() 'starts the timer1 again and resets A
Timer1.delay = i
Timer1.STOP
ValueBox2.Value = (Timer1.Delay) / 1000
Timer1.Start
Timer2.Start
a = 0
END
PUBLIC SUB Timer1_Timer() ' what happens when timer1 goes off
Button1.BackColor = Color.Red
Timer2.Stop
Timer3.Stop
ValueBox1.Value = a
END
JB SKaggs
On Wed, 2009-04-01 at 09:52 +1100, richard terry wrote:
> On Wed, 1 Apr 2009 09:20:37 am jbskaggs wrote:
> > I use timers alot in the game I am writing.
> >
> > I just use timer1.delay=5
> that wasn't the question - I wanted to re-set the timer to stop the event
> triggering until the key action pauses and then let the timer progress to
> execute
> >
> > that is pretty close to immediate action. then i rest the delay later
> >
> > JB
> >
> > richard terry-5 wrote:
> > > I want to be able to reset the timers time to 0 at will, without stopping
> > > the
> > > timer, so that I can link it to the keypress of a textbox. Every time the
> > > user hits a key, the place the timer is up to is reset, once they lag,
> > > then
> > > the timer event fires.
> > >
> > > Dosn't seem to be such a property.
> > >
> > > Thanks.
> > >
> > > -------------------------------------------------------------------------
> > >----- _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list