What is the difference between setScale and SKSpriteNodes in SpriteKit and Swift?

I tried to set the size SKSpriteNodefrom a PNG image (OK with this, just a:

test = SKSpriteNode(imageNamed: "myImage")

But when it comes to changing it, I'm not sure what I should use test.setScaleor test.size. What is the difference and when should I use each of them?

+4
source share
4 answers

setScale():

Sets the xScale and yScale node properties . These two parameters are the scaling factor that multiplies the width (for xScale) and height (for yScale) of the node and its children.

Code example:

spaceship.setScale(0.50) // decreased scale to it half size

size(): ( ) .

:

spaceship.size = CGSizeMake(100.0, 70.0) // Re-size the dimensions to these values

setScale size?

setScale , , , SKAction.scaleTo, .

size , , .

+3

spriteNode, .setScale .xScale .yScale, ..size UIKit.

, , 2x :

theNode.xScale = 2.0
theNode.yScale = 2.0

, float,

, ,.setScale - , .size - , , .. , , .setScale. , .size.

, , , - . !

+1

, SKSpriteNode , node.

node () node, , node, ().

node , .

. , , , 1.0 - scaleTo scaleBy .

+1

.size, , node .setScale/.xScale/. yScale. node, physicsBody.

0

Source: https://habr.com/ru/post/1649556/


All Articles