| Home | Trees | Index | Help |
|
|---|
| Module GameLogic |
|
GameKeys
Rasterizer
All the other modules are accessible through the methods in GameLogic.
See WhatsNew for updates, changes and new
functionality in the Game Engine Python API.
# To get a controller:
import GameLogic
co = GameLogic.getCurrentController()
# To get the game object associated with this controller:
obj = co.getOwner()
KX_GameObject and KX_Camera or
KX_Light
methods are available depending on the type of object:
# To get a sensor linked to this controller.
# "sensorname" is the name of the sensor as defined in the Blender interface.
# +---------------------+ +--------+
# | Sensor "sensorname" +--+ Python +
# +---------------------+ +--------+
sens = co.getSensor("sensorname")
# To get a list of all sensors:
sensors = co.getSensors()
See the sensor's reference for available methods:
KX_NetworkMessageSensor
KX_RaySensor
KX_MouseFocusSensor
KX_NearSensor
KX_RadarSensor
KX_TouchSensor
SCA_KeyboardSensor
SCA_MouseSensor
SCA_PropertySensor
SCA_RandomSensor
# To get an actuator attached to the controller:
# +--------+ +-------------------------+
# + Python +--+ Actuator "actuatorname" |
# +--------+ +-------------------------+
actuator = co.getActuator("actuatorname")
# Activate an actuator
GameLogic.addActiveActuator(actuator, True)
See the actuator's reference for available methods:
BL_ActionActuator
KX_CameraActuator
KX_CDActuator
KX_ConstraintActuator
KX_GameActuator
KX_IpoActuator
KX_NetworkMessageActuator
KX_ObjectActuator
KX_SCA_AddObjectActuator
KX_SCA_EndObjectActuator
KX_SCA_ReplaceMeshActuator
KX_SceneActuator
KX_SoundActuator
KX_TrackToActuator
KX_VisibilityActuator
SCA_PropertyActuator
SCA_RandomActuator
KX_Scene:
# Get the current scene
scene = GameLogic.getCurrentScene()
# Get the current camera
cam = scene.active_camera
Matricies as used by the game engine are row major:
matrix[row][col] = blah
KX_Camera has some examples using
matricies.
| Function Summary | |
|---|---|
Activates the given actuator. | |
SCA_PythonController
|
Gets the Python controller associated with this Python script. |
KX_Scene
|
Gets the current Scene. |
Returns a random floating point value in the range [0...1) | |
| list [float], len(getSpectrum()) == 512 |
Returns a 512 point list from the sound card. |
Sets the world gravity. | |
Stops the sound driver using DSP effects. | |
| Function Details |
|---|
addActiveActuator(actuator, activate)Activates the given actuator.
|
getCurrentController()Gets the Python controller associated with this Python script.
|
getCurrentScene()Gets the current Scene.
|
getRandomFloat()Returns a random floating point value in the range [0...1) |
getSpectrum()Returns a 512 point list from the sound card. This only works if the fmod sound driver is being used.
|
setGravity(gravity)Sets the world gravity.
|
stopDSP()Stops the sound driver using DSP effects. Only the fmod sound driver supports this. DSP can be computationally expensive. |
| Variable Details |
|---|
KX_TRUETrue value used by some modules. |
KX_FALSEFalse value used by some modules. |
KX_PROPSENSOR_EQUALActivate when the property is equal to the sensor value. |
KX_PROPSENSOR_NOTEQUALActivate when the property is not equal to the sensor value. |
KX_PROPSENSOR_INTERVALActivate when the property is between the specified limits. |
KX_PROPSENSOR_CHANGEDActivate when the property changes |
KX_PROPSENSOR_EXPRESSIONActivate when the expression matches |
KX_CONSTRAINTACT_LOCXSeeKX_ConstraintActuator
|
KX_CONSTRAINTACT_LOCYSeeKX_ConstraintActuator
|
KX_CONSTRAINTACT_LOCZSeeKX_ConstraintActuator
|
KX_CONSTRAINTACT_ROTXSeeKX_ConstraintActuator
|
KX_CONSTRAINTACT_ROTYSeeKX_ConstraintActuator
|
KX_CONSTRAINTACT_ROTZSeeKX_ConstraintActuator
|
KX_IPOACT_PLAYSeeKX_IpoActuator
|
KX_IPOACT_PINGPONGSeeKX_IpoActuator
|
KX_IPOACT_FLIPPERSeeKX_IpoActuator
|
KX_IPOACT_LOOPSTOPSeeKX_IpoActuator
|
KX_IPOACT_LOOPENDSeeKX_IpoActuator
|
KX_RANDOMACT_BOOL_CONSTSeeSCA_RandomActuator
|
KX_RANDOMACT_BOOL_UNIFORMSeeSCA_RandomActuator
|
KX_RANDOMACT_BOOL_BERNOUILLISeeSCA_RandomActuator
|
KX_RANDOMACT_INT_CONSTSeeSCA_RandomActuator
|
KX_RANDOMACT_INT_UNIFORMSeeSCA_RandomActuator
|
KX_RANDOMACT_INT_POISSONSeeSCA_RandomActuator
|
KX_RANDOMACT_FLOAT_CONSTSeeSCA_RandomActuator
|
KX_RANDOMACT_FLOAT_UNIFORMSeeSCA_RandomActuator
|
KX_RANDOMACT_FLOAT_NORMALSeeSCA_RandomActuator
|
KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIALSeeSCA_RandomActuator
|
KX_ACTIONACT_PLAYSeeBL_ActionActuator
|
KX_ACTIONACT_FLIPPERSeeBL_ActionActuator
|
KX_ACTIONACT_LOOPSTOPSeeBL_ActionActuator
|
KX_ACTIONACT_LOOPENDSeeBL_ActionActuator
|
KX_ACTIONACT_PROPERTYSeeBL_ActionActuator
|
KX_SOUNDACT_PLAYSTOPSeeKX_SoundActuator
|
KX_SOUNDACT_PLAYENDSeeKX_SoundActuator
|
KX_SOUNDACT_LOOPENDSeeKX_SoundActuator
|
KX_SOUNDACT_LOOPBIDIRECTIONALSeeKX_SoundActuator
|
KX_SOUNDACT_LOOPBIDIRECTIONAL_STOPSeeKX_SoundActuator
|
KKX_SOUNDACT_LOOPSTOPSeeKX_SoundActuator
|
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Fri Aug 27 21:08:03 2004 | http://epydoc.sf.net |