Using Flash Professional CS6, I've created a game that looks and plays great on an iPad 2 and 3. So now I'm ready to make the app "Universal" by making one that works better for the smaller screen on iPhones.
What I'd like to do, is detect in my first frame something like this:
if iPhone {
gotoAndPlay(2, "Scene 1");
}
else if iPad {
gotoAndPlay(3, "Scene 2");
}
else {
trace("Not an iOS Device");
}
If seen posts from 2010 where people retrieved the height and width of the device in px, but surely there's a better way right?
Capabilities class has useful info. The os property should help determine the device but you'll need to experiment to see what each device returns.
However, i would suggest basing logic on screen size rather than device type - that way its more flexible.
Related
I know that an app developed for iPhones older than iPhone5 is working in a letter box.
But how about the revers. An app updated to iPhone5 standard. How does it work on iPhone4 ?
If not, when all developers have updated their apps, the older iPhones will be without apps or updates ?
This is more geared toward MonoTouch, but the same techniques apply to Obj-C:
http://redth.info/get-your-monotouch-apps-ready-for-iphone-5-ios-6-today/
Basically the Default-568h#2x.png file will tell iOS that it's a 'Tall' app. For other image assets you need to detect if it's the tall device or not by checking the UIScreen's MainScreen's Bounds as well as if it's an iPhone idiom or not and then seeing if the height is 1136 (checking the scale value), and then selecting a different sized image in this case.
Here's the C# code, but again it's very close to Obj-C:
public static bool IsTall
{
get
{
return UIDevice.CurrentDevice.UserInterfaceIdiom
== UIUserInterfaceIdiom.Phone
&& UIScreen.MainScreen.Bounds.Height
* UIScreen.MainScreen.Scale >= 1136;
}
}
Just add an image called Default-568h#2x.png (640x1136) to your project and like magic it will work! It's unbelievable how easy it is.
They will need to adjust their layout accordingly using AutoLayout or something similar.
Of course they will work.
If you don't code them to automatically shrink or use smaller images, then it'll just get cut off top or bottom.
I have a very rare problem on iOS (iphone).
i developed the site yolieva.de with a videoclip which also runs on ios. but it plays in the background because on top is the navigation with z-index. but it is not accessible from ios. kind of disabled because of the videoclip. you may want to try it with an iphone and you see you cant click through the siteā¦
how to solve this? i want to keep the navigation above the video
I think this has something to do with how iOS deals with the videoclip, so I am not sure that you can do anything about it directly.
Why don't you make the div containing the flash player (id player) smaller on the iphone?
In fact, on the iphone your flash video is not shown in place, there is anyway a change of view, so there is no need of having it full screen either. Of course, you should make your flash player div smaller only for iOS, not other browsers, where it is fine that it is full screen...
How can I get to know that the device is iphone or ipad using actionscript3.0?
Check out the Capabilities class: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html
There's no 100% method to test if something is a specific device (Adobe say to not do it), mainly because you can end up with a ball of spaghetti code that's not future proof (e.g. the resolution/dpi roughly doubled between the iPhone 3GS and the iPhone 4, and who can say what the iPhone 5/6 etc will have).
What you could use are cpuArchitecture, manufacturer, os, pixelAspectRatio, screenDPI, screenResolutionX, screenResolutionY and touchscreenType to help try and figure it out.
There's also ContextMenu.isSupported as the context menu (what shows when you right-click on a swf) doesn't show up on smart phones or tablets (no right-click)
My question is simple:
1. I made an iphone app all done in cocos2d.
2. I adapted it to iphone4-retina, with all PNG files have their -hd copy.
Run in iPhone, the app displayed correctly (320x480).
Run in iPhone4-retina, the app also displayed correctly (640x960).
But run in iPad, if the app is set to iPhone only, it run correctly, but only as iPhone resolution (320x480). If the app is set to iPhone/iPad, of cause it will display wrong.
I'm sure there should be an option that force a retina-compitable iPhone app also run as retina on iPad (apple guys cannot be silly enough to miss it), but I just couldn't find it.
Where's the option? Or, is there an alternative that cocos2d has a same-easy switch to do the job? I do not need suggestions such as using relative coordinates or anything requires modifications more than twenty code-lines.
As far as I know, there is no automatic adaptation of an iPhone app to iPad. You still should be able to create a universal app for both iPhone and iPad and then re-create your UI based on whether you are running on one device or the other.
Specifically, you could:
Create an XCode project for a universal app (armv6 and armv7, targeting iPad and iPhone) and import there your existing project (source, resources, settings).
1b. (you could modify your existing project, but this could be trickier to do correctly.)
add icons and default images as per iPad guidelines in addition to those you have for iPhone;
As to the rest, you could follow a similar approach to the one highlighted here for Xibs:
test for iPad:
+(Bool)isIpad{
return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
}
translate image name before loading:
+(NSString*)properImageFileName:(NSString*)imageName {
if ([xxxx isIpad]) {
return [NSString stringWithFormat:#"ipad_%#", imageName];
} else {
return imageName;
}
}
Thus, if you are on iPhone, image names are not changed and will follow the iPhone convention for retina display; if you are on iPad, you change the name on the fly and use the right image. (of course, you can use the convention you prefer to identify iPad images).
This should make it pretty trivial, but keep in mind the size toll that having all the images in your universal app tolls.
I'm developing a game using cocos2d. It's running now on iPhone and also supports Retina display. With retina i'm using images with "-hd" postfix. Now i want my application to be able to work on iPad using this images. How can i do that ?
PS: I don't have a real iPad and can only use a simulator. I will test the game on my friend's iPad after it will work well on a simulator. Is it possible to use hi-res images with simulator and how to do it?
I'm using cocos2D 0.99.5
inside CCFileUtils.m
inside method name +(NSString*) getDoubleResolutionImage:(NSString*)path
edit if( CC_CONTENT_SCALE_FACTOR() == 2)
to if( CC_CONTENT_SCALE_FACTOR() == 2 || (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad))
this will make the app to load the -hd image when running on ipad, remember to change your app targeted device family to iPhone/iPad.
this will solve the loading of -hd problem for ipad.
but after loading -hd file for ipad resolution, you will also notice that most of your image position should be off alignment, now either you go directly into the cocos2d folder to edit how CCNode,CCSprite,CClabel handle the positioning of thing or you code it in your code checking if its ipad or not.
if you are using CCSpriteBatchNote. this will also cause another problem because you will be reading from the -hd SpriteSheet. so the texture Rect u set to cut need to be double too.
another method is position everything according to winsize. i haven try this method.
I don't exactly understand the question but I will try to answer.
You can technically use the same graphics for the iPad, but they will not look as nice. For one, they will all blurry and pixelated, and two, the iPad has a different screen aspect ratio that the iPhone/iPod Touch. If you do make separate images for an iPad version of your game, it will not be extremely difficult to do. If you want to do this, I suggest posting a new question.