Resizing a SKShapeNode

2020-06-22 05:03发布

How do I resize a SKShapeNode?

What I've tried so far:

Frame resize

box.frame.width = 10

Gives the error Cannot assign to the result of this expression

SKAction

let actionResize = SKAction.resizeToWidth(10, duration: NSTimeInterval(0.1))
box.runAction(actionResize)

Nothing happens

xScale

box.xScale = 0.1

Scales the node instead of resizing

2条回答
不美不萌又怎样
2楼-- · 2020-06-22 05:53

Change it to a var:

var shapeNodeName = SKShapeNode(rectOfSize: CGSizeMake(100,100))

// change to new size - shape will now be 150 x 150
shapeNodeName = SKShapeNode(rectOfSize: CGSizeMake(150,150))
查看更多
倾城 Initia
3楼-- · 2020-06-22 05:54

The action, resizeToWidth, can be called by an SKSpriteNode.

You can call the action, scaleTo , with SKShapeNode.

查看更多
登录 后发表回答