Cocos2d-x Visual Studio Android Project

In the world of game development , Cocos2d is one of the biggest names out there. The open source Cocos2d framework has been the backbone of a vast number of top selling apps and games, provides support for a number of programming languages, and targets a massive variety of devices. Currently, Cocos2d-x (the C++ version of Cocos2d) provides starter projects for Android targets for Eclipse and Android Studio and starter projects for Win32, Windows 8.1,  and Windows 10 targets for Visual Studio. Starting with Visual Studio 2015,  Visual Studio has added in a wealth of support for C++ projects that target not only Windows platforms but Android and iOS platforms as well. With some new Android support added in Visual Studio Update 2, this seemed like the perfect opportunity to allow Cocos2d-x users a chance to utilize Visual Studio’s  incredible editing, debugging, and deployment support for their Android development work. To this end, we’ve provided a starter project that can be dropped in with the Cocos2d basic template projects to allow for a quick start with Android Cocos2d-x development using Visual Studio. This starter project is intended to work with Cocos2d-x version 3.13.1 and will need manual adjustments to work with other versions of Cocos2s-x (there is an older version that works with 3.12 provided at the bottom of this post).

The first step in this process is to set up a new Cocos2d-x project following the standard pattern.

First off, download the newest version of Cocos2d-x and unzip the file to your convenient location of choice.

Next, take a command prompt and navigate to the Cocos2d-x directory that you unzipped into. From that directory, run setup.py to set up the development environment for Cocos2d-x, making sure that you have python installed on your system first. When the environment is set, the cocos command line tool can be used to create a new empty Cocos2d-x project.

C:>cocos new MyNewGame –l cpp –d projects

This command will create a new game directory called MyNewGame in the projects directory. The –l variable indicates that this is a C++ project that we want created. In this new directory, you will see the see the following directory structure.

This structure breaks down in the following way. The cocos2d directory contains the Cocos2d-x framework code. The engine code, platform- specific code, third party libraries, and things of that nature all go in here. Must of the time you’d hope to not have to change this framework code during development, but the great thing about Cocos2d-x being open source is that all the framework code is right there to debug into and edit if needed. The Classes folder contains the actual user C++ code that contains the code for the game. For the Cocos2d-x example, this is just a super basic scene which puts Hello World text and a static sprite image on a splash screen along with an FPS ticker and a close button. This is the directory where the user is expected to add and work with their game code. The Resources directory contains the various resources that will be a part of the game. Images, resources, music files, models, and all the like go here. And finally we have all the proj.* directories. These directories contain project files for targeting the various platforms that Cocos2d-x supports. These project have only a small amount of platform or  build specific files in them. Most of what these project files do is to reference the platform code in the cocos2d directory, the shared game code in the Classes directory, and the shared game assets in the Resources directory. The nice thing about this layout is that you can switch between various build tools and targets while maintaining the same game code and assets.

At this point we want to add in our Android targeting Visual Studio project to this layout. This file can be downloaded below:

proj.visualstudio (Cocos2d-x 3.13.1)

Move the proj.visualstudio.zip file from where it was downloaded into the main project directory and unzip it side by side with the other project types. Make sure that the solution is located in a proj.visualstudio directory directly under your main game directory. You don’t want the duplicate of the project folder name as this will mess up relative paths for the project so make sure that the Cocos2d.sln file is located under project\MyNewGame\proj.visualstudio.

Since we are just unzipping this side by side, we don’t participate in the template project renaming that the cocos command line does for the other project types. As a result, the solution and project files have more general names (Cocos2d.sln instead of MyNewGame.sln), and you’ll have to rename them manually to have them match up. Opening Cocos2d.sln will open up the project in Visual Studio 2015 Update 2. If Update 2 is not installed, then one of the projects will not load, so just right click the project and follow the prompts to update Visual Studio with the needed project types.

In this solution (I’ve expanded out a few folders for illustration) we have a Visual Studio Android ANT project called Cocos2d. This project contains links to the java platform code in the cocos2d directory as well as to the assets in the Resources directory that need to be included in the apk. The only non-shared code under the src directory is the org.cocos2dx.cpp\AppActivity.java class which extends Cocos2dxActivity and gets the engine up and running on the device. The Cocos2d java project references a Cocos2dcpp shared object project also included in this solution. In the jni directory of this project resides the project- specific main.cpp/h as well as linked files to the AppDelegate and HelloWorldScene files in the project  shared Classes directory. In the cocos directory are links to all the cocos2d C++ framework code from the shared cocos2d directory. At this point you can build your project and deploy it to the device of your choice with Visual Studio debugging support.

cpp-test project screenshots:

This version of proj.visualstudio works with Cocos version 3.12.

时间: 2024-07-31 04:50:10

Cocos2d-x Visual Studio Android Project的相关文章

Visual Studio Set Project Environment Variables

Visual Studio Set Project Environment Variables eryar@163.com In Visual Studio you can specify changes to environment variables in the project settings. Open your project, go to Project -> Properties... Under Configuration Properties -> Debugging, e

给开心的:Visual Studio .NET Custom Wizards

visual Visual Studio .NET supports a number of built in project types and wizards that generate skeleton projects and solutions depending on the type of application the developer intend to build. These project templates are an excellent way to automa

详解Visual Studio 2010中的扩展管理器

扩展能够为核心应用程序提供附加的功能或者自定义设置.在很多应用程序中这都是很流行的,包括流行的web浏览器IE和Firefox.微软的Office.媒体播放器.Photoshop.Eclipse.Visual Studio等等.其中有些可能比较新奇,而针对开发工具--像Eclipse和Visual Studio--的扩展让开发者的生产力得到了显著提高. Visual Studio早期的版本是构建在COM技术之上的.而Visual Studio的主要扩展方式插件是通过COM接口实现的.随着时间的变

Xamarin Studio Android 配置

原文:Xamarin Studio Android 配置 C#依托于mono平台可以实现Unix平台服务器端开发已经不是什么新鲜事了,而Xarmain公司(初始成员大多来自原Mono.MonoTouch.Mono For Android成员)继续将C#的先进性带到了移动平台 -- 这也不是新鲜事了!但是国内的学习资料却很少,倒是有培训班已经看准了这个赚钱的机会,CSDN应该是和Xamarin有合作在国内率先开始了Xamarin移动跨平台开始的课程(避免广告嫌疑,我就不贴地址了),虽然说我作为一个

在Visual Studio 2013/2015上使用C#开发Android/IOS安装包和操作步骤

原文:在Visual Studio 2013/2015上使用C#开发Android/IOS安装包和操作步骤 Xamarin 配置手册和离线包下载  http://pan.baidu.com/s/1eQ3qw8a 具体操作: 安装前提条件 1. 安装Visual Studio 2013,安装过程省略,我这里安装的windows10 + vs2013 with update 4. 2. 安装Java SDK,按照Next一步步安装,此处省略,如下图: 3. 安装Android SDK:因为在线安装的

Visual Studio跨平台开发实战(5) - Xamarin Android多页面应用程式开发

原文 Visual Studio跨平台开发实战(5) - Xamarin Android多页面应用程式开发 前言 大部份的Andr​​oid 都具有实体或虚拟的Back键. 因此在处理多页面应用程式时, 与先前所介绍的iOS Navigation controller 比较起来会简单许多. 1. 开启Visual Studio 并新增Android Application 专案并命名为Lab4-MultiScreen   2. 在Layout资料夹中新增Second.axml   在Second

Xamarin C# Android for Visual Studio 平台安装

原文:Xamarin C# Android for Visual Studio 平台安装 Xamarin是基于Mono的平台,目前主要有以下产品(更具体请见:http://xamarin.com/products): Xamarin Studio:IDE,是从原来的MonoDevelop改名而来.现在从MonoDevelop官方网站下载的其实也是Xamarin Studio:http://monodevelop.com/. (话说MonoDevelop也是SharpDevelop的一个分支发展而

Visual Studio跨平台开发实战(4) - Xamarin Android基本控制项介绍

原文 Visual Studio跨平台开发实战(4) - Xamarin Android基本控制项介绍 前言 不同于iOS,Xamarin 在Visual Studio中针对Android,可以直接设计用户接口.在本篇教学文章中,笔者会针对Android的项目目录结构以及基本控件进行介绍,包含TextView,EditView,Toggle/ Switch以及Seekbar控件. Android 项目目录结构 在Visual Studio建立Android 应用程序项目后,在方案总管中会看到如下

android studio-Android studio gradle project sync 这是怎么回事?

问题描述 Android studio gradle project sync 这是怎么回事? 就是把一台电脑64位的Android studio 的project 复制到另一台32位的Android studio 上,使用import project 进行导入,然后就提示gradle project sync 什么的,然后就只剩下基本的编辑的功能了,新建acticity也不行,这是因为什么? 解决方案 应该是环境没有配好,包括各种studio需要的插件,包括gradle版本,sdk等 解决方案