简体   繁体   English

我可以使用SpriteKit在iOS上从非矩形区域发射粒子吗?

[英]Can I emit particles on iOS with SpriteKit from a non-rectangular region?

I have a complex region (not a rectangle) on the screen from which I'd like to emit particles. 我在屏幕上有一个复杂的区域(不是矩形),我想从该区域发射粒子。 Is this possible? 这可能吗?

An emitter creates particles at a given point. 发射器在给定点创建粒子。 You can influence the start position X and Y variance, allowing particles to be emitted at random location within a rectangle. 您可以影响起始位置X和Y的方差,从而允许在矩形内的任意位置发射粒子。 Emitting particles limited to a non-rectangular area is not possible. 不可能将粒子发射到非矩形区域。

However you could use multiple emitters to approximate the shape or possibly a crop node to prevent particles from appearing outside of the shape. 但是,您可以使用多个发射器来近似形状,也可以使用裁剪节点来防止粒子出现在形状外部。

Lastly and quite possibly there might still be a way, although costly. 最后而且很可能仍然有一种方法,尽管成本很高。 If you apply an action that runs on each particle you could determine if that particle is within the shape and possibly alter its position or remove it if it is outside. 如果对每个粒子应用一个动作,则可以确定该粒子是否在形状内,并可能更改其位置,或者在其外部将其删除。 I say possibly because I don't know what influence one can have over individual particles using particle actions but it's worth giving it a try. 我之所以说是因为我不知道使用粒子动作会对单个粒子产生何种影响,但是值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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