From 9a7ea9664e27679935adaea3093630d7a6a30b5d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 29 Jun 2009 12:06:46 +0000 Subject: 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. --- source/gameengine/Ketsji/KX_NearSensor.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source/gameengine/Ketsji/KX_NearSensor.cpp') diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 64f6b9306a0..1a211a64b35 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -270,16 +270,15 @@ PyTypeObject KX_NearSensor::Type = { 0, 0, py_base_repr, - 0,0,0,0,0,0, - NULL, //py_base_getattro, - NULL, //py_base_setattro, - 0, + 0,0,0,0,0,0,0,0,0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 0,0,0,0,0,0,0, Methods, 0, 0, - &KX_TouchSensor::Type + &KX_TouchSensor::Type, + 0,0,0,0,0,0, + py_base_new }; PyMethodDef KX_NearSensor::Methods[] = { -- cgit v1.2.3