Servaas Member Licensed User Mar 12, 2017 #1 Hello all, trying my hands on a little line drawing game, and I have it working but now i'm trying to see if X is within the bounds of a button I have placed in Designer. Code: Copy If x > Button1.Top Then If x > Button1.Left Then If x < Button1.Top + 20 Then If x < Button1.Left + 60 Then Button1.Visible = False End If End If End If End If This does not work apparently. I guess I can see why (I think) but I'm unsure how to correct it. The line is drawn from the top of the screen by the way.
Hello all, trying my hands on a little line drawing game, and I have it working but now i'm trying to see if X is within the bounds of a button I have placed in Designer. Code: Copy If x > Button1.Top Then If x > Button1.Left Then If x < Button1.Top + 20 Then If x < Button1.Left + 60 Then Button1.Visible = False End If End If End If End If This does not work apparently. I guess I can see why (I think) but I'm unsure how to correct it. The line is drawn from the top of the screen by the way.
Servaas Member Licensed User Mar 12, 2017 #2 This seems to solve it... i'm very sorry if it looks like i'm spamming this board but I am very much starting up again in basic so little rusty. Code: Copy If NeedlePointx > Button1.Top Then If NeedlePointx > Button1.Left Then If NeedlePointx > Button1.Left + 60 Then If NeedlePointx < Button1.Top + 20 Then Button1.Visible = False End If End If End If End If Upvote 0
This seems to solve it... i'm very sorry if it looks like i'm spamming this board but I am very much starting up again in basic so little rusty. Code: Copy If NeedlePointx > Button1.Top Then If NeedlePointx > Button1.Left Then If NeedlePointx > Button1.Left + 60 Then If NeedlePointx < Button1.Top + 20 Then Button1.Visible = False End If End If End If End If
Erel B4X founder Staff member Licensed User Longtime User Mar 13, 2017 #3 It should be 60dip and 20dip. Upvote 0
klaus Expert Licensed User Longtime User Mar 13, 2017 #4 I would suggest you this code: Code: Copy If NeedlePointx > Button1.Top Then If NeedlePointx > Button1.Left Then If NeedlePointx < Button1.Left + Button1.Height Then If NeedlePointx < Button1.Top + Button1.Width Then Button1.Visible = False End If End If End If End If And be careful: If NeedlePointx < Button1.Left + Button1.Height Then < instad of >! Upvote 0
I would suggest you this code: Code: Copy If NeedlePointx > Button1.Top Then If NeedlePointx > Button1.Left Then If NeedlePointx < Button1.Left + Button1.Height Then If NeedlePointx < Button1.Top + Button1.Width Then Button1.Visible = False End If End If End If End If And be careful: If NeedlePointx < Button1.Left + Button1.Height Then < instad of >!