![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CUObstacleFactory.h>
Public Member Functions | |
static ::std::shared_ptr< ObstacleFactory > | alloc () |
virtual ObstacleScene | createObstacle (const std::vector< std::byte > ¶ms) |
A factory for creating shared obstacles.
This class provides a standard template for an shareable creation of obstacles. These factories can be attached to the provided net physics controller so that creation of obstacles can be synchronized across devices without the need to send texture and body information.
In order for every client to be updated when a new obstacle is created, they must have a uniform way to share info about the obstacle to be created. However, syncing the texture and body data is very costly, so this class is a template for creating an obstacle and (optionally) a scene node from serialized parameters.
|
inline |
Returns a newly allocated obstacle factory.
|
inlinevirtual |
Returns a new obstacle from the serialized parameters
If you want the obstacle to be accompanied by a scene node, you must return a pair of the obstacle and the scene node. You must also call the NetEventController#enablePhysics()
method and provide it a function for linking the obstacle and scene node.
It is possible for the SceneNode in the returned part to be nullptr. In that case, the obstacle will be created without a scene node.
The actual parameters are up to your network protocol. Some typical parameters include:
params | The serialized parameters for the obstacle |