简体   繁体   中英

Can I change the size of a sprite in XCode? (Swift)

我是 SpriteKit 的新手,我想知道是否有一种方法可以在不改变图像分辨率的情况下缩小 XCode 中 Sprite 的大小。

An SKSpriteNode has the property size which you can specify. If you want to scale a sprite, however, the easiest way would be to use the method setScale . It takes a parameter of type float and it scales the image by the specified degree. For example, if you had a sprite:

var mySprite = SKSpriteNode(imageNamed:"myImage.png")

you could then scale the sprite to be twice its original size:

mySprite.setScale(2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM