Ver Fonte

update sprite on change

Johann ELSASS há 5 anos atrás
pai
commit
74818e981e
1 ficheiros alterados com 8 adições e 3 exclusões
  1. 8 3
      bgraspriteanimation.pas

+ 8 - 3
bgraspriteanimation.pas

@@ -88,6 +88,7 @@ type
     procedure SetFSpriteRotation(const AValue: TRotationMode);
     procedure SetFStretch(const AValue: boolean);
     procedure SetFTile(const AValue: boolean);
+    procedure SpriteChange(Sender: TObject);
   protected
     { Protected declarations }
     procedure Paint; override;
@@ -241,9 +242,7 @@ begin
   if (FSprite = AValue) or (AValue = nil) then
     Exit;
 
-  FSprite := AValue;
-
-  Invalidate;
+  FSprite.Assign(AValue);
 end;
 
 procedure TBGRASpriteAnimation.SetFSpriteCount(const AValue: cardinal);
@@ -374,6 +373,11 @@ begin
     Invalidate;
 end;
 
+procedure TBGRASpriteAnimation.SpriteChange(Sender: TObject);
+begin
+  Invalidate;
+end;
+
 { Utils }
 
 function TBGRASpriteAnimation.DoCalculateDestRect(AWidth, AHeight: integer): TRect;
@@ -672,6 +676,7 @@ begin
   FProportional := True;
   FStretch := True;
   FSprite := TBitmap.Create;
+  FSprite.OnChange:=SpriteChange;
   FSpriteCount := 1;
   FSpriteFillOpacity := 255;
   FSpriteFlipMode := flNone;