I need some code so that when my player1 crosses a certian point on the form then the flag will disapear. So like when when player1 crosses img1 then the flag img will disapear.
Printable View
I need some code so that when my player1 crosses a certian point on the form then the flag will disapear. So like when when player1 crosses img1 then the flag img will disapear.
Sounds like collision detection. Is it acceptable to draw a virtual box around the flag, or do you need to have even tighter resolution? If you can say that the flag should disappear when the rectangle around player1 crosses into the rectangle around the flag, then the problem becomes quite simple, since you can just check whether the boxes overlap. There are simplifications that can be made to this, too, if either the flag or the player are considerably smaller than the other (such that one might be considered a point).
ok is there code to just make it so that if player1 comes in contact with the flag then the flag will dissapear?
Assuming that 'flag' and 'player' are controls:You should read up about the Region class and the Control.Region property to get a proper understanding of this code and how to best use it.VB Code:
Dim intersection As Region = flag.Region.Clone() intersection.Intersect(player.Region) If intersection.IsEmpty() Then 'There is no intersection between the two regions so the controls are not overlapping. End If