I’m doing up the rain effect today.  I’m hoping to get this game to run smooth on older devices, so I wanted to make the rain easily modifyable.  I’m not sure how many sprites Cocos2d can push at a time on, say, a 2nd gen iPod Touch…I’m sure I don’t have anything to worry about, I’m not making Smash TV here or anything, there’s basically a ninja, some stuff being thrown at him, and a couple background images, but I always like to stay on the safe side because it’s way nicer to find out you have excess memory at the end of the project than find out you don’t have enough haha

My early days in the game industry were spent working on cell phone games where we’d make an S60 version, which would be something like 260×320 and let us do badass full screen art and everything.  But we’d have to then make an S40 version, which was like 120×208 and way less powerful so I’d have to replace artsy backgrounds with color bar gradients and stuff.  We also had to do a third version…S30 maybe?  Can’t quite remember.  But it was a piece of crap.  Like a 128×128 screen and super weak power, where we could do the absolute most minimal stuff.  So I got in the habit of thinking in terms of “how can I strip this down if I have to”?  I found it was easier to just work efficiently from the start.

So this is how I usually do rain…I stole this method from some RPG on some console back in the day.  I have a raindrop graphic and a water splat animation:

The actual drops in-game are super long, but having a giant graphic like that is a waste so I just make a shorter version and stretch it vertically in-game…the above is for the 1024×768 iPad.  I actually had a much shorter drop but I would have had to scale it like 2000% and I get nervous about how the game’s going to handle a bunch of 2000% scaled images, so I like to size it so that when I stretch it out I only have to stretch it between 200% – 500%.  The rain splat is just a quick doodle of a drop blipping into some ripples.

Now I combine these by showing the raindrop randomly all over the screen, I also show the rainsplat randomly around the screen.  So the drops aren’t ACTUALLY hitting the spots where the rain splats appear, but when you look at them together the overall effect is that rain is pouring.  If I had a splat where each drop lands I’d have to figure out the depth/height of objects, which surfaces can get a drop, if there was 50 rain drops I’d need 50 splats as well, etc.  With this method I can have 50 rain drops but only 10 splats and get the same overall effect.  In the end I have about 11 drops shown at a time and maybe 5 splats shown at a time.  The layers look like so:

I figure if I run into slow-down on older devices I can just remove a few raindrops or splats until it runs smooth.

I like this method for making rain in an RPG because you can specify in your tiles which ones should get rainsplats and which ones shouldn’t (so you’d have the roof tiles on a house splattable but the wall tiles wouldn’t be).

- Quickdraw

« »