PDA

View Full Version : delphix no animation



mitch
08-04-2003, 12:24 PM
i wanna make an animation
so used this code
but it doesn't work he only plays frame 1 so no animation what's wrong
can some one help

mitch

heli := Tback.Create(DXSpriteEngine1.Engine);
heli.Image := Form1.DXImageList1.Items.Find('Pacman');
heli.X := 10;
heli.Y := 10;
heli.Width := 28;
heli.Height := heli.Image.Height;
heli.AnimStart := 0;
heli.AnimCount := 2;
heli.AnimLooped := True;
heli.AnimSpeed := 50/1000;

Traveler
09-04-2003, 08:35 AM
I heard there are some bugs with animating sprites in delphix. I've never used that way of animation myself though. I'm using this in my tutorials


TPlayer = class(TImageSprite)
protected
startFrame : byte;
CurrentFrame : byte;
maxFrame : byte;
procedure ChangeFrame;
end;
(....)
var player : TPlayer;
(....)
procedure TPlayer.ChangeFrame;
begin
if GameCounter mod 4 = 0 then //inc gamecounter in ontimer event
begin
if CurrentFrame < startFrame+MaxFrame-1 then
inc(CurrentFrame)
else
CurrentFrame:= StartFrame;
end;

image := Form1.DXImagelist1.items.items[CurrentFrame];
end;

(....)
player := TPlayer.Create(Form1.DXSpriteEngine1.Engine);
With player do
begin
Image := Form1.DXImageList1.Items.items[19];
X := (form1.width - 15) div 2;
Y := form1.Height - 50;
Z := 10;
Width := Image.Width;
Height := Image.Height;
startFrame := 19;
CurrentFrame := startFrame;
maxFrame := 10;
end;



Have a look at my the tutorials on my website for more info about this...[/pascal]

Useless Hacker
09-04-2003, 11:25 AM
Make sure you have set the PatternWidth and PatternHeight properties of the PictureCollectionItem ('Pacman') are set to the correct size. Then set the Width and Height of the sprite to the Width and Height of the image.
heli.Width := heli.Image.Width;
heli.Height := heli.Image.Height;

fitzbean
09-04-2003, 04:16 PM
The first way is a bad way to animate - come collision detection time, it fails miserably. I'd use the Traveler's way.