Store and create game objects at positions along terrain

Posted by Alex on Game Development See other posts from Game Development or by Alex
Published on 2012-06-11T07:47:31Z Indexed on 2012/06/11 10:48 UTC
Read the original article Hit count: 267

I have a circular character that rolls down terrain like that shown in the picture below.

enter image description here

The terrain is created from an array holding 1000 points. The ground is drawn one screen width infront and one screen width behind. So as the character moves, edges are created infront and edges are removed behind.

My problem is, I want to create box2d bodies at certain locations along the path and need a way to store these creator methods or objects.

I need some way to store a position at which they are created and some pointer to a function to create them, once the character is in range. I guess this would be an array of some sort that is checked each time the ground is updated and then if in range, the function is executed and removed from the array. But I'm not sure if its even possible to store pointers to functions with parameters included... any help is much appreciated!

© Game Development or respective owner

Related posts about box2d

Related posts about cocos2d-iphone