I IDONTKNOW New Member Licensed User May 11, 2018 #1 Here is what I have so far. The wait timer works perfectly if you put the message box after the wait for but in the new game sub it immediately says "cool" "yay" without waiting. Any help would be appreciated. Sub WaitSecs(secs As Int) Dim WaitTimer As Timer WaitTimer.Initialize("WaitTimer",0) WaitTimer.Interval = secs * DateTime.TicksPerSecond WaitTimer.Enabled = True Wait For WaitTimer_Tick WaitTimer.Enabled = False End Sub Sub NewGameBtn_Click WaitSecs(10) Msgbox("Cool","YAY") End Sub
Here is what I have so far. The wait timer works perfectly if you put the message box after the wait for but in the new game sub it immediately says "cool" "yay" without waiting. Any help would be appreciated. Sub WaitSecs(secs As Int) Dim WaitTimer As Timer WaitTimer.Initialize("WaitTimer",0) WaitTimer.Interval = secs * DateTime.TicksPerSecond WaitTimer.Enabled = True Wait For WaitTimer_Tick WaitTimer.Enabled = False End Sub Sub NewGameBtn_Click WaitSecs(10) Msgbox("Cool","YAY") End Sub
MarkusR Well-Known Member Licensed User Longtime User May 11, 2018 #2 Code: Copy Sub Test Log("Wait") Wait For (WaitSecs(10)) Complete (Result As Boolean) Log("OK") End Sub Sub WaitSecs(secs As Int) As ResumableSub Sleep(secs*1000) Return True End Sub Upvote 0
Code: Copy Sub Test Log("Wait") Wait For (WaitSecs(10)) Complete (Result As Boolean) Log("OK") End Sub Sub WaitSecs(secs As Int) As ResumableSub Sleep(secs*1000) Return True End Sub
udg Expert Licensed User Longtime User May 12, 2018 #4 You may find useful my class xToastMessage, an XUI/B4X class born to take the B4A standard ToastMessage to B4J, but which then turned to a more complete tool. Source code is provided so you can tailor it to your needs. Upvote 0
You may find useful my class xToastMessage, an XUI/B4X class born to take the B4A standard ToastMessage to B4J, but which then turned to a more complete tool. Source code is provided so you can tailor it to your needs.
MarkusR Well-Known Member Licensed User Longtime User May 12, 2018 #5 you spoke about a game. a statemaschine will also be useful, a timer will trigger something you do at a current state. so you can memory the time at state x , next state, condition time1-time2 >= 10 secs then next state Upvote 0
you spoke about a game. a statemaschine will also be useful, a timer will trigger something you do at a current state. so you can memory the time at state x , next state, condition time1-time2 >= 10 secs then next state
Erel B4X founder Staff member Licensed User Longtime User May 13, 2018 #6 Better to use Sleep directly: Code: Copy Sub Test Log("Wait") Sleep(10 * 1000) Log("OK") End Sub Very important tutorial: Upvote 0
Better to use Sleep directly: Code: Copy Sub Test Log("Wait") Sleep(10 * 1000) Log("OK") End Sub Very important tutorial: