How do I resize a new image to an existing Sprite?

I have multiple images that at various times I need to replace a target image for a SKSpriteNode.

Each of these multiple images has a different size.

The target SKSpriteNode has a fixed frame that I want to stay fixed.

This target is created via:

myTarget = SKSpriteNode(imageNamed: “target”)

myTarget.size = CGSize(…)
myTarget.physicsBody = SKPhysicsBody(rectangleOf: myTarget.size)

How do I resize each of the multiple images so that each fills up the target frame (expand or contract)?

Pretend the target is a shoebox and each image is a balloon that expands or contracts to fill the shoebox.

I have tried the following that fails, that is, it changes the size of the target to fit the new image .. in short, it does the exact opposite of what I want.

let newTexture = SKTexture(imageNamed: newImage)
let changeImgAction = SKAction.setTexture(newTexture, resize: true)
myTarget.run(changeImgAction)

Again, keep frame of myTarget fixed and change size of newTexture to fit the above frame ..

The Frame you are talking about is PhysicBody, right?

If so, it's because when you change the texture, even though it asks you to resize, it doesn't change the physicsBody, so you would have to recalculate

How do I resize a new image to an existing Sprite?
 
 
Q