组装23 人物动画的简单实现 加入声音

unit SoundUnit;

interface
 uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DXDraws, DirectX, DXClass,  ExtCtrls,
   DXSounds;
 var
   CurVolume : Integer;
   g_DXSound: TDXSound;
   g_Sound : TSoundEngine;

 const
   SoundFileName = 'E:\mirClient\Mir1.76\Wav\M7-1.wav';
procedure PlaySound(idx: integer);


implementation

uses
  Movies;

  procedure PlaySound(idx: integer);
  begin
    if g_Sound <> nil then
    begin
     g_Sound.EffectFile(SoundFileName,False,False);
    end;

  end;

end.

 

g_DXSound :=  TDXSound.Create(Self);
 g_DXSound.Initialize;
 if g_DXSound.Initialized then
 begin
   g_Sound := TSoundEngine.Create(g_DXSound.DSound);
 end
 else
 begin
   g_Sound := nil;
 end;
procedure TActor.RunActSound(frame: Integer);
begin
  if m_boRunSound then
  begin
    case m_nCurrentAction of
      ActHit,ActHeavyHit:
        if frame = 2 then
        begin
           PlaySound(m_nWeaponSound);
           m_boRunSound := False;
        end;
    end;
  end;
end;

procedure TActor.RunSound;
begin
  m_boRunSound := True;
  
end;

procedure TActor.SetSound;
begin

end;


procedure TActor.Run;
var
  prv: integer;

begin

  if (m_nCurrentAction = ActWalk) or
    (m_nCurrentAction = ActRun) or
    (m_nCurrentAction = ActRushLeft) or
    (m_nCurrentAction = ActRushRight) then
    Exit;

  RunActSound(m_nCurrentFrame - m_nStartFrame);

 

posted @ 2025-08-29 23:06  D7mir  阅读(10)  评论(0)    收藏  举报