Last Friday and Saturday I went to the One More Thing Conference in Melbourne. The conference targeted being indie and becoming successful as an indie, which contrasts with the Swipe conference, which is more about specific design or development stuff.
The conference was well organised and run, with fantastic speakers, all of whom came from overseas.
I went to the mini-conf “code” and the main conference the next day (there was also a design mini-conf on Friday morning).
All comments below are coloured by my particular/peculiar viewpoints, and I’ve kept one or two great insights to myself, to think further on.
This is part six of a series on making iOS games.
With hundreds or thousands of particles on the screen, a particle effect is a great way to bring your frame rate precipitously down. There are so many different aspects of the particle engine that can effect performance.
Michael Daley has a whole chapter on this (see resources below – and he is right – its a big time sink).
I started off just extending the normal sprite classes which I created in the game template (which I talked about in the last post in this series), and then gradually moved to including more and more optimisations.
I (like everyone else) pre-create a number of particle engines, so that the expensive operation of memory allocation does not have to happen during the game, more as a precaution, than something I’ve rigorously tested with the profiler in Instruments.
Point sprites are a common thing to use with particles effects, to try an optimise things. With each particle as a point sprite you dont need to pass as much data to OpenGL, theoretically 1/6 of the data, since you are only passing one vertex per sprite, not two triangles.
In order to use point sprites you need to set the point size in the traditional vertex shader. I couldn’t see any docs on how to manage the point size in the GLKit base effect – this would be something like:
in the normal OpenGL ES 2.0 vertex shader.
So I experimented a bit and created a particle engine using the usual OpenGL ES 2.0 vertex and fragment shaders to do point sprites, and the same (as the game template in the previous post) GLKit base effect for the other sprites such as the player, background tiles etc.