I use:
MyAnim.Load(MyStarlingXml+'#fps:30,anim-naming:strict-underscore')
(or even URL
) to open a spritesheet.
Any parameter I insert after #fps
does not change the number of frames which always remains the default (8).
Maybe I’m wrong but I don’t think it’s needed to disable DefaultSpriteSheetFramesPerSecond
.
Only TimePlayingSpeed
works with which I can change the speed of the animation but always starting from 8 frames / sec.
I tried to launch the animation both with PlayAnimation
and by setting AutoAnimation
and AutoAnimationLoop
but nothing changes.
I use TCastleControlBase with Lazarus. Could this be the problem?
So I tried the code posted by @Carring
using my sprite sheets and the #fps parameter works fine. But it uses CastleWindow.
I created a new application by removing all unnecessary code:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
CastleControl, CastleScene, CastleViewport, CastleTransform, CastleVectors;
type
TPlayer = class
constructor Create;
destructor Destroy; override;
end;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
CastleControlBase1: TCastleControlBase;
procedure Button1Click(Sender: TObject);
private
public
MainViewport: TCastleViewport;
PlayerScene: TCastleTransform;
end;
var
Form1: TForm1;
player: TPlayer;
PlayerAnimations: TCastleScene;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
MainViewport := TCastleViewport.Create(Application);
MainViewport.AutoCamera := true;
MainViewport.FullSize := true;
MainViewport.Setup2D;
MainViewport.Camera.Orthographic.Width := castlecontrolbase1.ClientWidth;
MainViewport.Camera.Orthographic.Height := castlecontrolbase1.ClientHeight;
MainViewport.Camera.Orthographic.Origin := Vector2(0.5, 0.5);
CastleControlBase1.Container.Controls.InsertFront(MainViewport);
Player:= TPlayer.Create;
PlayerScene := TCastleTransform.Create(Application);
PlayerAnimations := TCastleScene.Create(Application);
PlayerAnimations.URL:=[MyStarlingXml]+'#fps:25,anim-naming:strict-underscore';
//PlayerAnimations.Load([MyStarlingXml]+'#fps:3,anim-naming:strict-underscore');
PlayerAnimations.ProcessEvents := true;
PlayerScene.Add(PlayerAnimations);
PlayerAnimations.Exists:=true;
PlayerScene.Translation := Vector3(0, 0, 1);
MainViewport.Items.Add(PlayerScene);
PlayerAnimations.PlayAnimation('Down', true);
//PlayerAnimations.AutoAnimation:='Down';
//PlayerAnimations.AutoAnimationLoop:=true;
end;
constructor TPlayer.Create;
begin
inherited;
end;
destructor TPlayer.Destroy;
begin
inherited;
end;
end.
The frame number of the animation never changes.
Some idea?