Im trying to make a game with Sprite Kit on iOS. I have a UIViewController with an SKView, and I am using one SKScene.
Now in my scene, I am initializing a 'Player' class, which is just a custom class I wrote, it's a subclass of NSObject. The problem is that I need to know what the screen size is inside my custom class. From what I can tell, the only way to know the screen size inside my custom class is to pass it in from the scene in the Player's initializer.
Is there a more elegant way to do this? Thank you.
You could just use [UIScreen mainScreen].bounds within your Player class. Check out the applicationFrame and scale properties of a UIScreen as well.
You might argue that having a Player know the screen size isn't elegant in the first place, but nonetheless this is a way to do it without passing the information into a Player.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With