Hey Guys - new issue here. Since the C# Port guy made things a bit different I can't rely of his code.
Actually it's not a syntax issue more a semantic one.
struct AircraftMover
{
AircraftMover(float vx, float vy)
: velocity(vx, vy)
{
}
void operator() (SceneNode& node, sf::Time) const
{
Aircraft& aircraft = static_cast<Aircraft&>(node);
aircraft.accelerate(velocity);
}
sf::Vector2f velocity;
};
That's the code in the book. Please focus on the fact that the method
operator() here receives these usual parameters of type
SceneNode and
Time.
After that there is a definition for
HandlePlayerRealtimeInput:
void Player::handleRealtimeInput(CommandQueue& commands)
{
const float playerSpeed = 30.f;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
Command moveLeft;
moveLeft.category = Category::PlayerAircraft;
moveLeft.action = derivedAction<Aircraft>(
AircraftMover(-playerSpeed, 0.f));
commands.push(moveLeft);
}
}
Here you can see that the
Commad object
moveLeft within its function pointer
action (
if it isnt a function pointer nvm - thats not the point here I think) receives
AircraftMover() (
which is the constructor as I can see that far)
Now...since the
operator() method of
AircraftMover isn't called explicit I'm sure that it's called within the
AircraftMover Constructor. (
Be sure that I'm not hip with C++ therefore I have to estimate what happens and relate it to C# designs).
That are all things which I could handle with C#.
The big BUT here is...
How can the
operator() method of
AircraftMover receive any references to
SceneNode and
Time ? Since the
AircraftMover Constructor isn't receiving any of these (
only float_x and float_y parameters). Neither there is any inheritance to something which contains a
SceneNode nor
Time.
I really browsed the C# Port and ascending pages of the Tutorial Book - but couldn't find any explaination what is happening there.
Besides that problem I really miss the definition of the
HandleEvent Method of the
Player class. Only the
HandlePlayerRealtimeInput receives a defintion with the implemenation of the
Command class etc. as you can see above. Would be nice to have some clear code on that method aswell (
Again - the C# Port has another approach on that problem - therefore I can't take it for this here)
I hope I won't waste your time on this - but I'm very motivated to complete this tutorial with all dents and stones which may occur. Since I'm a beginner coder I need your help often. But HEY - I learned a lot here and with the book - so you can be sure my question activity will lower and answer posts will raise
greets Charlie