If you want to separate the iterations you have to maintain separate lists (or Arrays) for different classes yourself. And whenever you create body, you can add the reference to that body in respective lists. For example you have lists like.
Up vote 0 down vote favorite share g+ share fb share tw.
Im programming for the iphone using box2d and cocos2d frameworks. Currently, I have 3 Classes all subclasses of CCSprite. They are: DynamicBlock1, DynamicBlock2 and DynamicEgg1 Basically my problem is that I want to separate the iterations in the tick method so that I can iterate certain classes and not others.
Currently the Tick (iteration) method is split into two parts, isMoving == YES/NO.. This switches the iteration between b2body(Master)-sprite(Slave) and b2body(Slave)-sprite(Master). This way I can delegate who controls who. And it works quite well.
Once again, the problem is that this code below, will iterate over ALL my bodies from all my classes in GetBodyList(). When I just want the iteration to occur to the one class (DynamicBlock1)... Is there a way to do this? To isolate the iterations?
A thousand thank you's Oliver -(void) tick:(ccTime)dt { int32 velocityIterations = 8; int32 positionIterations = 1; world->Step(dt, velocityIterations, positionIterations); for (b2Body* be = world->GetBodyList(); b; be = b->GetNext()) { DynamicBlock1 *block1 = (DynamicBlock1*)b->GetUserData(); if (block1. IsMoving == NO){ block1. Position = CGPointMake( b->GetPosition().
X * PTM_RATIO, b->GetPosition(). Y * PTM_RATIO); block1. Rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()); } if (block1.
IsMoving == YES){ b2Vec2 b2Position = b2Vec2(block1.position. X/PTM_RATIO, block1.position. Y/PTM_RATIO); float32 b2Angle = -1 * CC_DEGREES_TO_RADIANS(block1.
Rotation); b->SetTransform(b2Position,b2Angle); } } } c++ objective-c xcode cocos2d box2d link|improve this question asked Mar 23 '11 at 12:20Oliver40719 83% accept rate.
If you want to separate the iterations you have to maintain separate lists (or Arrays) for different classes yourself. And whenever you create body, you can add the reference to that body in respective lists. For example you have lists like NSArray *DynamicBlocksList; NSArray *DynamicEgssList; Now when you create DynamicBlock body, you also add it in "DynamicBlocksList" and when this body is destroyed, you can remove it from the list.
And in Tick() function you can iterate only required list. But in my personal opinion this may not be a very good idea to do this. Its fine to iterate over "world->GetBodyList()" and then you can delegate the processing of different bodies to different classes or functions.
Thanks, that pretty much what I decided to do. – Oliver Mar 24 '11 at 11:01.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.