I would like to update my non retina game to use the wide screen in the iPhone 5, is it possible to use a 568x320 sized OpenGL window?
Yes. But your graphics will not show as sharp as it could be.
I suggest you to make #2x version of all your graphics.
I have now compiled and got my game working at 568x320, all I had to do is include the Default-568h#2x file and do this in createFrameBuffer
[self setFrame:rect];
[self setBounds:rect];
[self.layer setFrame:rect];
[self.layer setBounds:rect];
Related
Today i am going to create an iphone application which is compatible with iphone4 and iphone5. Earlier i have changed iphone4 application views programetically by using below code to adjust controllers for iphone5.
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for iphone5
}
else {
// code for iphone4
}
am thinking this is difficult to track all the frames and sizes of controllers each and every time. I have created one sample app and also tried with Auto-resizing option(i have put check mark) at the starting of view and selected size Retina 4 full screen in inspector. And also selected simulator hardware-device is iphone Retina-4 inch
if i change simulator hardware-device is iphone Retina-3.5 inch then the screen is looking like
My question is without setting frames how can i achieve this problem.
Please help me.
Thanks in advance.
You can use this link for autosizing
http://blog.mugunthkumar.com/coding/supporting-the-iphone-5/
Instead of giving static numbers give frames dynamically. means instead of giving 320 give self.view.frame.size.width so you no need to check the device, just you need to add default splash screen.
You problem could be resolved easily using Autolayout feature provided in the XCode Version 4.x .
Go through the following link :-
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
By applying few contraints using Autolayout your problem could easily be resolved.
Happy Coding :)
I have been looking everywhere on here and Google, but I still have this weird issue that I can't figure. I have an app pictures below, with 4 UIButtons that have a background image applied:
When I resize/run on the iPhone 5, the top button resizes in a very strange way:
How do I get all the UIButtons to resize the same way with the iPhone 5? Is it possible? Do I need to use a different method?
I really hope this is not a duplicate, but I am completely stumped. If I change the UIButtons around in other positions along the UIView, a different one will resize, or strange gap spacing will show up.... I don't understand. Thanks for any help!
EDIT: I am using iOS 6 on Xcode 4.5. I am testing on an iPhone 4S and an iPhone 5. I have AutoLayout checked. If I use Pin (just found it) I can get the UIButton to keep its height.
To clarify my question. I want the UIButtons to resize so they occupy the same percentage of the screen.... I want the proportions to be the same, instead of simply adding a bunch of empty space. I hope that make it more clear
One of the features you can use is called AutoLayout. Its provided with Xcode to make it easier adjusting things for the 4 inch screen. You can find a good example here: http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
But as far as I know AutoLayout works only with iOS 6 which makes it "not so useful yet". I have been using a class called UIDevice, source of which can be found here: https://github.com/erica/uidevice-extension and check if the platform type is iPhone 5. I have it set up in a method which setups GUI when the view loads. Example of my implementation:
UIImage *backgroundImage;
if ([[UIDevice currentDevice] platformType] == UIDevice5iPhone)
{
//I have a 4 inch screen present
myButton.frame = CGRectMake(x, y, w, h); //Set the frame as you would like it to look on the iPhone 5
backgroundImage = [[UIImage alloc] initWithCGImage:[UIImage imageNamed:#"main_background-568h#2x"].CGImage scale:2.0 orientation:UIImageOrientationUp];
}
else
{
//I have a 3.5 inch screen present
myButton.frame = CGRectMake(x, y, w, h); //Set the frame as you would like it to look on the iPhone 3, 3gs, 4, 4s...
backgroundImage = [[UIImage imageNamed:#"main_background"] retain];
}
self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
[backgroundImage release];
Hope it clears a bit.
you should firstly disable the use AutoLayout this option is under the "Show the file inspector"
I have an app for iPhone that uses some images compatible with retina and non retina devices. When I lunch the app on any iPhone simulator it works perfectly, retina and non retina images are loaded.
The issues appear when I select the app to run on my physical device (iPhone 4). In this case the retina images are not loaded any more and everything seems blurry.
I used "Don't Code Sign" since I don't have a developer account yet. I just wanted to get a feeling of my app, could it be because of this?
Here is a sample project that has the same behaviour on my physical device:
http://db.tt/XL4DPLH8
Solved: retina images were name 2X instead of 2x...also in the project and in the example.app / Thanks for the answer Adam (his answer disappeared)
Check resolution at start up by NSLog and then setting appropriate image...
- (void)viewDidLoad
{
[super viewDidLoad];
// NSLog(#"bound :%f", [[UIScreen mainScreen] bounds].size.height);
NSString* imageName;
if([[UIScreen mainScreen]bounds].size.height == 568)
{
imageName= #"568h#2x.png";
}
else{
imageName= #"bg#2x.png";
}
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:imageName]];
hope help
I made a game using cocos2d for iPad.. Now I have to scale it for iPhone. I tried using scaleX and ScaleY parameters for my GameScene. It scaled the sprites, but I have a lot of hard coded boundaries for my objects which don't get scaled. How can I do the complete scaling of my game??
you have to do something like following
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
[yourview setFrame:CGRectMake(400, 208, viewrect.size.width, viewrect.size.height)];
else
[yourview setFrame:CGRectMake(190, 96, viewrect.size.width, viewrect.size.height)];
you already done for iPad, so now you need to change else portion
set your view's frame there according to device orientation.
I'm trying to get started with cocos2d by creating an app with a background image. It's not a texture, just a straight image.
I add the background using:
CCSprite* background = [CCSprite spriteWithFile:#"paris.png"];
background.tag = 1;
background.anchorPoint = CGPointMake(0, 0);
[self addChild:background z:0];
The image is 960x640 but when I run it in the iPhone 5 simulator I only see a small part of the image. It's like it's too large for the screen. I was under the impression I would need 960x640. Is this not accurate? What resolution should my image be?
I've tried with and without the anchorPoint being set. Without the anchor I see a smushed image on 1/2 the screen.
Learn about retina display in cocos2d: http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:how_to_develop_retinadisplay_games_in_cocos2d
Make an image with 480x320 with name paris.png...
Rename your current image as paris-hd.png...
Enable Retina Display in app delegate.. And you are done.. Hope this helps.. :)