fixed #1364:add paused state

This commit is contained in:
minggo 2012-06-26 11:02:19 +08:00
parent ec5ba08a97
commit 16310cb544
3 changed files with 15 additions and 6 deletions

View File

@ -98,6 +98,8 @@ typedef enum {
BOOL mute;
BOOL enabled_;
BOOL backgroundMusic;
// whether background music is paused
BOOL paused;
@public
BOOL systemPaused;//Used for auto resign handling
NSTimeInterval systemPauseLocation;//Used for auto resign handling
@ -111,6 +113,7 @@ typedef enum {
@property (assign) id<CDLongAudioSourceDelegate> delegate;
/* This long audio source functions as background music */
@property (readwrite, nonatomic) BOOL backgroundMusic;
@property (readonly) BOOL paused;
/** Loads the file into the audio source */
-(void) load:(NSString*) filePath;

View File

@ -39,7 +39,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
@implementation CDLongAudioSource
@synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic;
@synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic, paused;
-(id) init {
if ((self = [super init])) {
@ -47,6 +47,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
volume = 1.0f;
mute = NO;
enabled_ = YES;
paused = NO;
}
return self;
}
@ -94,6 +95,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
-(void) play {
if (enabled_) {
self->systemPaused = NO;
self->paused = NO;
[audioSourcePlayer play];
} else {
CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled");
@ -101,22 +103,22 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
}
-(void) stop {
self->paused = NO;
[audioSourcePlayer stop];
}
-(void) pause {
self->paused = YES;
[audioSourcePlayer pause];
}
-(void) rewind {
self->paused = NO;
[audioSourcePlayer setCurrentTime:0];
}
-(void) resume {
if (!self->systemPaused) {
return;
}
self->paused = NO;
[audioSourcePlayer play];
}
@ -577,6 +579,10 @@ static BOOL configured = FALSE;
return;
}
if (![self.backgroundMusic paused]) {
return;
}
[self.backgroundMusic resume];
}

View File

@ -187,7 +187,7 @@ void CCDirector::setGLDefaultValues(void)
CCAssert(m_pobOpenGLView, "opengl view should not be null");
setAlphaBlending(true);
setDepthTest(true);
setDepthTest(false);
setProjection(m_eProjection);
// set other opengl default values