| Class KX_TouchSensor (2.48) |
|
|
| getHitObject |
getProperty |
| getHitObjectList |
setProperty |
|
|
|
| getFrequency |
reset |
| getInvert |
setFrequency |
| getLevel |
setInvert |
| getUseNegPulseMode |
setLevel |
| getUsePosPulseMode |
setUseNegPulseMode |
| isPositive |
setUsePosPulseMode |
| isTriggered |
---------- |
|
|
|
| getExecutePriority |
setExecutePriority |
| getOwner |
---------- |
|
|
getHitObject
getHitObject()
Returns the last object hit by the Touch sensor.
Return type: KX_GameObject
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor attached to the controller named Touch
sen = controller.getSensor("Touch")
# get last object hit by touch sensor
obj = sen.getHitObject()
# get the name
name = obj.name
getHitObjectList
getHitObjectList()
Returns a list of the objects hit by the touch sensor in the last frame.
Return type: List [ KX_GameObject ]
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor attached to the controller named Touch
sen = controller.getSensor("Touch")
# get a list of the objects hit in the last frame
objList = sen.getHitObjectList()
# get the name of first object in the list
name = objList[0].name
getProperty
getProperty()
Returns the name of the property that the touch sensor looks for.
Return type: string
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor attached to the controller named Touch
sen = controller.getSensor("Touch")
# get name of material sensor looks for
name = sen.getProperty()
setProperty
setProperty(name)
Sets the name of the property that the sensor looks for.
name:
Type:
string
Note:
For
setProperty(name) to change the property that triggers the Touch
sensor,
a property with the name you're changing to must already be listed
under Add Property of the object attached to the Touch sensor.
If it isn't, the property won't be changed.
Sample
Code
# get the controller
controller = GameLogic.getCurrentController()
# get the sensor attached to the controller named Touch
sen = controller.getSensor("Touch")
# set name of material sensor looks for
sen.setProperty("Wall")
|