Comiling error: Identifier not found "Application"

I’ve spend the last couple weeks familiarizing myself with the specifics of Pascal, and now I’m taking another shot at the tutorials in the manual. From this page:
https://castle-engine.io/viewport_and_scenes_from_code
In section 10, the tutorial says to enter the code:

CarTransforms[I] := TCastleTransform.Create(Application);

I have finished to the end of the section, and am trying to compile and run the changes. “Application” used here is giving me an identifier not found error.

Here is the code copied out of my script:

CarTransforms[I] := TCastleTransform.Create(Application);

I’m not seeing anything wrong in the syntax or spelling. Is this something I am supposed to declare, such as you would for a variable? How can I fix this?
And, this is in the body of the TStateMain.Start procedure.

You need to add CastleWindow to your project uses section. See here Castle Game Engine: CastleWindow

EDIT: And if this happens in TStateMain.Start then doing TCastleTransform.Create(FreeAtStop); is a better way to go. As this way they will be properly freed when the state frees or stops, won’t wait until Application exits, which sometimes can create a lot of wasted memory if you restart the same state over and over again many times.

1 Like

Thank you for explaining! I just realized this is the same section where I bumped into problems before. I’m glad to finally move on from it.

Thanks also for the tip on FreeAtStop. I will remember that for the future.

1 Like