last day (14 days later) » 

10:09 AM
0
A: Stop function after secods

AlladinianJust to make things clear... The function doesn't 'run' while the layer is emitting, so the real question is "How to stop the emitter ?" and the answer to this is by setting the birthRate of the emitter layer to zero. So just hold a reference (since you don't want to be removed) and set the bir...

 
I tried your code but it did not work....:/
 
@risa8 Can you please edit your question and share your code? Because I did try my answer before posting and is working fine...
 
Ok give me a second. The error is "Value of CompleteViewController has no member cell2."
 
... so what is cell2? It seems that this problem is unrelated to the specific question...
 
Sorry mistype it is cell
 
10:09 AM
I would gladly help you with that, but you have to post some real code in your question. Just hit Edit and include the code as it is now if possible
Hi, are you there?
 
Yes I updated the real code :)
 
Hi
Ok I can see
so the problem is that you try to set the birthrate on your cells
what you should do, is declare some ivars for your Emitters
or a list of emitters
like var emitters = [CAEmitterLayer]()
then you append each emitter into the list
like:
let emitter = Emitter.get(with: #imageLiteral(resourceName: "ichi"))
emitters.append(emitter)
and then, inside your asyncAfter...
you do
for emitter in emitters { emitter.birthRate = 0 }
does this makes sense?
 
Yes it makes sense:) i am writing the code.
 
nice, let me know if you need something, I'll hang in this chat a little longer
 
Thak you!
Hi
I have add following code to CompleteViewController
var emitters = CAEmitterLayer()
let emitter = Emitter.get(with: #imageLiteral(resourceName: "ichi"))
let emitter2 = Emitter.get(with: #imageLiteral(resourceName: "ni"))
let emitter3 = Emitter.get(with: #imageLiteral(resourceName: "san"))
let emitter4 = Emitter.get(with: #imageLiteral(resourceName: "yon"))

// emitters.append(emitter)
var cells = [CAEmitterCell]()
let cell = CAEmitterCell()
let cell2 = CAEmitterCell()
let cell3 = CAEmitterCell()
let cell4 = CAEmitterCell()
There is no error but emitter does not stop... :/
 
10:35 AM
ok I see a few problems in your code... Would it be a problem to send me your controller file in order to have a try on it?
 
Sure how can i send the file?
 
there is an 'upload' button next to 'send' -->
 
10:48 AM
nevermind, I will send you a working sample
 
Sorry when I try to send it gets errors because whole code is huge..
I am trying to edit it
 
no worries
just download the file I sent you
I have tested it, it should be fine
 
Thank you so much...
 
You're welcome. That's what this community is for
 
11:10 AM
It worked perfectly. Thank you for your kind help :)
I hope to help the community one day.
 
Awesome :)
 

last day (14 days later) »