The specific reason I'm asking is that I implemented a scrolling mechanism based on the movement of one body, and took into account the PTM_RATIO basically at every step. But now, when moving into the RUBEScene paradigm I'm not sure how to resolve this.
The scrolling I'm doing in my previous layer goes like this:
In tick:
Code: Select all
if(traveler != NULL) { // traveler is the body that, when moving, the layer scrolls with it
[self setScrollingPoint:traveler->GetPosition()];
[self setPosition:CGPointMake(difference.x*PTM_RATIO, difference.y*PTM_RATIO)];
}
Code: Select all
- (void) setScrollingPoint:(b2Vec2)vec {
CGSize screen = [[CCDirector sharedDirector] winSize];
float x = vec.x * PTM_RATIO;
float y = vec.y * PTM_RATIO;
CGPoint goodPoint = ccp(x,y);
CGPoint centerOfScreen = ccp(screen.width/2, screen.height/2);
CGPoint diff = ccpSub(centerOfScreen, goodPoint);
difference = CGPointMake(diff.x/*/PTM_RATIO*/, 0); // difference is an instance variable, used for offsetting the background position, and the mouseJoint target.
}