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.
Related
I was following raywenderlich's Metal tutorial, but got stuck rendering a texture on a plane, it seems to be showing only one color of the image, not the entire image. I'm running on an iPad iOS 12.3.
Here's a repo for the project: https://github.com/TheJoseph-Dev/MyMetalProgram
May anyone help me?
In your Renderer implementation, set a breakpoint on the line that reads:
private lazy var device = metalView.device
And run your code.
At the point in which this line is executed, the metalView exists, but the device on that metalView is nil. Similar problems can be seen for the other lazy properties of the renderer.
You may wish to use a less complex property style as it appears the properties are not being collected when the view is in the state you expect. I suspect that the view will not create resources like its device until it is attached to a window which will happen after viewDidLoad.
In my ARKit application ARSCNView is initialized and attached to ViewController internally based on storyboard file structure. So in function viewDidLoad I have already initialized view.
But the problem is it uses default rendering API metal. But I would like to change it to OpenGL ES2. In Apple documentation I read that preferredRenderingAPI can be somehow changed in IB inspector. But I don't understand how. There are no any examples of how to do this?
Or maybe I still change it from the code, even though the view is initialized from IB?
Just open your Main.storyboard (or whatever you have) in Xcode and navigate to the node Scene View of type SCNView in there. The Attributes inspector should allow you to change the renderer (Rendering API).
I've just tested it but it looked like my project didn't work the same as with metal.
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
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'm making a Sprite Kit app and in my scene I added an SKLabelNode. I noticed a pretty large lag-spike when I load the SKScene. After profiling the app I found it came from creating an SKLabelNode with a papyrus font(though the font doesn't matter). When I remove the label the scene starts up almost instantaneously, but with the label it takes an extra 1-3 seconds.
I am pretty sure it's from loading the font as when I go back to the main menu and play the game again it starts up instantly again.
Now is there a way to preload the font earlier so when the player selects the level there isn't a large pause?
We had this issue, and it turned out that we were simply not using the "correct" font name. In our case, we were using "Menlo" instead of "Menlo-Regular" when instantiating our SKLabelNode, and it was incurring the several-second penalty. Once we used the correct font name, the delay no longer happened.
(Curiously, the SKLabelNode still found Menlo and used it, so it was not immediately obvious that we had the wrong font name. Presumably, the delay is caused by the system having to figure out the appropriate substitute to use. It does a good job, finding the font we intended to use, but it takes a while to do it, hence the delay.)
I had the same issue. Add following code to your very first scene, with your font name:
SKLabelNode *preload = [SKLabelNode labelNodeWithFontNamed:#"Avenir"];
preload.text = #"text";
If you don't provide text it won't load font. Note that you don't need to add label as child to your scene.