I created a SpriteKit game and it works well except when I turn my Iphone 6 view mode to zoomed the game looks like zoomed too.
When I return to the standard mode everything goes back and looks just. I create the nodes in the right dimensions. Like it works on Iphone simulator.
I tried to change the scale mode in GameViewController and nothing changes, I still have the same problem.
Related
So the main problem is a blank screen after Launch.storyboard finishes.
But from the beginning: I wanted to use fullscreen in my game. When I checked "Requires full screen" AND "Launch Screen File" was left empty like on the image,
... the app runs without launch screen (as expected), but I get a scene which is NOT playing as fullscreen, like on the image below, (the status bar is visible, there are also two black bars on either side). In the GameViewController I have: override var prefersStatusBarHidden: Bool { return true },
In info.plist I have:
No matter what I do I do not get full screen without visible status bar.
Now, I change to this:
And... Launch.storyboard shows itself (it has only text, not any large pictures), after this nothing happens, there is only blank screen without any images. I can hear background music, I can even touch the screen and the game runs but I do not see anything. This happens on both my physical devices - iPhone SE 1-st and 2-nd gen. attached to my computer. Interestingly, when I press device's sound level buttons, up or down, .. voila, and I can see everything now, the game scene appears! (full screen without status bar, as I expected).
I tried everything: reinstall app, remove Xcode cache, reboot computer and device - nothing works, all the time blank screen with music. I checked on the simulators - on SE (2) and others everything works fine, the launch.storyboard loads, the game is visible from the beginning. On another physical device, iPhone 12 works fine, also on iPad Pro works fine, (but for a very short time the black screen appears). Maybe it has something with memory, but on the other hand SE 2-nd gen. is rather new device.
Do you have any ideas what could be wrong and how to fix this? I do not want to publish the app until I am 100% sure that it works on all devices without any issues.
Thank you ZAY, but I think I have found the answer after many attempts. When Xcode creates the default Game scene, it creates Main.storyboard that looks like this: .
What I did: instead of default SceneKit View, I added default View, like this:
Everything seems to work now. Do not know why, but it works.
I built my game on the iPhone 6 simulator, and everything was going fine until I needed to switch screen sizes for screenshots. I switched from the 6 to the 5s and now everything is in the wrong place and very off center. How do I make my game suitable for all screen sizes with everything in its place? Will post code if necessary.
If you have hardcoded your view locations and sizes (as opposed to making everything relative to everything else) then you will either have to refactor to make everything relative or do some sort of scaling and letterboxing.
Since a few years back I have a "iPhone is the controller, game screen displayed on TV by way of Apple TV and Air Play" project slowly going. It's like a space-shooter-maze kind of game, except there is no shooting and the objective is to steer a spaceship to find the boss (which is a pic of my then ~1 year old son). Like a NES game without the NES.
Now when I run the stuff for the first time in like a year or so, the controller, which is basically using a SpriteKit scene down the line, is tilted 90 degrees in the right OR left direction. The "OR" depends on what orientation my iPhone 6 Plus is in when the app starts. So the game only takes up half of the tv screen now - because it's tilted - and even a lay man can see that something fishy is going on because the text is not the normal horizontal text you are reading now, it's tilted.
Did something change recently, like with iOS 8 and how hooking up additional UIScreen:s work? I rarely touch this project, so I forget how everything work most of the time I do something with it again after a long hiatus. Anyone experienced this and know where to start digging?
Poking around, it seems that the app itself and what is displayed on the handheld device/controller (the iPhone) must/should be portrait only. If the app is launched in landscape mode, the screen display on the tv will also be "tilted", without the tv itself being tilted... and things get out of order. I set portrait only just by clicking around in the target->device orientation checkboxes.
This is kind of unwanted because the a normal video game controller is held in a landscape position and this was the way I always used it. I don't know what made this work differently, maybe it's the iPhone 6 Plus with landscape support at the home screen level, or maybe iOS 8 or whatever.
So there are basically two options here.
Design the controller as portrait, but already in the design put everything tilted. The bottom left steering cross would have to be put top left, tilted 90 degrees to the right for a fake "landscape right" setting. Might be less of a pain than doing the same thing to the tv screen instead.
Continue with the use of real landscape mode for the controller, and use some anti-tilt rotation by setting a new rotated transform of the tv controller's view's transform. (I tried this, it seemed like it needed a translation as well, so I gave up. Still might work.)
Update: I found a better solution:
Allow landscape right, landscape left AND portrait rotations of the app. (In that order, if you intend to launch the controller in landscape mode - but portrait has to be in there.)
In the subclass of UIViewController that controls what's going on upon your tv, return UIInterfaceOrientationMaskPortrait in supportedInterfaceOrientations. The tv controller must be run in "portrait" mode, which for a tv controller would mean the "default" mode, which for the eye looks like the normal landscapish mode. A landscaped tv controller would mean a tilted view, and we don't want that. Yes this is weird but maybe logical. Oh, and in the subclass of UIViewController for the hand controller, I return UIInterfaceOrientationMaskLandscape so as not to support portrait mode. The user likely launches the controller in portrait mode (especially on any iPhone other than 6 Plus) and if we supported that he/she would maybe think the controller can only be used in portrait mode, and that is very inconvenient when playing video games.
I´ve tried running my iOS (for iPhone) game built with cocos2d on an iPad and almost everything works just fine, except the first screen to display where the UI elements is all over the place.
However, if I switch to another View (or Scene in Cocos2d) everything looks great and if I switch back to the previously messed up screen, it also looks normal.
So, the first screen to load when running on the iPad will look messed up and I have no idea what´s causing this.
Any ideas?
This generally happens when you inherit your scene class from CCNode. Change the parent class of your scene to CCScene.
I'm creating a cocos2d game on iOS that uses the accelerometer. I just started testing on an iphone 5 and for some reason, it's reversing the accelerometer data - basically it behaves as if the screen orientation is 180 degrees flipped from how it actually is, tilting down causes it to send things up, left goes right etc.
It works fine on my iphone 4 running iOS 5 and on both my ipad running iOS 5 and my ipad running iOS 6. Not sure if it's an issue with just the iphone 5 or all iphones running iOS 6.
I can't find any mention of this issue online, wondering if anyone else is running into this and if you know of a solution.
OK I figured out what was going on. In iOS 6 the willRotateToInterfaceOrientation method is deprecated and no longer gets called. I had code in there to do two things - detect which landscape orientation the phone was loading into and adjust the variables accordingly, and to prevent the phone from flipping the orientation during gameplay (it's a tilt-to-move game). The reason everything was behaving as if the view was upside-down was because it was, and the phone's orientation was locked, and my code to correct for that wasn't being called. Here's what Apple says about willRotateToInterfaceOrientation:
The willRotateToInterfaceOrientation:duration:,
willAnimateRotationToInterfaceOrientation:duration:, and
didRotateFromInterfaceOrientation: methods are no longer called on any
view controller that makes a full screen presentation over itself—for
example, by calling presentViewController:animated:completion:. You
should make sure that your apps are not using these methods to manage
the layout of any subviews. Instead, they should use the view
controller’s viewWillLayoutSubviews method and adjust the layout using
the view’s bounds rectangle.
Now I just need to figure out how to use the willLayoutSubviews method to replicate my original functionality.