No collision no message


Small problem:

I have outcommented the Label1.Caption because when there is no collision between mousescene and player the caption should be empty. But it remains empty when in the next line there is collision between mousescene and NPC.
So how can I get a blank caption only when there is no collision at all?

if PlayerMouse.Scene.BoundingBox.RectangleXY.Collides(StatePlay.PlayerScene.BoundingBox.RectangleXY.Grow(-30, -20)) then Label1.Caption := Player.Personalia.FirstName; // else Label1.Caption := ' ';
  for I := 1 to Location.NPCNR do
 if PlayerMouse.Scene.BoundingBox.RectangleXY.Collides(StatePlay.NPCScene[I].BoundingBox.RectangleXY.Grow(-30, -20)) then Label1.Caption := NPC[I].Personalia.FirstName; // else Label1.Caption := ' ';

Just set Label1.Caption := ''; right before this code? This way if nothing else sets Label1.Caption, it will remain empty.

There’s a more involved solution, to keep track of “whether we need to empty caption by a Boolean variable” but it’s probably more than you need in this case.

Yes, that did it. Thanks!