Autor Beitrag
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 24.07.04 13:40 
Hallo,
ich habe ein ereignis erstellt:

ausblenden Delphi-Quelltext
1:
TColision = function(nx,ny:Integer):boolean;					


und das möchte in einer andren klasse verwenden:

steht im Privaten teiel der klasse

ausblenden Delphi-Quelltext
1:
function Collision(x,y,index:Integer):boolean;					


und die funktion:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
{
  Testet ob an den angeben position eine collisions ist oder nicht

  Autor: Michael Springwlad
  Erstellt am: 18.07.2004
  Upgedatet am: 18.07.2004
}


function TPACMan.Collision(x,y,index:Integer):boolean;
var
  i:Integer;
begin
  if index > 0 then begin
    for i:=0 to High(K.KIS) do begin
      if (K.KIS[i].x = x) and (K.KIS[i].y = y) then begin
        result:=True;
        exit;
      end
      else
        result:=False;
    end;
  end;

  if (x <= MapX-1and (y <= MapY) and (x >= 0and (y >= 0and (Map[x,y].isD = True) then
    result:=False
  else
    result:=True;
end;


die zuweisung bei Create:
ausblenden Delphi-Quelltext
1:
k.onColision:=Collision;					


das problem ist jetzt, das der compliler folgendes meint:
[Fehler] p.pas(102): Inkompatible Typen: 'Reguläre Prozedur und Methodenzeiger'

warum ???
was habe ich falschgemacht...

PS:
ich habe sowas noch nie selbst versucht zu machen, das erstmal also das ich was mit ereignisen machen wollte !!!

_________________
MFG
Michael Springwald, "kann kein englisch...."
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Sa 24.07.04 14:11 
Da fehlt noch das "of object" dahinter, das angibt, dass das ganze ein Methodenzeiger und kein Prozedurzeiger ist...
ausblenden Delphi-Quelltext
1:
TColision = function(nx,ny:Integer):boolean of object;					

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 24.07.04 14:23 
vielen dank, daran hats gelegen !!!

muss ich eigentlich immer nach einer eigenschaft oder beim ereignis ein ofobject
dahinter schreiben ?

_________________
MFG
Michael Springwald, "kann kein englisch...."
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 25.07.04 05:00 
of Object muss bei allen Methoden-Typen dahinter, die Ereignisfunktionen darstellen sollen.
Ansonsten versteh ich nicht, hinter was du bei nem Property ein Of Object setzen willst...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
mimi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 25.07.04 10:18 
ok, hast recht :D

_________________
MFG
Michael Springwald, "kann kein englisch...."