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
Related
I am generating my levels in SpriteKit via code (in Swift), and its not working out entirely how I'd like. Is there a way to inspect the scene of the simulator at run time. E.g. So I can view how things are being placed outside the visible screen.
Thanks!
Believe me, level editor via code rarely is a good idea. There are exceptions but if you need static levels then you should find another way to defined it.
How can you see your entire scene?
AFAIK you con't with Xcode 7, however you can change how the scene is resize in order to show the full scene inside the view. Depending by the size of your level you can judge whether this is solutions fits your case.
Just open GameViewController.swift and change this
scene.scaleMode = AspectFill
into this
scene.scaleMode = .AspectFit
Now your scene will be compressed to fit the size of the screen. Of course don't forget to restore the original value once you are done.
So, I have a game that was developed for iPad. It's pretty complex, combination of Unity and native UIKit, a bit of Interface builder, a lot of programmatic view generation, surely many hard-coding sins and so on.
Now I would like to create an iPhone version of this game. I could either go the lengths of redesigning and porting all the graphics, programmatically make them fit arbitrary view sizes and aspect ratios, use Interface builder's autolayout and so on,
OR
I just scale everything down to fit the screen. Which is what I'm trying now. I'm fine with letterboxing.
So, right after my application launched, I scale down the main window, like so:
//scale window down to iPhone 6 size
CGAffineTransform transform = CGAffineTransformMakeScale(0.416666f, 0.416666f);
UIView* v = self.window;
CGPoint origin = v.frame.origin;
v.transform = transform;
v.frame = CGRectMake(origin.x, origin.y, v.frame.size.width, v.frame.size.height);
Works well, looks great, no aliasing or performance problems, but:
touch input doesn't work anymore - I can't click anything! Does anyone have an idea what could be the reason for this and how to solve for it?
The same is true by the way If I replace 'self.window' with 'self.window.rootViewController.view'
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 think I've looked through all the previous posts that are similar to this problem and couldn't find a solution so I hope someone can help me.
I've got a very simple game using SpriteKit. The game is in portrait mode only. When I view the game in the simulator, the ads appear perfect but they are on top of my content and have also shifted the top content off the screen so you can barely see the scores. I'm not sure if I need to do something in the ViewController or the scene itself that has the ads running, but I think the ViewController is the correct place.
I'm hoping someone else had this problem and figured it out. I saw some people say that using:
scene.scaleMode = SKSceneScaleModeAspectFill;
or
scene.scaleMode = SKSceneScaleModeAspectFit;
changed their views to work. I'm using "fill" but I tried "fit" and neither seemed to do anything. Ideally the top of the banner is the new bottom of my screen and I can get everything to fit in the new smaller size but I'm kinda of stuck at the moment. Thanks for any help you can provide!
I had the same issue and instead of using AspectFill or AspectFit
use this.
scene.scaleMode = .Fill
This option didn't cover up as much content as the others.
I work on an app, which scans an image and shows you a 3D-Object or a video on top of the image target. Normal AR-App. For that AR stuff I usw the Vuforia SDK. The problem is, that the Vuforia SDK don't support animated 3D-Objects and for that I use cocos3d.
So I created a basic cocos3d app and included my vuforia stuff for the AR. This works good and the app displays normal 3D-Objects and videos. This was the background, now the problem.
The first view I have is my camera view, which scans the images. If I scan now a specified target, I want to show an animated 3D-Object. For that, I display the cocos3d view on top of the AR-View. The cocos3d view is transparent and is displayed on top of the AR-View (tested this with a simple button in the cocos3d view).
The problem is, that I'am not able to display a animated 3D-Object. I tested some options but none of them worked because I don't really have an idea how to do that. My current code:
CCDirector *director = CCDirector.sharedDirector;
EAGLViewCC *glView = [EAGLViewCC viewWithFrame:[window bounds] pixelFormat:kEAGLColorFormatRGBA8 depthFormat:GL_DEPTH_COMPONENT16_OES];
[director setOpenGLView:glView];
[window addSubview:director.openGLView];
After that I have a layer and add the test scene to my layer (Standard from the example). But than I don't know how to display it. It tried this:
[director pushScene:scene];
but no luck. In the example, they use this code to show the object (viewController is of type "CC3DeviceCameraOverlayUIViewController").
[viewController runSceneOnNode: mainLayer];
Why don't I use the viewController? Because I couldn't get the view transparent. So how do I get the 3D-Object displayed in my view? What do I have to do? Am I completely wrong?