How to create a Gradient in Spritekit?

前端 未结 4 724
长发绾君心
长发绾君心 2021-02-08 22:35

Is there any possible way to create a gradient filled box in SpriteKit? I\'ve tried filling a shape node with that but it notes that only solid colors work with skshapenode.

4条回答
  •  无人及你
    2021-02-08 22:50

    I don't think this is possible with current SKShapeNode, which barely handles its basic features currently. A good approach if you don't want to use pre-existing sprite gradient images would be to create an SKTexture from applying a CIFilter (like maybe CILinearGradient in this case) to a basic box image, and then create the SKSpriteNode from that SKTexture.

提交回复
热议问题