cocos2d-x wp8开发手记-1-新闻详情

cocos2d-x wp8开发手记-1


发布时间:2016-03-22责任编辑:朱明 浏览:1612


开发环境搭建

软硬件需求:

1、操作系统是windows8及以上版本

2、CUP64位且支持虚拟化

 

步骤:

1、安装windows8操作系统

2、安装VS2013

 

cocos2d-x版本选择

cocos2d-x2.2.3及以上版本

cocos2d-x3.0及以上版本

 

运行demo

创建工程,进入工程目录下,proj.wp8-xaml文件夹。打开.sln,编译运行。

喵玩-1.png

 

常见问题

设置横竖屏失败

进入cocos2dplatformwp8目录下,CCGLView.cpp

GLView::GLView()

    : _frameZoomFactor(1.0f)

    , _supportTouch(true)

    , _isRetina(false)

    , m_lastPointValid(false)

    , m_running(false)

    , m_initialized(false)

    , m_windowClosed(false)

    , m_windowVisible(true)

    , m_width(0)

    , m_height(0)

    , m_eglDisplay(nullptr)

    , m_eglContext(nullptr)

    , m_eglSurface(nullptr)

    , m_delegate(nullptr)

    , m_messageBoxDelegate(nullptr)

, m_orientation(DisplayOrientations::Landscape)

DisplayOrientations::Landscape此处设置横竖屏。

 

切屏后出现闪退

通常是因为找不到texturecache中的资源。Debug模式下输出错误信息,查看找不到的资源。在

void AppDelegate::applicationWillEnterForeground() {

    Director::getInstance()->startAnimation();

   

    // if you use SimpleAudioEngine, it must resume here

     CocosDenshion::SimpleAudioEngine::getInstance()->resumeBackgroundMusic();

}

中将找不到的资源重新加载。

 

点返回键游戏闪退

在mainpage.cs中找到OnBackKeyPress函数。

重写该函数:

protected override void OnBackKeyPress(CancelEventArgs e)

{

            e.Cancel = true;

            if (MessageBox.Show("是否退出游戏","退出",MessageBoxButton.OKCancel) == MessageBoxResult.OK)

            {

                m_d3dInterop.OnBackKeyPress();

            }           

 }



喵玩工作室