|
Hello!
I'm using a Sensor listener to read a sensor in a behavior class.
This is the code:
public class Angestossen implements Behavior, SensorListener
{
public void stateChanged(Sensor touchsensor, int oldValue, int
newValue)
{
if (touchsensor.readBooleanValue() ==true)
{ angestossen=true;
Sound.systemSound(false, 2);
}
}
It seems to work fine.
If I include code to play a sound if the touchsensor releases, then the
second sound is played steadily, if the sensor is not pressed and the
value was not changed:
if (touchsensor.readBooleanValue() ==true)
{ angestossen=true;
Sound.systemSound(false, 2);
}
else
Sound.systemSound(false, 0);
This is unexpected. What I expected was, that the second sound is played
only once, when the sensor is released, because the stateChanged()
should be only executed, if the sensor state really changed. Is there
anything wrong in my code or does the sensor listener not work correct?
Regards
Michael
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|