Navigation Menu

Skip to content

Commit

Permalink
CCVideoPlayerTest: handle orientation change
Browse files Browse the repository at this point in the history
  • Loading branch information
psineur committed Jun 11, 2011
1 parent 2c2f9d1 commit 74d3c9f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Tests/CCVideoPlayerTest/CCVideoTestLayer.m
Expand Up @@ -76,6 +76,14 @@ - (void) movieStartsPlaying
[[CCDirector sharedDirector] stopAnimation];
}

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
// Updates orientation of CCVideoPlayer. Called from SharedSources/RootViewController.m
- (void) updateOrientationWithOrientation: (UIDeviceOrientation) newOrientation
{
[CCVideoPlayer updateOrientationWithOrientation:newOrientation ];
}
#endif

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
Expand Down
17 changes: 17 additions & 0 deletions Tests/SharedSources/RootViewController.m
Expand Up @@ -34,6 +34,13 @@
#import "RootViewController.h"
#import "GameConfig.h"

@protocol UpdateOrientation <NSObject>

- (void) updateOrientationWithOrientation: (UIDeviceOrientation) orientation;

@end


@implementation RootViewController

/*
Expand Down Expand Up @@ -143,6 +150,16 @@ -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrien
rect.size.height *= contentScaleFactor;
}
glView.frame = rect;


// Let current test know that orientation was changed.
CCScene *curScene = [[CCDirector sharedDirector] runningScene];
if (curScene)
{
for (id <UpdateOrientation> child in curScene.children)
if ([child respondsToSelector:@selector(updateOrientationWithOrientation:)])
[child updateOrientationWithOrientation:toInterfaceOrientation ];
}
}
#endif // GAME_AUTOROTATION == kGameAutorotationUIViewController

Expand Down

0 comments on commit 74d3c9f

Please sign in to comment.