Hello. Why everybody doesn’t like camera moving and prefer layers moving instead?
So I have a debug draw layer and the main layer with CCSprites. I don’t think that moving both layers together is a good idea, isn’t it? So I wrote a helper-layer with the code:
void cc::Camera::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
CCSetIterator it = pTouches->begin();
CCTouch* touch = (CCTouch*)(*it);
CCPoint prev = touch->getPreviousLocation();
CCPoint now = touch->getLocation();
CCPoint movement = ccpSub(prev, now);
float x, y, z;
mCamera->getEyeXYZ(&x, &y, &z);
mCamPos.x += movement.x;
mCamPos.y += movement.y;
mCamera->setCenterXYZ(mCamPos.x, mCamPos.y, 0);
mCamera->setEyeXYZ(mCamPos.x, mCamPos.y, z);
}
Seems that mCamPos is okay after changes but nothing happens in the world. setCenter and setEye doesn’t affect the scene :(. mCamera is the pointer taken from: CCDirector::sharedInstance()->getRunningScene()->getCamera();