标签:http io ar os 使用 sp on bs ad
cocos2dx 3.3 操作节点相机:
CCSize winSize=CCDirector::sharedDirector()->getWinSize();
Camera* camera=Camera::create();
camera->setCameraFlag(CameraFlag::USER1);
this->addChild(camera);
sprite->setCameraMask(2); //CameraFlag::USER1就等于2
Vec3 eyePosOld=camera->getPosition3D();
Vec3 eyePos=Vec3(0,0,eyePosOld.z);
camera->setPosition3D(eyePos);
camera->lookAt(Vec3(eyePos.x,eyePos.y,0), Vec3(0, 1, 0));//如果up参数传Vec3(sqrt(2)/2,sqrt(2)/2,0)可将头歪45度
注意camera->lookAt必须在camera->setPostion3D之后,因为lookAt中有一句
Vec3::subtract(this->getPosition3D(), lookAtPos, &zaxis);//即相减得出相机空间z轴
使用了getPosition3D。所以必须先设定对position3D再调lookAt才能得到正确结果。
参考:
http://www.cocos2d-x.org/news/344
cocos2d_tests - Camera3DTest.cpp
标签:http io ar os 使用 sp on bs ad
原文地址:http://www.cnblogs.com/wantnon/p/4158135.html