I'm working on a game but can't figure out the right way to scale/ position everything. I have a universal app and when I switch from device to device the nodes aren't in the right place everytime. I'm using AspectFill because it sizes my nodes the the right way for each device. The problem is the positioning. I don't know if I'm right in making the conclusion that I need to figure out how to make the view the same size as the screen so that it changes for each device and then positions and scales everything properly, but this is what I've been trying to figure out. I've been trying many different things online and looking at things like how to make a custom view. I've tried to make a rectangle that ha constraints to fill the screen and then setting that rectangle to equal the UIView or SKView. I've tried many different things and looked at many things online but they are either confusing and I don't know if I'm trying them right or they don't pertain to my situation. This is causing a lot of confusion for me and I was hoping someone could help with this issue. I think the issue is that I need to make a custom view that relates to the size of the screen. I don't know if this is possible or what I should be going after. It would be great if someone could clear this up for me.
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- Using if let syntax in switch statement
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
- Swift - Snapshotting a view that has not been rend
To keep my games universal I make all my
node
s sizes and positions dependant onSKScene
sizeInstead of using hardcoded numbers try using proportions from your
SKScene
size. For example: Instead of writing this:Write somthing like this:
Same for sizes
Also
GameViewController
should look something like this:Was this helpfull?