Image Collision (Part 2)
Posted on 1999-07-23
The answer to my Question Q.10185289 Image Collision works.
I can check for collision with other Controls now before moving another control.
But now there is another problem.
The code is:
//Dummy is a TRect
//imgMain is the control I'm going to move.
For i := 0 to Form1.ControlCount - 1 do
If IntersectRect(Dummy, imgMain.BoundsRect, Form1.Controls[i].BoundsRect) = False then
imgMain.Left := imgMain.Left + 5; //No collision, so move it!
The problem is:
Let's say there are 5 controls on the form.
When I use the above code, the Control I want to move will move 5 times the amount I want it to move!
The For - Loop will be implemented on the "Move Control Code"!
That's not what I want!
Is there a way I can move the Control by 5, no matter how many controls the form already has?