problem in elseif statement
Blitz3D Forums/Blitz3D Beginners Area/problem in elseif statement
| ||
In the following if else statement only the first condition is working. While not keyhit(1) If mousex()>320 and mousex()<480 and mousey()>185 and mousey()<230 and mousehit(1) then Load_func1() ElseIf mousex()>320 and mousex()<480 and mousey()>235 and mousey()<280 and mousehit(1) then Load_func2() Else Endif Why the second condition is not working ? |
| ||
That is because MouseHit() is being cleared on the If part so it will always be false on the ElseIf pat. Instead, do this If MouseHit(1) Then If MouseX()>320 And MouseX()<480 And MouseY()>185 And MouseY()<230 Then Load_func1() ElseIf MouseX()>320 And MouseX()<480 And MouseY()>235 And MouseY()<280 Then Load_func2() EndIf EndIf |
| ||
Oh yes, I have made a logical mistake. Now, the program is working fine. Thank you. |
| ||
Or even better.... store mousehit and mousedown in a variable at the top of the loop and check the variable rather than the function... |