add setPlayRate()
This commit is contained in:
parent
725986da59
commit
39adcebb3d
|
|
@ -170,6 +170,24 @@ class Interval(DirectObject):
|
|||
def isPlaying(self):
|
||||
return taskMgr.hasTaskNamed(self.getName() + '-play')
|
||||
|
||||
def getPlayRate(self):
|
||||
""" Returns the play rate as set by the last call to start(),
|
||||
loop(), or setPlayRate(). """
|
||||
return self.__playRate
|
||||
|
||||
def setPlayRate(self, playRate):
|
||||
""" Changes the play rate of the interval. If the interval is
|
||||
already started, this changes its speed on-the-fly. Note that
|
||||
since playRate is a parameter to start() and loop(), the next
|
||||
call to start() or loop() will reset this parameter. """
|
||||
|
||||
if self.isPlaying():
|
||||
self.pause()
|
||||
self.__playRate = playRate
|
||||
self.resume()
|
||||
else:
|
||||
self.__playRate = playRate
|
||||
|
||||
def setDoneEvent(self, event):
|
||||
self.doneEvent = event
|
||||
|
||||
|
|
|
|||
|
|
@ -288,6 +288,37 @@ is_playing() const {
|
|||
return (index >= 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::get_play_rate
|
||||
// Access: Published
|
||||
// Description: Returns the play rate as set by the last call to
|
||||
// start(), loop(), or set_play_rate().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
double CInterval::
|
||||
get_play_rate() const {
|
||||
return _play_rate;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::set_play_rate
|
||||
// Access: Published
|
||||
// Description: Changes the play rate of the interval. If the
|
||||
// interval is already started, this changes its speed
|
||||
// on-the-fly. Note that since play_rate is a parameter
|
||||
// to start() and loop(), the next call to start() or
|
||||
// loop() will reset this parameter.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
set_play_rate(double play_rate) {
|
||||
if (is_playing()) {
|
||||
pause();
|
||||
_play_rate = play_rate;
|
||||
resume();
|
||||
} else {
|
||||
_play_rate = play_rate;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CInterval::priv_do_event
|
||||
// Access: Published
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ PUBLISHED:
|
|||
void clear_to_initial();
|
||||
bool is_playing() const;
|
||||
|
||||
double get_play_rate() const;
|
||||
void set_play_rate(double play_rate);
|
||||
|
||||
// These functions control the actual playback of the interval.
|
||||
// Don't call them directly; they're intended to be called from a
|
||||
// supervising object, e.g. the Python start() .. finish()
|
||||
|
|
|
|||
Loading…
Reference in New Issue