How do I pass a function as a parameter
I have a class called RigidBody and it has an update function. And in there you shift the horizontal axis and a function is called to handle and check horizontal collisions and the same for the vertical axis. Now each entity that has a RigidBody component has a custom handleHorizontalCollisions() and handleVerticalCollisions() which I will need to pass in. How do I pass functions? Here is what I am trying to do: By the way “dt” stands for delta time. My game is not frame capped. And “Velocity” is a member of RigidBody. public void update(float dt, Vector position, function handleHorizontalCollisions, function handleVerticalCollisions) { position.x += velocity.x * dt; handleHorizontalCollisions(); position.y += velocity.y * dt; handleVerticalCollisions(); }