【Spine】Spine Runtime for Delphi移植笔记(四…

2018-06-17 18:56:47来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

////////////////////////////////////////////////////////////////////////////////
//Generic delphi runtime v3.6 for Spine animation tool                        //
//Runtime port by cjk (hzi1980@163.com)                                       //
////////////////////////////////////////////////////////////////////////////////

unit spine.classes;

interface

uses
  System.Classes, System.SysUtils, System.Generics.Collections, spine.types;

type
  THashSet<T> = class
  private
  public
    procedure Clear;
    function Add(const Item: T): Boolean;
  end;

  TExposedList<T> = class(TList<T>)
  private
    FVersion: Integer;
    procedure ClearEx(const AIndex, ALen: Integer); overload;
    procedure Shift(const AStart, ADelta: Integer);
  public
    procedure EnsureCapacity(const AMin: Integer);
    procedure ClearEx(const AClearArray: Boolean = True); overload;
    function  Resize(const ANewSize: Integer): TExposedList<T>;
    procedure RemoveAt(const AIndex: Integer);
    procedure CopyFrom(const ASource: TExposedList<T>); overload;
    procedure CopyFrom(const ASource: TExposedList<T>;
      const ASourceStart, ATargetStart, ACount: Integer); overload;
  end;

  TSpineTexture = class(TObject)

  end;

  TAtlasPage = class(TObject)
  public
    Name: AnsiString;
    Format: TPageFormat;
    MinFilter: TPageTextureFilter;
    MagFilter: TPageTextureFilter;
    WrapU: TPageTextureWrap;
    WrapV: TPageTextureWrap;
    Texture: TSpineTexture;
    Width: Integer;
    Height: Integer;
    end;

  TAtlasRegion = class(TObject)
    Page: TAtlasPage;
    Name: AnsiString;
    X: Integer;
    Y: Integer;
    Width: Integer;
    Height: Integer;
    U: Single;
    V: Single;
    U2: Single;
    V2: Single;
    OffsetX: Single;
    OffsetY: Single;
    OriginalWidth: Integer;
    OriginalHeight: Integer;
    Index: Integer;
    Rotate: Boolean;
    Splits: array of Integer;
    Pads: array of Integer;
    end;

  ITextureLoader = class abstract
    function LoadTexture(const Page: TAtlasPage; const TextureName: string): TSpineTexture; virtual; abstract;
  end;

  IUpdateable = class abstract
    procedure Update; virtual; abstract;
  end;

  IAtlas = class abstract end;
  ISkeleton = class abstract end;
  IBone = class(IUpdateable) end;
  ISlot = class abstract end;
  IEvent = class abstract end;
  IAnimation = class abstract end;
  IAnimationState = class abstract end;
  ISkin = class abstract end;

  IAttachment = class abstract
  protected
    function GetID: Integer; virtual; abstract;
    function GetName: string; virtual; abstract;
  public
    property ID: Integer read GetID;
    property Name: string read GetName;
  end;

  IConstraint = class(IUpdateable)
  protected
    function GetOrder: Integer; virtual; abstract;
  public
    property Order: Integer read GetOrder;
  end;

  ITimeline = class abstract
  protected
    function GetPropertyId: Integer; virtual; abstract;
  public
    procedure Apply(const ASkeleton: ISkeleton;
                    const ALastTime, ATime: Single;
                    const AEvents: TList<IEvent>;
                    const AAlpha: Single;
                    const APose: TMixPose;
                    const ADirection: TMixDirection); virtual; abstract;
    property PropertyId: Integer read GetPropertyId;
  end;

implementation

end.

 

类定义,I 开头的抽象类大多数只是为了定义一下,因为需要单元间交叉引用,但是又不想都是定义为TObject,写接口又没必要,只能这么写了。

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Delphi中MD5实现方法(转)

下一篇:Delphi Screen.DataModuleCount 总是返回 0!Delphi 的 Bug? Da