Hey all,
So I know this is probably easy to do but i just cant figure it out. In my game I update all of my sprites and chipmunk bodies. They are all named the same except for a number. For example I have:
player1Sprite
player2Sprite...
enemy1Sprite
enemy2Sprite...
and then i have the chipmunk bodies which are:
player1Body
player2Body...
enemy1Body
enemy2Body...
Right now im going through and doing:
player1Body->p = player1Sprite.position;
player2Body->p = player2Sprite.position;
cpBodySetAngle(player1Body, CC_DEGREES_TO_RADIANS(-player1Sprite.rotation));
cpBodySetAngle(player2Body, CC_DEGREES_TO_RADIANS(-player2Sprite.rotation));
enemy1Body->p = enemy1Sprite.position;
enemy2Body->p = enemy2Sprite.position;
cpBodySetAngle(enemy1Body, CC_DEGREES_TO_RADIANS(-enemy1Sprite.rotation));
cpBodySetAngle(enemy1Body, CC_DEGREES_TO_RADIANS(-enemy2Sprite.rotation));
and
[player1Sprite setPosition:ccp(player1Body->p.x, player1Body->p.y)];
[player2Sprite setPosition:ccp(player2Body->p.x, player2Body->p.y)];
[player1Sprite setRotation: (float) CC_RADIANS_TO_DEGREES( -player1Body->a )];
[player2Sprite setRotation: (float) CC_RADIANS_TO_DEGREES( -player2Body->a )];
[enemy1Sprite setPosition:ccp(enemy1Body->p.x, enemy1Body->p.y)];
[enemy2Sprite setPosition:ccp(enemy2Body->p.x, enemy2Body->p.y)];
[enemy1Sprite setRotation: (float) CC_RADIANS_TO_DEGREES( -enemy1Body->a )];
[enemy2Sprite setRotation: (float) CC_RADIANS_TO_DEGREES( -enemy2Body->a )];
Now my question is can I somehow make the number an int and then create a loop that just adds one to the number?
Thanks
-Lars