c++ - Cocos2dx v.3.0 Portrait Mode -


hey developing cocos2dx application xcode , iphone 5c , looking change coordinate system portrait. looked @ these directions http://www.cocos2d-x.org/wiki/device_orientation. according direction, need change couple of methods in rootviewcontroller before cocos magic, ios has handled rotating container.

now applicable methods of rootviewcontroller.mm follows. builds , runs.

#ifdef __iphone_6_0 - (nsuinteger) supportedinterfaceorientations{     return uiinterfaceorientationmaskportrait; } #endif  - (bool) shouldautorotate {     return yes; }  - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation {     return uiinterfaceorientationisportrait ( interfaceorientation ); }  - (void)didrotatefrominterfaceorientation:(uiinterfaceorientation)frominterfaceorientation {     [super didrotatefrominterfaceorientation:frominterfaceorientation];      auto glview = cocos2d::director::getinstance()->getopenglview();      if (glview)     {         cceaglview *eaglview = (__bridge cceaglview *)glview->geteaglview();          if (eaglview)         {             cgsize s = cgsizemake([eaglview getwidth], [eaglview getheight]);             cocos2d::application::getinstance()->applicationscreensizechanged((int) s.width, (int) s.height);         }     } } @end 

the code init() method of level looks this

bool level1::init() {     //////////////////////////////     // 1. super init first     if ( !scene::init() )     {         return false;     }      auto visiblesize = director::getinstance()->getvisiblesize();     vec2 origin = director::getinstance()->getvisibleorigin();      for(int i= 0; < max_touches; ++i) {         labeltouchlocations[i] = label::createwithsystemfont("", "arial", 42);         labeltouchlocations[i]->setvisible(false);         this->addchild(labeltouchlocations[i]);     }      auto eventlistener = eventlistenertouchallatonce::create();      //  create eventlistener handle multiple touches, using lambda, cause baby, it's c++11     eventlistener->ontouchesbegan = [=](const std::vector<touch*>&touches, event* event){          // clear visible touches in case there less fingers touching last time         std::for_each(labeltouchlocations,labeltouchlocations+max_touches,[](label* touchlabel){             touchlabel->setvisible(false);         });          // each touch in touches vector, set label display @ it's location , make visible         for(int = 0; < touches.size(); ++i){             labeltouchlocations[i]->setposition(touches[i]->getlocation());             labeltouchlocations[i]->setvisible(true);             labeltouchlocations[i]->setstring("touched");             std::cout << "(" << touches[i]->getlocation().x << "," << touches[i]->getlocation().y << ")" << std::endl;          }     };      _eventdispatcher->addeventlistenerwithscenegraphpriority(eventlistener, this);      return true; } 

when touch point @ lowest left part of iphone, x coordinate of touch point print out 150. y coordinate 0, expected. why x coordinate not zero? there missing in creation of scene? believe made changes cocos documentation requires. docs out of date?

the coordinate system not start @ (0,0) @ bottom left suggested documentation. however, there simple methods can used origin , size of container included in default scene.

auto visiblesize = director::getinstance()->getvisiblesize(); vec2 origin = director::getinstance()->getvisibleorigin(); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -