First of all, I saw this and found it incredibly helpful:
http://www.cocos2d-iphone.org/forum/topic/5359
I was able to set up a way to display scores by using the ideas presented here. My question is in regards to the way the "_targetsDestroyed" variable was obtained in her case. In other words, how do you keep count on the targets that can then be updated via the _targetsDestroyed variable.
To be more clear, I would like to assign a point value for different sprite types. For example, when a collision occurs between the main sprite and a target, I would like to assign different point values for different target types.
I'm using Chipmunk for collision handling. I thought I could write code in the "static int" collision handler that would assign the point value there ... but so far no success. It doesn't seem to allow me to assign a variable there that can then be passed to my score updater. For example:
cpSpaceAddCollisionHandler(space, TYPE_A, TYPE_B, updateScore, NULL, NULL, NULL, NULL);
And then in "updateScore" do something like:
static int updateScore(cpArbiter *arb, cpSpace *spacepace, void *data){
cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b);
//collision handler code goes here and then ...
//Add score of 5 for Sprite Type A
Code would go here that would then assign the value of 5 for my score updater
return 1;
}
It seems like a simple thing but I'm stuck. Perhaps my thought process isn't working here. Any help would be mucho appreciated!
Thanks in advance!