After following the various steps proposed in the manual (Designing user interface and handling events (press, update) within the state) I wanted to play a bit to get familiar with the engine and the Editor.
A nice thing came out of it (very simple but which can be useful for beginners like me) so I share it for those who want to take a look at it.
I modified the code to get some different behaviors: the plane no longer falls, you can always move it with the cursor keys but I made some changes on its movement with the mouse.
The plane goes straight to the click point instead of making an angle like in the Dragon demo. To get it I change the speed on the two x and y axes.
The plane rotates on its axis taking the same direction as the target.
At both departure and arrival the plane rotates slowly to take the direction of flight.
I have introduced the double click which doubles the flight speed.
I uploaded the code to pastebin. It is only needed to duplicate LabelFps and rename it to LabelRot (it will show the rotation of the plane in radians).
UPDATE: I changed the double click management code. If you have downloaded the first version replace it with this one,
You can see a very short video
I have two questions:
To manage the double click I wanted to use the CGE Timer but I did not understand if once started it is always active. I haven’t found a function to stop it. So I just used CastleGetTickCount64. But in any case I found it difficult to prevent the action from starting on the first click before intercepting the second click and then manage everything as a double click. Any suggestions?
This brings me to the second question. Why does CGE not provide for a double click? Is it a little requested function or maybe it is not easily portable to systems other than Windows?
Adventure games make great use of this feature (run, teleporting, fast switching from one scene to another) , it would be really appreciated if it were available directly.