SpriteKit scale for universal app - iphone

What is the best practice to universal app?
Make iPad version and them scale to iPhone ? is a good idea?
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
viewSize.height *= 2;
viewSize.width *= 2;
}
Thanks for help!

This tutorial will be very useful for you .
http://www.raywenderlich.com/49695/sprite-kit-tutorial-making-a-universal-app-part-1
http://www.raywenderlich.com/49697/sprite-kit-tutorial-making-a-universal-app-part-2
I'm sure that it will make your apps better

Related

How to have sprite kit automatically resize depending on dimension of phone

At the moment, to handle the different screen sizes of the iphone 4 and 5 i use the following:
if ((int)[[UIScreen mainScreen] bounds].size.width == 568)
{
-----
} else {
-----
}
But with the edition of the 6 and 6 plus, this just seems like to much code to do for everything that requires a position on the screen. Is there an easier way to do this, where it automatically resizes for you?
I wrote an application using iPhone 6 dimensions in SpriteKit SKS files. When switching scenes I used the following code, the game scaled automatically when testing on different devices.
let yourScene = yourSceneFile(fileNamed: "YourScene")
gameplay!.scaleMode = .AspectFill
self.view?.presentScene(yourScene, transition)

Anyone has a tutorial on how to create Universal app with XCode 4.2?

It looks like things changed with XCode 4.2 and I did not see any guide/tutorial on how to create a Universal app with XCode 4.2. Anyone knows one or wrote one?
Note: I'm not talking about how to select your project to be Universal, I'm talking about a Hello World tutorial.
Thanks,
In case you actually wanted a plain source, compilable as a universal app that writes Hello World into the console, depending on the device in use, here comes a tiny snippet for you.
main.m
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
printf("hello world, from my iPad");
}
else
{
printf("hello world, from my iPhone or iPod");
}
return 0;
}
Within the build settings of your app, you will have to select:
TARGETED_DEVICE_FAMILY = 1,2
Like this:
File / new / new project / ios / application / single view application
Next
fill fields and choose "Universal" in Device Family
Next
Xcode will create a project with 2 initial XIBs with same names and different suffix _iPhone and _iPad.
Enjoy!
Good luck!
Look for any Hello World iPhone OR iPad app. Make sure you set the project to Universal.
iPhone: http://www.tuaw.com/2009/04/27/iphone-dev-101-the-hello-world-app/
iPad: http://hijinksinc.com/2010/07/23/entry-level-xcode-hello-world-for-ipad/
Try :
Head First iPhone and iPad Development, 2nd Edition
A Learner's Guide to Creating Objective-C Applications for the iPhone and iPad
By Dan Pilone, Tracey Pilone
They have a great section on Universal Apps :)

what framework should i use for this game?

hi all
i'm beginner to iOS
i'm trying to make a game when i use NSTimer for action a Ball (for example)
and use CGPointMake for posing in the view its so unreal i mean its like an
old pc with low ram (frame frame) i thought i need to use a Framework for THIS
Can any body help me?
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
xValue = acceleration.x*80.0;
yValue = acceleration.y*80.0;
ball.center = CGPointMake(ball.center.x + xValue, ball.center.y);
if (ball.center.x < 24.0) {
ball.center = CGPointMake(24.0 , ball.center.y);
}
if (ball.center.x > 296.0) {
ball.center = CGPointMake(296.0 , ball.center.y);
}
}
Definitely go for cocos2d and Box2D for your physics:
http://www.cocos2d-iphone.org/
http://www.box2d.org/
There are plenty of tutorials out there on both.
I'm not sure I completely understand your question.
OpenGL is a good framework to use for game creation, especially graphics rendering on iOS devices.
Here is a good tutorial you might like to follow.
Here:
http://www.iphonedevbook.com/
If you register on the forum, you can download the sample code from the book "Beginning iPhone 3 Development".
Chapter 15 is called "Ball", and has code which rolls a ball around the screen, based on input from the accelerometer.
cocos2d is a nice framework for writing iPhone games
http://www.cocos2d-iphone.org/

iOS 4.0 contentScaleFactor and scale - how to handle in 3.1.3?

I am tasked with making an app that works in iOS 4.0 work in 3.1.3 and 3.2 again. Mostly it is straightforward but the handling of the new API for scale and other situations where values must be passed/returned is hard.
respondsToSelector/performSelector takes care of nearly everything else.
Here's a simplified version of what is going on:
-(float)getImageScaleFactor
{
if([[UIScreen mainScreen] scale == 2.0)
return kScaleFactorForRetinaDisplay;
else
return kScaleFactorForOlderDisplay;
}
scale isn't in iOS prior to 4.0.
Can anyone show a code sample that will work in all versions of iOS?
I use very similar code, but you're missing one important part: respondsToSelector:
if([[UIScreen mainScreen] respondsToSelector:#selector(scale)] && [UIScreen mainScreen].scale == 2.0f)
return kScaleFactorForRetinaDisplay;
else
return kScaleFactorForOlderDisplay;

How can I detect which system my App Store application is running on?

I am developing a Cocoa Touch application for Apple's App store and I want to do some tweaking in the code depending on what device it's running on. How can I tell?
I've used this in a Universal app to determine if the code is running on an iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// Do iPad only stuff here
}
Check out the documentation for UIDevice
Look at UIDevice and it's properties. There is a systemVersion string that will work for what you want.