Blender Git Commit Log

Git Commits -> Revision 9b4956a

Revision 9b4956a by Benoit Bolsee (master)
September 22, 2008, 19:54 (GMT)
BGE patch: KX_STATEx constant to allow simple state manipulation in setState()

The constants KX_STATE1 to KX_STATE30 can be used
with setState() to change the object state in a
python controller. The constants are defined in the
GameLogic module so that the full name is
GameLogic.KX_STATE1 to GameLogic.KX_STATE30 but you
can simplify this with the import statement:

from GameLogic import *
cont = getCurrentController()
ob = cont.getOwner()
ob.setState(KX_STATE2) #go to state 2

KX_STATEx constants are defined as (1<<(x-1))
Binary operators |, &, ^ and ~ can be used to combine states:

You can activate more than one state at a time with the | operator:

ob.setState(KX_STATE1|KX_STATE2) #activate state 1 and 2, stop all others

You can add a state to the current state mask with:

state = ob.getState()
ob.setState(state|KX_STATE3) #activate state 3, keep others

You can substract a state to the current state mask with the & and operator:

state = ob.getState()
ob.setState(state&~KX_STATE2) #stop state 2, keep others

You can invert a state with the ^ operator:

state = ob.getState()
ob.setState(state^KX_STATE2) #invert state 2, keep others


Commit Details:

Full Hash: 9b4956ae2213570e07475ecc544a630c44d2892c
SVN Revision: 16685
Parent Commit: eef475a
Lines Changed: +32, -0

1 Modified Path:

/source/gameengine/Ketsji/KX_PythonInit.cpp (+32, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021