unit GameViewMain;
interface
uses Classes,
CastleVectors, CastleComponentSerialize,
CastleUIControls, CastleControls, CastleKeysMouse,
CastleThirdPersonNavigation;
type
TMyThirdPersonNavigation = class(TCastleThirdPersonNavigation)
ExampleLegScene = class(TCastleScene)
ExampleTorsoScene = class(TCastleScene)
TMyThirdPersonNavigation.AvatarHierarchy := MyTransform;
protected
procedure SetAnimation(const AnimationNames: array of String); override;
end;
{ Main view, where most of the application logic takes place. }
TViewMain = class(TCastleView)
published
{ Components designed using CGE editor.
These fields will be automatically initialized at Start. }
LabelFps: TCastleLabel;
public
constructor Create(AOwner: TComponent); override;
procedure Start; override;
procedure Update(const SecondsPassed: Single; var HandleInput: Boolean); override;
function Press(const Event: TInputPressRelease): Boolean; override;
end;
var
ViewMain: TViewMain;
implementation
uses SysUtils;
{ TMyThirdPersonNavigation ---------------------------------------------------- }
procedure TMyThirdPersonNavigation.SetAnimation(const AnimationNames: array of String);
begin
if AnimationNames[0] = 'idle' then
begin
ExampleLegsScene.PlayAnimation('idle', true);
ExampleTorsoScene.PlayAnimation('idle', true);
end else
if AnimationNames[0] = 'walk' then
begin
ExampleLegsScene.PlayAnimation('walk', true);
ExampleTorsoScene.PlayAnimation('walk', true);
end;
end;
{ TViewMain ----------------------------------------------------------------- }
constructor TViewMain.Create(AOwner: TComponent);
begin
inherited;
DesignUrl := 'castle-data:/gameviewmain.castle-user-interface';
end;
procedure TViewMain.Start;
var
MyNavigation: TMyThirdPersonNavigation;
begin
inherited;
MyNavigation := TMyThirdPersonNavigation.Create(FreeAtStop);
// TODO: Remember to assign MyNavigation properties
end;
procedure TViewMain.Update(const SecondsPassed: Single; var HandleInput: Boolean);
begin
inherited;
{ This virtual method is executed every frame (many times per second). }
Assert(LabelFps <> nil, 'If you remove LabelFps from the design, remember to remove also the assignment "LabelFps.Caption := ..." from code');
LabelFps.Caption := 'FPS: ' + Container.Fps.ToString;
end;
function TViewMain.Press(const Event: TInputPressRelease): Boolean;
begin
Result := inherited;
if Result then Exit; // allow the ancestor to handle keys
{ This virtual method is executed when user presses
a key, a mouse button, or touches a touch-screen.
Note that each UI control has also events like OnPress and OnClick.
These events can be used to handle the "press", if it should do something
specific when used in that UI control.
The TViewMain.Press method should be used to handle keys
not handled in children controls.
}
// Use this to handle keys:
{
if Event.IsKey(keyXxx) then
begin
// DoSomething;
Exit(true); // key was handled
end;
}
end;
end.
Here is the code with your additions. Unfortunately, I get exactly this error on line 12 position 19. Note again, that it doesn’t make any logical sense following the rules of Pascal syntax because I declared it exactly the way you should declare it, with no semicolons, yet it says there is an equal sign in place of a semicolon.
On top of this, it should have given me two errors and not only one, because I used the same syntax on both lines next to each other vertically speaking in order to intilalize/declare the scenes.
IE, it should have given me the same error for line 13 as well as 12, because I used the same exact syntax to declare the two scenes.
Even weirder/illogical still, it’s bugging me about there not being a semicolon in a place where semicolons never actually go, if you read the documentation on how TCastleScene instances are declared, you are supposed to put the equals sign in the middle.
Do you know if I am just missing something again?