-
Mar 14th, 2015, 02:48 PM
#1
UC Question - One UC picture on top of the other UC picture
I have two user controls each with a picture in it. How can I tell if I move one of the UC picture on top of the other UC picture?
Last edited by jmsrickland; Mar 14th, 2015 at 02:52 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Mar 14th, 2015, 06:05 PM
#2
Re: UC Question - One UC picture on top of the other UC picture
Do a simple "Pixel Collision" test on the two colliding UC, or if its your board game you could always just go with the index (2,1) of the square or their position (height,width,left,top).
For example you have 0,0 selected your mouse moves to the right and over the 0,0 width now it would have collided with 0,1 square
-
Mar 14th, 2015, 06:31 PM
#3
Re: UC Question - One UC picture on top of the other UC picture
It has nothing to do with my game so how to do pixel collision?
Wouldn't something like drag over work?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Mar 14th, 2015, 06:50 PM
#4
Re: UC Question - One UC picture on top of the other UC picture
You could add the MouseMove Event to your UC's picturebox... like this
Code:
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Now in your form when you mouse your move over the UC's PictureBox you should be able to see it's x,y... meaning you can make Pixel Collision... don't forget to use ScaleX, ScaleY if one can be in twips and the other in pixels... if not then there is no need.
form code
Code:
Private Sub UserControl12_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print X, Y
End Sub
Note: I did not make an Array of UC so it it UserControl11 and UserControl12... with an array you'd use it's index... and add Index As Integer to the event
Edit: not sure if you meant PictureBox or picture... if you mean like a .picture = (pictue) then forget the PicturBox in my example and change all the PictureBox events to be UserControl events instead
-
Mar 14th, 2015, 07:01 PM
#5
Re: UC Question - One UC picture on top of the other UC picture
That only works when the mouse pointer is over the object. If the mouse pointer is in the center of the control to move then it won't detect anything when the picture first starts to move over the object - it will only show x and y as soon as the mouse enters the object
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Mar 14th, 2015, 07:11 PM
#6
Re: UC Question - One UC picture on top of the other UC picture
Use
x + (width - x)
To find the end of the object
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|