0

I have an SKShapeNode which is supposed to be a paddle in a breakout-style game which I would like to scale in width by some factor.

It looks like this:

image

After I run

[SKAction scaleXBy:3.f / 2.f y:1.0 duration:1.0],

it looks like this (ignore the other grey brick in the corner, that's just another paddle):

image

The problem is that the triangles on the side are no longer 45-45-90.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
michaelsnowden
  • 6,031
  • 2
  • 38
  • 83

2 Answers2

0

That's to be expected because you don't preserve the aspect ratio of the shape when scaling x by 1.5 and not scaling y (1.0).

You'll have to create a new shape by changing the path property to use a path that adheres to your specifications.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
0

What you're essentially asking for is to scale the center rectangle without scaling the triangles at either end. To do that easily, you could create a compound of four nodes — a parent node that contains separate nodes for the three shapes. When you want to embiggen your paddle, scale the rectangle and move the triangles.

rickster
  • 124,678
  • 26
  • 272
  • 326