Performance best practices

Topics: Developer Forum, User Forum
Dec 30, 2011 at 4:14 AM


I am trying to make a simple wp7 game where a bird has to avoid 'obstacles'. Each obstacle consists of 10 to 15 independent bodies, and at any given time I have up to 3 obstacles on screen. I have created a Pool of around 60 bodies (using BodyFactory.CreateCompoundPolygon) and I recycle through them. 

On start up, I set all bodies in the Pool to have body.Enabled = false. On initializing an obstacle, for each body I set body.Enabled = true, and once the obstacle is off screen, I reset to body.Enabled = false. (All body.Awake = false on initialize and reset.) I have very little other game logic, and I've tried settings low values for VelocityIterations and PositionIterations, but I am still seeing a low frame rate.

I noticed that setting body.Enabled has some overhead, so should I avoid this altogether (keep every body in the pool enabled whether it is on screen or not) and just work with body.Awake?

I'm fairly new to farseer, so I might be off track completely, and any help or advice would be great.