2

I have made my game prototype for iPhone6+. I have a circular sprite which has dimensions 108x108. I am creating artwork for my prototype for the iPad. After doing my calculations (iPhone6+ width to iPad reduces by 7.25% and the height increases by 23.67% for 2048x1536), I arrived at a 102x133 sprite image for the iPad. This image is not a circle. The moment of the circle is dependent on the radius so I need to calculate it right for the physics. How should I calculate my radius to get a similar look and movement? Currently I am using the following:

radius = sprite.frame.size.width/2
sprite.physicsBody = SKPhysicsBody(circleOfRadius: radius)
Serenade
  • 55
  • 5
  • 3
    http://math.stackexchange.com/questions/432902/how-to-get-the-radius-of-an-ellipse-at-a-specific-angle-by-knowing-its-semi-majo#432907 – Idan Nov 23 '16 at 11:47
  • 1
    @Idan how can I write this is Swift code? and if I use a 102x133 image for a circle on an iPad would it look like a circle or an ellipse? – Serenade Nov 23 '16 at 13:25
  • You need to approach your game differently, if you need to retain the shape of all of your objects, you need to clip some of your game – Knight0fDragon Nov 23 '16 at 13:50
  • 1
    @Knight0fDragon Yes, I need to retain the shape of the sprites. Please would you explain how I can achieve this – Serenade Nov 23 '16 at 14:51
  • 1
    This is explained all over SO and other websites, just look at how to handle scaleMode – Knight0fDragon Nov 23 '16 at 14:58
  • @Knight0fDragon I found some stuff on `scaleMode` but it's a bit confusing. I decided to go with the `.fill` mode but I am not getting it to fill the whole scene view. I asked a follow up question http://stackoverflow.com/questions/40789050/scalemode-fill-not-filling-the-scene-view-on-ipad – Serenade Nov 24 '16 at 17:48
  • You want .aspectFill to keep shape, .fill gets you distortion – Knight0fDragon Nov 24 '16 at 18:41
  • @Knight0fDragon I am using a 2048x1536 image for my iPad Air 2 background and it's zoomed in. – Serenade Nov 25 '16 at 05:16
  • @Knight0fDragon I really don't get it. I am using a 2048x1536 image and the .aspectFill scaleMode and testing on the iPad Air 2 simulator but it's still zoomed in (cropped off) – Serenade Nov 25 '16 at 07:05
  • your scene size is your window size – Knight0fDragon Nov 25 '16 at 12:22
  • 1
    @Knight0fDragon Thanks. when I checked my scene size it is 1024x768. I changed my background image to 1024x768 and it's working. So why does nearly every site/ post I see talk about using 2048x1536 for iPad Air image dimensions? I am really trying to understand this works. I would really appreciate some explanation. – Serenade Nov 25 '16 at 12:54
  • 1
    because they are dumb and have no idea how retina style works, this is why we have -@2x graphics. You get to program in -@1x dimensions with higher resolution images – Knight0fDragon Nov 25 '16 at 13:04

1 Answers1

0

The height and width of a sprite shouldnt get affected by the number of pixels on screen, it would only affect the viewable area of your game. If you're running into a case where it is being affected that way, you should think of simply changing the scale mode on the scene. Here's a good explanation of using scale modes -http://blog.infinitecortex.com/2014/01/spritekit-understanding-skscene-scalemode/

DreamerNo56
  • 213
  • 1
  • 8