When compiling, writes that the variable img is not found (it is). This is because of the code above command.
img:= timage.Create(Form4);
If you remove what is above this command, everything works. What is the problem?
Here is my code (do not be alarmed by a large number of if statements):
procedure TForm4.kaban4Click(Sender: TObject); begin timer10.Enabled:=true; k4:= image1.Top - kaban4.Top; if k4 > 0 then begin if k4>= 200 then begin kaban4.Picture.LoadFromFile('sprite\gun3.png'); fire:=3; end; end else begin k4:= kaban4.Top - image1.Top; if kaban4.Top> 200 then begin image1.Picture.LoadFromFile('sprite\gun2.png'); fire:=2; end; end; if (kaban4.Top > 150) and (kaban4.Top < 430) then fire:=1; end; img:= timage.Create(Form4); img.Parent:=Form4; img.Left:=kaban4.Left; img.Top:=kaban4.Top + 120; img.Width:=278; img.Height:=68; img.Picture.LoadFromFile('sprite\kaban\dead.png'); img.SendToBack; kaban4.Visible:=false; mm41.Enabled:=true; a:=a+1; label2.Caption:='Убито кабанов: ' +inttostr(a); end;