Resizing a SKShapeNode

我怕爱的太早我们不能终老 提交于 2019-12-06 08:25:31

问题


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


回答1:


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

You can call the action, scaleTo , with SKShapeNode.




回答2:


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))


来源:https://stackoverflow.com/questions/27931376/resizing-a-skshapenode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!