I am trying to get into the sprite kit scene editor that recently came out, and having some difficulties. My main problem is that i can't seem to understand the size of it.
The current size is 1024 x 768. So i start adding nodes to it, and then run it as an iPhone app, and now it won't show my nodes. They simple get left out since it resizes it. My problem is, i thought it would handle this automatically (scale it to fit), but it doesn't.
so my question is, how do you handle this? I mean Apple has a lot of different screen sizes now, so how on earth are one supposed to match this? Surely you aren't supposed to create an entire scene for each screen size, there must be a better way? I just have no clue. I thought this code would take care of it (standard code when making a new spriteKit project) in the GameViewController that presents the scene:
// Create and configure the scene.
GameScene *scene = [GameScene unarchiveFromFile:#"GameScene"];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
But it doesn't. It displays it all if i'm running it on an iPad in landscape mode, but not if i switch to portrait or run in any iPhone orientation.
So how do you support multiple screen sizes with this new editor? And if anyone can point me to a resource where i can learn more about this editor i would be thrilled.
Thanks in advance,
Best Regards,
/JBJ
Question:
Are there ways to animate anything within the LaunchScreen.xib file of an Xcode 6 Project targeted to deploy for iOS 8.1+ ?
Context:
I'm looking to make simple animations to convey activity or serve as a distraction to the user while they wait...
Examples:
A Loading Bar
Activity Indicator
Animated GIF
Move a UIImage across the Screen
Rotate an Image
Nope.
The Launch Image is shown only during the time period between when the user chooses to launch your app and when your app has actually started running. During this period, your app can't take any actions such as performing an animation — it's not running yet. The Launch Image is just a static image that, when well designed, helps give the user the impression that your app is ready quickly.
(Some developers ignore the HIG and use the launch image to provide a splash screen, sometimes with an animated presentation. But in those cases, the launch screen is still a static image, and the animation happens once the app begins running — it's just that the first frame of animation drawn by the running app matches the appearance of the static launch image.)
This behavior didn't change with the LaunchScreen.xib feature in iOS 8 — it still appears only before your app is actually running, so it's still a static image. What the LaunchScreen.xib feature gets you is the ability to adaptively produce a launch image for many different device sizes and styles without having to separately design, render, and ship in your app bundle different images for each size/orientation/etc.
If your app isn't actually ready to use by the time it gains control, think about whether the "loading" tasks you're doing at that time really need to be done immediately, or if you can let the user start doing some things right away and do more setup work on a background thread or defer it until it's actually needed.
I don’t use splash screens often but when I do, I want them to open like a book.
In all truth, I’m not a big fan of splash screens and even Apple recommends using a default.png that shows the controls (with no text) of the application:
Display a launch image that closely resembles the first screen of the application. This practice decreases the perceived launch time of your application.
Avoid displaying an About window or a splash screen. In general, try to avoid providing any type of startup experience that prevents people from using your application immediately.
from HIG Guidelines
However, some people love them and one app in particular has a nice implementation splash screen — Path 2.0. When you open Path, you’re greeted with their logo on a red version of the Apple linen texture that animates open like a book (or journal as that’s what Path considers themselves to be).
You can get the source for this project here: https://github.com/jaysonlane/OpenBook
Before we begin, let me preface this with a disclaimer: I am very new to animations in Cocoa so bear with me. If you spot unnecessary or inefficient code, please leave a comment and I’ll tidy it up.
If you haven’t seen the animation, hop on the app store and pick up a copy to see what we’re trying to accomplish. I’ve created a default png that we can use cleverly titled Math (like a Math book that opens, right?) You can download that here (retina) and here.
To get started, let me explain “the trickery” behind what we’ll be doing: we’re going to use the normal default splash system in place to display our default.png. In the App Delegate, once the application has finished launching, we’re going to create a UIImageView on top of our view of that same default.png. We’ll then animate that UIImageView, to rotate open to reveal our view.
So let’s go:
Create a new project, I created one using the single view template but this will work with whatever. Go ahead and set your default.png and default#2x.png to the images supplied. You can do this by clicking the project in the navigation pane on the left, click the Target and scroll down to launch images:
Open your AppDelegate.m and add the following code to your application didFinishLaunching or application didFinishLaunchingWithOptions function:
//1. add the image to the front of the view...
UIImageView *splashImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[splashImage setImage: [UIImage imageNamed:#"Default"]];
[self.window addSubview:splashImage];
[self.window bringSubviewToFront:splashImage];
//2. set an anchor point on the image view so it opens from the left
splashImage.layer.anchorPoint = CGPointMake(0, 0.5);
//reset the image view frame
splashImage.frame = CGRectMake(0, 0, 320, 480);
//3. animate the open
[UIView animateWithDuration:1.0
delay:0.6
options:(UIViewAnimationCurveEaseOut)
animations:^{
splashImage.layer.transform = CATransform3DRotate(CATransform3DIdentity, -M_PI_2, 0, 1, 0);
} completion:^(BOOL finished){
//remove that imageview from the view
[splashImage removeFromSuperview];
}];
Three things are happening here…
1) We create a new UIImageView and add it to the top of the view
2) We set an anchor point on the left side of the image to make it open from the left and then reset the frame to the full size of the view
3) We animate the UIImageView and remove it from the view on completion
That’s it, it’s that simple.
Source: http://jaysonlane.net/tech-blog/2012/03/path-2-0-style-animated-splash-screen-default-png/
You can create the LaunchScreen.xib and then create a perfect replica that you can put code on and have a class like LaunchScreenAnimator that you can call form your delegate and that has a delegate to tell you when the animation is over
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
LaunchScreenAnimator *la=[LaunchScreenAnimator createWithDelegate:self];
self.window.rootViewController=la;
[self.window makeKeyAndVisible];
[la startAnimation];
return YES;
}
-(void) splashAnimationFinished:(LaunchScreenAnimator*)view
{
[self startWithDashboardWindow]; // replace the current rootViewController with whatever you want
}
I'm building a game that requires levels. These levels, so that they all fit onto one page I have had to add them to a CCScrollView. This view loads automatically, as I have set in the SpriteBuilder App. The CCSrollView has been added in the MainScene.ccb file, and the content node for the scroll view is Level.ccb. What I'm trying do is have a button that is in the Level.ccb that changes the scene/content node to a level which is called Gameplay.ccb. I've tried writing the code to change the scene in the MainScene.m and Level.m files in Xcode. However these bring up an error. I'm still learning to code, so sorry if the question has been asked or has a really easy solution
- (void)levelOne {
CCScene *gameplayScene = [CCBReader loadAsScene:#"Gameplay"];
[[CCDirector sharedDirector] replaceScene:gameplayScene];
}
This piece of code is how i would switch the scene without the scrollview
If you do not understand what my problem is and would like the code send me a message and i will email you the source code
Thanks!
I'm currently working with the AVCam demo app to present a live camera feed over airplay or apple hdmi adapter for import into a HD camera switcher.
The issue I'm having is with OverScanCompensation to remove the huge black border from the mirrored view.
The only documentation I have found is to implement the screen.overscanCompensation = 3; method someplace? I have tried to put it into viewDidLoad and it will let me, but it doesn't change anything on the external view?
I had success of sorts with the Airplay Demo (quellish) using UIImagePicker, but I would much prefer to implement AVFoundation for this exercise.
Is there a better way to achieve what I'm looking for without having to implement separate view controllers?
All you need to do is, upon setting up the external screen (via, say, if ([[UIScreen screens] count] > 1) externalScreen = (UIScreen *)[[UIScreen screens] objectAtIndex:1];), set the overscanCompensation property of the above UIScreen instance to UIScreenOverscanCompensationInsetApplicationFrame (=2). It'll entirely get rid of both the border (overscanning) and image quality-deterioating scaling.
See http://www.iphonelife.com/blog/87/tv-display-output-why-does-your-picture-have-black-border-and-how-can-it-be-fixed for more info.
I started out with the UISplitViewController template in Xcode 4, and added a UIImageView that covers the whole detailViewController.
When i run the project the image and views render correctly. If i rotate the device it also renders correct, but if i hit the PopoverButton while in portrait and then rotate the device the image is rendered above the rootView..
I've been trying to reproduce the bug you're experiencing, but without success. Could you provide information about how you add the image view and how you set its frame?
One possible solution that I can think of is setting:
self.view.clipsToBounds = YES;
in viewDidLoad of the detail view controller.
It would however be great if you could provide some code, so that I can reproduce the bug and tell you what's wrong.