Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Universal Windows App即通用窗口应用是微软2014年推出的最重要的技术之一。在全新8.1的Windows XAML app framework下,使用统一的 Windows 运行时和 Visual Studio IDE 同时针对所有Windows 设备进行开发(包括Windows Phone),真正做到一套代码全平台共用,极大地提高了开发效率,节省开发成本。进一步的知识大家可以参考如下链接:
- https://dev.windows.com/zh-cn/develop/building-universal-windows-apps/
- https://www.cnblogs.com/sonic1abc/p/3772693.html
Cocos2dx的最新版本提供了对于Universal Windows App(以下简称UAP)的支持。针对这个全新的开发模式,很多开发者还不是太熟悉。所以本文罗列了一些基本信息,帮助大家快速过渡。
1. Cocos2dx支持UAP的版本:
- 3.x的话:需要3.3版本
- 2.x的话:官网版本尚不支持UAP,需要MSOpenTech分支的2.2.5版本
2.获取支持UAP的Cocos2dx代码:
- 3.x的话:直接从官网下载3.3版本即可:https://www.cocos2d-x.org/download
- 2.x的话:从MSOpenTech的GitHub上获取,具体步骤如下所示:
cd cocos2d-x |
git checkout v2-universal |
git submodule update –init |
download-deps.py (should be downloading from msopentech and not cocos2d) |
3.系统要求:
安装 Visual Studio 2013 Update 4
4.创建支持UAP工程:
方法和以前完全相同,不需要特别的步骤
3.x版本:
Cocos new -l cpp -d D:\ MyGame MyGame
2.x版本:
cd tools\project-creator
create_project.py -project MyGame -package com.foo.bar -language cpp
5.构建UAP工程:
在proj.win8.1-universal目录下打开“xxx.sln”工程文件,根据需要的环境把XXX.Windows (Windows 8.1) 或者XXX.WindowsPhone (Windows Phone8.1) 设置为启动工程,运行即可
6.常见的一些问题:
问题1 |
问:编译后会有如下很多LinkError,如何解决?
2>XamlTypeInfo.g.obj : error LNK2001: 无法解析的外部符号 "public: __cdeclcocos2d::KeyBoardWinRT::~KeyBoardWinRT(void)" (??1KeyBoardWinRT\@cocos2d\@\@Q$AAA\@XZ)2>OpenGLES.obj : error LNK2001: 无法解析的外部符号 "public: __cdeclcocos2d::KeyBoardWinRT::~KeyBoardWinRT(void)" (??1KeyBoardWinRT\@cocos2d\@\@Q$AAA\@XZ) |
答:必须安装Visual Studio 2013 update 4 |
|
问题2 |
问:UAP模式如何增加回退键处理? |
答:可以按以下步骤增加HardwareButtons::BackPressed处理: 1. 在App.xaml.cpp中加入头文件: usingnamespaceWindows::Phone::UI::Input;
2. 在App()中加入BackPressed处理: App::App() { InitializeComponent(); Suspending += refnewSuspendingEventHandler(this, &App::OnSuspending); Resuming += refnewEventHandler<Object^>(this, &App::OnResuming); HardwareButtons::BackPressed += refnewEventHandler<BackPressedEventArgs^>(this, &App::HardwareButtons_BackPressed); }
3.在App.xaml.h中加入HardwareButtons_BackPressed() 声明: voidHardwareButtons_BackPressed(Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ e);
4.在App.xaml.cpp中加入HardwareButtons_BackPressed() 定义(函数内部可以根据自己的要求修改): void App::HardwareButtons_BackPressed(Object^ sender, BackPressedEventArgs^ e) { Frame^ rootFrame = dynamic_cast<Frame^>(Window::Current->Content); if (rootFrame != nullptr&&rootFrame->CanGoBack) { rootFrame->GoBack(); e->Handled = true; } } |
|
问题3 |
问:为什么UAP模式没有Master版本? |
答:目前只提供Release版本 |
|
问题4 |
问:如何发布UAP的应用? |
答:使用VS的Store菜单下的商店功能 |
谢谢!
梅颖广
Comments
Anonymous
March 30, 2015
我的程序在发布认证时 ,一直提示windows api无法通过测试,此应用程序类型不支持kernel32 API FormatMessageA, libcurl.dll使用到了此api,请问是什么原因啊Anonymous
July 21, 2015
using namespace Windows::Phone::UI::Input;命名空间报错,啥原因?