Cocos2d 在 mac 10.13 和 xcode 10.1 组合下,移动才显示的bugfix

Mac和Xcode的组合bug,在最新的Mac更新中应该已解决。如果依然存在问题,可以用下面的方式修正。

在 CCApplication-mac.mm 中做如下修正。

// 添加的头文件
#ifdef __APPLE__
#include "platform/desktop/CCGLViewImpl-desktop.h"
#endif

    while (!glview->windowShouldClose())
    {
        lastTime = getCurrentMillSecond();
        
        director->mainLoop();
        glview->pollEvents();

        curTime = getCurrentMillSecond();
        if (curTime - lastTime < _animationInterval)
        {
            usleep(static_cast<useconds_t>((_animationInterval - curTime + lastTime)*1000));
        }
        
#ifdef __APPLE__  // 添加的内容
        static bool macMoved = false;
        if(!macMoved) {
            int x, y;
            GLViewImpl *view = (GLViewImpl *)glview;
            glfwGetWindowPos(view->getWindow(), &x, &y);
            glfwSetWindowPos(view->getWindow(), ++x, y);
            macMoved = true;
        }
#endif
    }

标签: Cocos2d-x

添加新评论