Skip to content

Commit

Permalink
Merge pull request #1079 from brianensorapps/master
Browse files Browse the repository at this point in the history
Scaffold updated to support new 4 inch retina displays
  • Loading branch information
PrimaryFeather committed Oct 8, 2012
2 parents 522b328 + ead2878 commit d57b559
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions samples/scaffold/src/AppScaffold.xcodeproj/project.pbxproj
Expand Up @@ -12,6 +12,7 @@
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
D31E5AFA160E51B300330CFB /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D31E5AF9160E51B300330CFB /* Default-568h@2x.png */; };
DE1FBDFD14F831A300E86642 /* SPResizeEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = DE1FBDFC14F831A300E86642 /* SPResizeEvent.m */; };
DE3F093811B7B9DC009D4DB0 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE3F093711B7B9DC009D4DB0 /* AVFoundation.framework */; };
DE3F093A11B7B9DC009D4DB0 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE3F093911B7B9DC009D4DB0 /* AudioToolbox.framework */; };
Expand Down Expand Up @@ -75,6 +76,7 @@
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* App-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "App-Prefix.pch"; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* App-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "App-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
D31E5AF9160E51B300330CFB /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../../../src/Default-568h@2x.png"; sourceTree = "<group>"; };
DE1FBDFB14F831A300E86642 /* SPResizeEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPResizeEvent.h; sourceTree = "<group>"; };
DE1FBDFC14F831A300E86642 /* SPResizeEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPResizeEvent.m; sourceTree = "<group>"; };
DE3F093711B7B9DC009D4DB0 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -264,6 +266,7 @@
DE71B21A14ED15EE00E37AE6 /* background@2x~ipad.jpg */,
DE4F80E514E1541400655D44 /* Default@2x.png */,
DE4F80F814E15D8A00655D44 /* Icon@2x.png */,
D31E5AF9160E51B300330CFB /* Default-568h@2x.png */,
);
path = 2x;
sourceTree = "<group>";
Expand Down Expand Up @@ -369,6 +372,7 @@
DE71B21E14ED15F500E37AE6 /* background.jpg in Resources */,
DE71B22214ED164600E37AE6 /* Default-Portrait~ipad.png in Resources */,
DE8055CB15065DED006A9426 /* Icon~ipad.png in Resources */,
D31E5AFA160E51B300330CFB /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
6 changes: 4 additions & 2 deletions samples/scaffold/src/Classes/AppDelegate.m
Expand Up @@ -26,7 +26,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// 'supportHighResolutions' enables retina display support. It will cause '@2x' textures to be
// loaded automatically.
//
// 'doubleOnPad' allows you to handle the iPad as if it were an iPhone with a retina display
// 'doubleOnPad' allows you to handle the iPad as if it were an iPhone with a 3.5 inch retina display
// and a resolution of '384x512' points (half of '768x1024'). It will load '@2x' textures on
// iPad 1 & 2. If the iPad has a retina screen, it will load '@4x' textures instead.

Expand All @@ -38,7 +38,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

BOOL isPad = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
int width = isPad ? 384 : 320;
int height = isPad ? 512 : 480;

// If the screenBounds height is equal to 568 points, the game is running on a 4 inch retina display.
int height = isPad ? 512 : screenBounds.size.height == 568 ? 568 : 480;

SPView *sparrowView = [[SPView alloc] initWithFrame:screenBounds];
sparrowView.multipleTouchEnabled = NO; // enable multitouch here if you need it.
Expand Down
15 changes: 13 additions & 2 deletions samples/scaffold/src/Classes/ViewController.m
Expand Up @@ -54,10 +54,21 @@ - (void)loadView
self.view = [[[SPOverlayView alloc] initWithFrame:screenBounds] autorelease];
}

- (NSUInteger)supportedInterfaceOrientations
{
NSArray *supportedOrientations = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];
NSUInteger returnOrientations;
if ([supportedOrientations containsObject:@"UIInterfaceOrientationPortrait"]) returnOrientations |= UIInterfaceOrientationMaskPortrait;
if ([supportedOrientations containsObject:@"UIInterfaceOrientationLandscapeLeft"]) returnOrientations |= UIInterfaceOrientationMaskLandscapeLeft;
if ([supportedOrientations containsObject:@"UIInterfaceOrientationPortraitUpsideDown"]) returnOrientations |= UIInterfaceOrientationMaskPortraitUpsideDown;
if ([supportedOrientations containsObject:@"UIInterfaceOrientationLandscapeRight"]) returnOrientations |= UIInterfaceOrientationMaskLandscapeRight;
return returnOrientations;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSArray *supportedOrientations =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];
NSArray *supportedOrientations =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];

return ((interfaceOrientation == UIInterfaceOrientationPortrait &&
[supportedOrientations containsObject:@"UIInterfaceOrientationPortrait"]) ||
Expand Down
Binary file added samples/scaffold/src/Default-568h@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d57b559

Please sign in to comment.