WaitEvent() after PeekEvent() to get EventSource()
BlitzPlus Forums/BlitzPlus Beginners Area/WaitEvent() after PeekEvent() to get EventSource()
| ||
I call WaintEvent() after PeekEvent() gives me something, so that I can check EventSource() etc. Is there a downside doing code like this? There isn't a need for FlushEvents if I call WaitEvent() whenever PeekEvent() gives an event, right?Event = PeekEvent() If Event <> 0 Then Event = WaitEvent() ... do something about the events... |
| ||
| some people, honestly.... Here is one for you.... asd asg 356 eg 57u 5h3 57u 5736u 36u ? Any ideas? |
| ||
| uh Fox.. o_O What's so difficult about a normal typical daily boring loop? Like this:
Repeat
Delay 2
Waitevent()
If EventID()=$803 quit=true
If EventID()=$401
If EventSource()=button01
EndIf
If EventSource()=button02
EndIf
If EventSource()=button03
EndIf ; etc.
EndIf
If EventID()=$201
If EventSource()=MyCanvas
EndIf
EndIf
Until quit
Don't make things more difficult than they are.. |
| ||
| By doing as fox suggests it means that it loops regardless off whether there is an event. |
| ||
| And what if my loop is inside a timer ? |
| ||
| CS_TBL, There are a good number of reasons. The main reason being that my game logic is not based on waiting for events to occur. I also prefer to have clean code, and wrapping all the event based code within a single IF is a big plus from that viewpoint. |
| ||
| Say you have 2 windows, one working on a canvas and one with a set of gadgets. You don't want to have to press a button or do somthing everytime you want somthing to happen on the canvas. |
| ||
| Which is why I'd put that update routine inside a timer :) |
| ||
I do it like this:
Repeat
Select WaitEvent(0)
Case $803
Exit
; Other event handling goes here
End Select
; Game logic code goes here
Forever
WaitEvent() doesn't have to wait! |