how to make particles appear after collision

98 views Asked by At

im a 12 year old self taught developer developer working on a game in which particles would make the game amazing. Though i already have particles i would like to know how to add particles after a collision. Though many actions already happen i would like to add another, here is my code.

(void)didEndContact:(SKPhysicsContact *)contact {

if (contact.bodyA.categoryBitMask == rectangulo && contact.bodyB.categoryBitMask == circulo) {

    count.text = [NSString stringWithFormat:@"%ld points", ++collisionsCount];

    [contact.bodyB.node removeFromParent];

    MyParticlez = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle]
                                                              pathForResource:@"MyParticlez" ofType:@"sks"]];}}

i don't know whether i should add a certain CGPoint or an addChild or something else to make the particles appear over the block "rectangulo"

thank you, <3

1

There are 1 answers

0
Good Doug On BEST ANSWER

You've got a good start, you've created the particles, but now you need to add the particles to the scene in the same way you've added the other sprites to the scene. So, you'll call:

MyParticlez.position = contact.bodyB.node.position
myScene.addChild(MyParticlez)

You may want to have a way to remove the particle emitter from the scene when they are finished.