Reputation: 943
I have a physics body that needs the y scale to be 0.2. I have been using the rectangleOfSize property to define my physics body, but am not sure how to change the y scale of it. I had changed the y scale earlier in the code, and would like to know if there is an easier way to do this other than having to go into photoshop and create a new image. I will provide example code if anyone needs me to. Thanks!
Upvotes: 0
Views: 242
Reputation: 1904
Unfortunately, scaling the physicsBody in Spritekit would cause collisions to be bugged, I would recommend that you create a new physicsBody and assign it to the node instead.
As to change the yScale of the node, you can simply call this function
node.yScale = yourValue
Upvotes: 1
Reputation: 1467
Yes, there is an easier way! I recommend looking into SKAction
. SKAction
contains the class methods:
+ (SKAction *)scaleBy:(CGFloat)scale duration:(NSTimeInterval)sec;
+ (SKAction *)scaleXBy:(CGFloat)xScale y:(CGFloat)yScale duration:(NSTimeInterval)sec;
Upvotes: 0