Jump to content
  • Advertisement
Sign in to follow this  
robert83

unDelphiX 1.0.9.0 2 sprite animation simultaneously

This topic is 2840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!