First, the status quo
Now live class, video player and so on basically have the bomb screen mode.
In order to maintain performance and memory controllable, it is basic to generate a pool at initialization (pool capacity is set), that is, using the reuse mechanism (you can imagine the UITableView reuse mechanism, but this pool and tableview mechanism slightly different). Each generated a barrage into the pool, when reaching the pool maximum capacity, you have to wait, waiting for a bomb in the pool to fly out of the screen to complete the task, and then take the queue of the barrage task, assigned to the projectile a new. When the volume of the screen is particularly large, the server or client will have to choose the task of the queue, because you have no way to deal with so many of the barrage. The delay is too long and the experience will be too bad.
Ii. actual Demand issues
At this time your products must be out of work, why not more display point barrage? No matter what you overlap or what, you have to put the screen to the fullest possible display, so as to show this room or video popularity, is the bomb screen effect! (The programmer can only say that my concubine can't do it!) A lot of barrage, it will be jammed! )
In order to maintain the frame rate, the maximum number of barrage is bound to have an upper limit, how to break the ceiling without affecting performance?
Landlord whim, for what particle effect so dazzling, so many particles can be properly displayed without affecting performance?
Can we treat the barrage as a particle?
Three, the solution design
We need to know two classes, one is Caemitterlayer, the other is Caemittercell.
What we need to do:
1. Convert the background and text of the barrage into cgimageref assignment to Caemittercell Contents
2. Timer, change Caemitterlayer emittercells particle Source (bullet screen)
3. Coordinate the life cycle, caemittercell-> birthrate, caemittercell->lifetime , caemittercell->lifetimerange, and your timer refresh cycle.
4.CAEmitterCell Some of the spawn locations to look for themselves.
Summary: the landlord tested the next 1000 rounds per second (pure random digital bomb screen, equipment iphone 6 16G), the proper 60fps does not drop frame, but the switch interface will be a little bit of lag, can be accepted (can be closed before leaving the screen or other optimization).
There is a need for a friend to try, anyway I can not use. (However, the disadvantage of the particle barrage is that the bouncing out of the barrage, such as spilled water, is not controllable, can not monitor collision click events)
IOS large volume barrage (bullet screen)