Sign in to follow this  
robert83

unDelphiX 1.0.9.0 2 sprite animation simultaneously

Recommended Posts

Hello Everyone,

I've just started playing with unDelphiX in Delphi, and I like it very much, I'm stuck though, I've created a nice little background on which I wish to animate two different lights, I've created them picture by picture... one by one they work fine, but If I animate them both at once, the second sprite also goes trough the pictures of the first sprite, makes it look really bad. The code :

These two are what change the pictures

procedure TInstPower.ChangeFrame;
begin
if InfoCounter mod 6 = 0 then
begin
if CurrentFrame < startFrame+MaxFrame-1 then
inc(CurrentFrame)
else
CurrentFrame:= StartFrame;
end;


image := Form1.DXPowerAni.items.items[CurrentFrame];

end;


procedure TInstLight.ChangeFrame;
begin
if InfoCounter mod 6 = 0 then
begin
if CurrentFrame < startFrame+MaxFrame-1 then
inc(CurrentFrame)
else
CurrentFrame:= StartFrame;
end;


image := Form1.DXLight.items.items[CurrentFrame];

end;

Here I initialize once both :

InstPower := TInstPower.Create(Form1.DXSpriteEngine3.Engine);
With InstPower do
begin
Image := Form1.DXPowerAni.Items.items[0];
X := 520;
Y := 415;
Z := 10;
Width := Image.Width;
Height := Image.Height;
startFrame := 0;
CurrentFrame := startFrame;
maxFrame := 11;
end;

InstLight := TInstLight.Create(Form1.DXSpriteEngine4.Engine);
With InstLight do
begin
Image := Form1.DXLight.Items.items[0];
X := 25;
Y := 390;
Z := 10;
Width := Image.Width;
Height := Image.Height;
startFrame := 0;
CurrentFrame := startFrame;
maxFrame := 17;
end;

DxTimer runs this

Form1.DXDraw1.surface.Draw(0,0,InstructionImage.clientrect,InstructionImage,false);

Form1.DXSpriteEngine3.Move(0);
Form1.DXSpriteEngine3.Draw;
Form1.DXSpriteEngine3.Dead;

Form1.DXSpriteEngine4.Move(0);
Form1.DXSpriteEngine4.Draw;
Form1.DXSpriteEngine4.Dead;

InstPower.image := Form1.DXPowerAni.items.items[InstPower.CurrentFrame];
InstPower.ChangeFrame;

InstLight.image := Form1.DXLight.items.items[InstLight.CurrentFrame];
InstLight.ChangeFrame;


My problem is :

InstLight for some strange reason loops both DxPowerAni and DxLight Images … and I cannot figure out how to solve this. Basicaly I want to animate 2 or more stuff on the screen.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this