[英]How to make animated spritekit background?
我想在游戏中制作动画空间背景,我尝试在spritekit“星星节点”上使用节点,但由于星星数量过多,游戏变得迟钝,是否有任何程序或方法可以制作高清动画背景?
You just need one node for the background ya know. 您只需要一个节点即可知道背景。
Basically, you create each frame of your animated background as images. 基本上,您将动画背景的每一帧都创建为图像。 You can put these images into an image atlas in the asset catalogue. 您可以将这些图像放入资产目录中的图像集。
Now, you can add a single sprite node that covers the whole scene as the "background". 现在,您可以添加一个覆盖整个场景的单个Sprite节点作为“背景”。 You just set the texture of the sprite node to the first frame of your animation. 您只需将精灵节点的纹理设置为动画的第一帧。
Then, in didMoveToView
or some methods like that, 然后,在didMoveToView
或类似的方法中,
SKTextureAtlas
object 将图像图集作为SKTextureAtlas
对象获取 textureNamed
and put each of them into an [SKTexture]
使用textureNamed
获取地图集中的每个纹理,并将每个纹理放入[SKTexture]
- --
yourBackgroundSprite.runAction(SKAction.repeatForever(
SKAction.animateWithtextures(theTexturesYouCreatedInStep2, timePerFrame: 30)
))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.