Simple butterfly simulation based on bezier curve
I’ve been meaning to warm up my iOS development for awhile and finally got a chance to get back into it.
A new version of the cocos2d framework has been released since I developed “Around the world in 5 differences.” So I figured the best way to get the hang of it, is to dive right back in. I don’t want to turn this post into a super technical one so I’ll just highlight what I ended up making:
A butterfly simulation based on bezier curves:
- Wing animation is based on simple sprite manipulation using CCActions
- Each butterfly determines a flight path using a randomly generated bezier curve. Each curve is based on a start point, two control points and an end position. like this
- Once the flight path is selected, a random time interval is picked at which the butterfly plans to complete its flight.
- After flight is completed, each butterfly ‘chills’ for a randomly generated amount of time, determines a new path and flies off once again.
The implementaion of the simulation is rather simple. There are no specific swarm rules and the butterflies do not interact with each other. Perhaps that’s something that can be added in future iteration.
For anyone interested in the code, they can get it from here: (I believe all you need is a mac computer and xcode)