timer event and doevents question

ta1dr

Member
Licensed User
Longtime User
Hi All
I want to develop simple game for my son but it is not complate I have problems
I use timer and event but call run_it subrutine
but no change btn4 color

B4X:
'Activity module
Sub Process_Globals
   
   Dim timer1 As Timer 
   
End Sub

Sub Globals
   
   
   Dim mode As Boolean
   Dim rtc As İnt
   Dim zaman As İnt
   Dim bnumber As İnt

   Dim Label1 As Label
   Dim btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btn11,btn12 As Button

   
   Dim Label2 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    activity.LoadLayout("main")
    timer1.Initialize("timer1",100)
   timer1_tick
   timer1.Enabled=True
   zaman=599
   label2.Text=zaman
   if firsttime Then
      run_it
   End if   
   End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub timer1_Tick
   if zaman > 0 Then
      zaman= zaman - 1
   Else
       zaman=599
   End if
   label2.Text=zaman
   mode=Not(mode)   
   rtc=rtc + 1
    
End Sub
Sub btnevent_click
   Dim send As Button
   send=Sender
   label1.Text=send.Tag
End Sub
Sub run_it
    Dim x As İnt
   x=0
   Do While (x=0)
          DoEvents
         if rtc > 5 Then
               rtc=0
               if mode=False Then
                  btn4.Color=Colors.RGB(0,255,0)
            Else
                  btn4.color=Colors.RGB(255,0,0)
            End if  
         End if  
   Loop  
End Sub
Could you help me ?
Ahmet
 

Attachments

  • simple_game.zip
    6.9 KB · Views: 170
Top