BGE PyAPI support for subclassing any BGE game type from python, scripters define extra functions on gameObjects.
Adding a UI to set the type on startup can be added easily. # ---- class myPlayer(GameTypes.KX_GameObject): def die(self): # ... do stuff ... self.endObject() # make an instance player = myPlayer(gameOb) # gameOb is made invalid now. player.die() # ---- One limitation (which could also be an advantage), is making the subclass instance will return that subclass everywhere, you cant have 2 different subclasses of the same BGE data at once.
This commit is contained in:
@@ -307,6 +307,7 @@ void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_I
|
||||
controller->Activate(m_triggeredControllerSet);
|
||||
// so that the controller knows which sensor has activited it
|
||||
// only needed for python controller
|
||||
// Note that this is safe even if the controller is subclassed.
|
||||
if (controller->GetType() == &SCA_PythonController::Type)
|
||||
{
|
||||
SCA_PythonController* pythonController = (SCA_PythonController*)controller;
|
||||
|
Reference in New Issue
Block a user