Are you sure CurrentSprite is a valid index?
You should not do this, , but try this, it will avoid anything wrong :
Code:
function TGameObject.isColliding(Sprite: TSprite): Boolean;
begin
Result:=false; //setting result, just in case
if (not Assigned(self)) or (not Assigned(Sprite)) then Exit;
case ObjectMode of
omAnim: begin
if (CurrentAnim>0) and (CurrentAnim<=Animations.Items.Count-1) then
if Assigned(Animations.Items[CurrentAnim]) then //safety check so we won't get segfault
//setting result
Result:=Animations.Items[CurrentAnim].IsColliding(Sprite);
end;
omSprite: begin
if (CurrentSprite>0) and (CurrentSprite<=Animations.Items.Count-1) then
if Sprites.Items[CurrentSprite]<>nil then //safety check so we won't get segfault
//setting result
Result:=Sprites.Items[CurrentSprite].IsColliding(Sprite);
end;
end;
end;
Bookmarks