Reputation: 1624
End Goal: generate particles within an area (got that bit) that all accelerate to a point.
If I knew the position of the particle, everything would be fine, but I generate the particles with a particleRange, meaning I don't know the exact location of each particle.
Is there any way to retrieve the location of each particle after it has been generated?
My current plan is to attach a particleAction with a block that can read the final rendered position.
Upvotes: 0
Views: 555
Reputation: 1624
Whilst the particle does not accelerate (I can live without that) I have been able to get them to all go to the desired location using:
emitterNode.particleAction = [SKAction moveTo:location duration:1];
Which is as close as it's going to get.
Upvotes: 0
Reputation: 2435
No, as it says in the SKEmitterNode
documentation, particles are objects privately owned by Sprite Kit, you cannot access them after they're generated, so the current position of each separate particle will not be retrievable. Thus, your plan of reading the position in the particle action block won't work, as the actions are only executed by new particles, which are not subject to manipulation/access as separate nodes.
You're left with setting their behaviour in advance using particleRange
or particleAction
. However, the SKCropNode
class might be the way out - you can try masking the particle emitter, so that particles outside of your desired area are not rendered.
Upvotes: 1