This project is read-only.


Topics: Sample Code and Demos
Jan 11, 2013 at 2:31 PM


I've been using cocos2d for quite some time now, developing for the iOS and Mac platform. I now want to use cocos2d to develop for Windows and Xbox 360.

My problem, I don't have the slightest clue on how to start. I have Visual Studio 2010 installed and I tried to open the solutions that are in the source of cocos2d-xna but they will not open, Visual Studio claims that they were created with a version newer then 2010.

Also, how would I go about just adding cocos2d to a new Xbox360 game project?

Please let me know as I am very anxious to attempt to port some of my existing Mac and iOS projects.


Jan 11, 2013 at 3:51 PM

Hi, welcome to cocos2d-xna. Cocos2d-xna works well with xbox360, but note that we are only now just adding the gamepad support for it. Cocos2d-XNA is a touch specific framework right now, but with the advent of Ouya, Xbox360, and desktop deployments, the need for a gamepad has grown to be a requirement. We are quite close to having it ready for you. I will be testing some gamepad support today.


Look at the “tests” in the repository. They were all created for Visual Studio 2010 and XNA 4. You *MUST* have XNA 4 installed (the refresh update), or else this will not work for you. That’s likely where you are seeing the “.. created with a version newer than …” error. You also need to install the Windows Phone 7.1 SDK. We have not added a plain windows platform build project yet, but the “cocos2d-xna.sln” file does have a windows build target in it (see cocos2d/cocos2d.Windows.csproj).


We are working on documentation and samples. I know that this is the one place where the SDK have fallen flat and we apologize for that.


Note that cocso2d-xna does work on Xbox 360 and Ouya. We have done it in our offices. It’s just rough and not ready for general consumption. I am open to your suggestions for how to handle menu movements and gestures using the controller.


Thank you for using Cocos2d-XNA!

Jan 11, 2013 at 4:00 PM

Thank you for your quick response.

I have started to look at the tests and attempted to create a new Xbox 360 project using the code in the test project.

Here is the issue I am having now. When I compile, I get this message

Could not load file or assembly 'cocos2d-xna, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The module was expected to contain an assembly manifest.

I have added cocos2d-xna as a reference, so I'm not sure what I'm missing here, any ideas?

Also, I have XNA 4 Refresh installed but it still will not allow me to open the solution. I am using the Ultimate version of Visual Studio 2010, which version did you create the solutions in?

Also, for handling menu movements with the gamepad, I found an extension a while back that someone made for CCMenu that allow keyboard input for menu selection, I'll see if I can dig that up and send it to you, maybe you could use that for the gamepad.


Jan 11, 2013 at 4:23 PM

This error: The module was expected to contain an assembly manifest, usually means the project is not being built in the current configuration.

Did you open the cocos2d-xna.sln file, right click on the "tests (Windows)" project, select " Create XBox 360 Project" ??

We all use VS2010 Pro from Windows 7 Ultimate. Our VS comes from MSDN, non-retail. Ultimate is fine for this as well, you just need a minimum of VS Pro to build these targets successfully. VS Express won't work (just stating that for the community).

CCMenu has a keyboard binding extension? Fun. Cocos2d-xna that we have here does not have full keyboard support yet. Working on that as well.


Jan 11, 2013 at 9:13 PM

So I was finally able to implement cocos2d-xna and was able to run a Windows Game Project with a blank screen and a label. I figured I would stick with the basics until I have everything working.

So then I right clicked on WindowsGame1 in Solution Explorer and clicked on Create Copy of Project for Xbox 360. Everything seemed to move along just as it should. I then noticed that the reference for cocos2d-xna was missing from the XBox 360 project, so I removed the reference and re-added it. and now I get a ton of errors when I try to build the project.

The primary reference "cocos2d-xna" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version =, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0,Profile=Client". To resolve this problem, either remove the reference "cocos2d-xna" or retarget your application to a framework version which contains "mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089".

I have no idea how to change the project to target a different framework and even if I did, I wouldn't know which framework to target. Could you shed some light onto this issue. I really appreciate all of your help so far.

Jan 11, 2013 at 9:26 PM

excellent, so you are making progress. This error: NETFramework,Version=v4.0,Profile=Client, means that the target framework (right click cocos2d project, choose Properties) is set to the .NET 4 Client Profile, which is incorrect. Just change that to the non-client .NET 4 profile, and it should work. Do this for the XBox 360 version of cocos2d. If you don't have that, then do the same "Create a copy for XBox 360" step and use that in your xbox 360 target project.

XBox 360 can't use the limited client profile.

Jan 11, 2013 at 9:41 PM

Ok, so here's what I tried, loaded the Cocos2d.Windows project, right clicked on the project changed it to target .NET Framework 4.0 (Not the client one) and then clicked on build. It built the library which I then added as a reference to my Xbox 360 project but I'm still getting the same errors. Any ideas?


Jan 11, 2013 at 9:51 PM

You need to create an XBox 360 copy of cocos2d-xna. Right click on cocos2d-xna.Windows.csproj, select "Create a copy for XBox 360". This will create the correct csproj settings for XBox 360. Use that in your 360 specific game project instead of the cocos2d-xna.Windows reference.

Jan 11, 2013 at 9:59 PM

I think I understand, so I would basically open up the project that I created by clicking on Create a copy for Xbox 360 and then add my files, appdelegate, controller, etc... to that project, change the Output type to Console Application and build?

Jan 11, 2013 at 10:03 PM

In this case, yes. But if you started with a working game on WP7 and did the "create a copy for XBox 360", it would create links to your original source. That way you only have to edit on the original source.

I have gamepad code that I will check in later today.

Jan 11, 2013 at 10:06 PM

Ok, I'll give it a shot and see what happens. Excited to see the gamepad code..


Jan 11, 2013 at 10:07 PM

me too. I put our first cocos2d-xna game on the xbox360 immediately after I wrote it for WP7. It was cool, but I couldn't control it. +6 months later, we can finally play the game.

Jan 11, 2013 at 11:35 PM

So. Here's what I did...


Double-Clicked on cocos2d.Windows.csproj

This launched Visual Studio 2010, I then proceeded to right-click on cocos2d.Windows in Solution Explorer. I then clicked on Create Copy of Project for Xbox 360. I then received a popup asking me to Save changes to the following items? cocos2d.Windows.sln. I proceeded to click no on that. After the popup window closed, the copy of the project for Xbox 360 was created.

I then closed Visual Studio 2010. I double clicked on the file "Xbox 360 Copy of cocos2d.Windows.csproj". This launched Visual Studio 2010. Right away I noticed that there were 2 missing references (ICSharpCode.SharpZipLib and I removed them and then readded them from the external libs folder within cocos2d.

I then proceeded to right-click on Xbox 360 Copy of cocos2d.Windows project and click on properties.

I clicked on Application and changed the Output type to Console Application.

I then added the following: Game1.cs, Program.cs, AppDelegate.cs and Controller.cs

I then tried to build the project and it didn't work.

The type or namespace name 'Compression' does not exist in the namespace 'System.IO' CCTMXMapInfo.cs

The type or namespace name 'Devices' does not exist in the namespace 'Microsoft' CCAccelerometer.cs

and the list goes on.

Do you think that there is a possiblity that you could maybe compile the cocos2d-xna library that works with Xbox 360 for me? Hopefully I'm not being too much of a pain.

Jan 11, 2013 at 11:51 PM

That's expected. There are going to be lots of little quirks to go through to make it work again on xbox 360. Remember that this is a touch/mobile library. Once we get past the device stuff you will need to consider design resolution for your game. The default WP7 configuration is 480 x 800. On the console, this is 480p, and it very retro. You will want to go 720p or 1080p. The NTSC display formats are well known. Don't worry about the "i" versions since those are "interpolated" formats. Only the "p" (for Pixel) format are of concern.

I will try an xbox 360 version after I commit my changes for gamepad, which will be shortly. I am testing some windows stuff right now.

Jan 12, 2013 at 12:47 AM

done. github and codeplex both have the xbox360 build. builds here just fine.

Jan 12, 2013 at 12:52 AM

Error 1 No file or directory that you deploy can have a name longer than 40 characters. Unable to deploy file Content\extensions\CCControlColourPickerSpriteSheet.plist.xnb.  0 0 

haha. I will fix this next.

Jan 12, 2013 at 1:10 AM

i have deployed the project to xbox 360 successfully. the CCControlColourPickerSpriteSheet files are not used so they can be excluded from the project.

Jan 12, 2013 at 1:51 AM

Error 1 Source file 'C:\Documents and Settings\Administrator\Desktop\cocos2dxna-71009-1\cocos2d\gamepad_dispatcher\CCGamePadButtonDispatcher.cs' could not be opened ('Unspecified error ') cocos2d.XBox360

Error 2 Source file 'C:\Documents and Settings\Administrator\Desktop\cocos2dxna-71009-1\cocos2d\gamepad_dispatcher\CCGamePadButtonDelegate.cs' could not be opened ('Unspecified error ') cocos2d.XBox360

This is what I'm getting. I took out all of the CCGamePadButtonDispatcher stuff and got it to deploy but I can't get it to deploy with the CCGamePadButtonDispatcher.cs included in the project. Any thoughts?


Jan 12, 2013 at 2:27 AM

The files exit in the github repository but not on codeplex. I got the test to run but when I try to run my own app, I get

An unhandled exception of type 'System.TypeLoadException' occurred in cocos2d-xna.dll

Additional information: Could not load type 'ICSharpCode.SharpZipLib.GZip.GZipInputStream' from assembly 'ICSharpCode.SharpZipLib, Version=, Culture=neutral, PublicKeyToken=null'.

Jan 12, 2013 at 3:23 AM

Did you add a reference to the SharpzipLib from the externa libs directory  into your game project? Make sure you do that.

Jan 12, 2013 at 3:34 AM

Yes I did, still not working. Also, could you give me a quick explanation of how to use the keypad and gamepad classes? Thank you for all of your help.

Jan 12, 2013 at 5:38 AM

The issue seems to be related to parsing a TMX tile map. It also happens when I use the Tilemap tests but only on Xbox 360. If I run it on Windows, it works fine. Can you try it out and see if you encounter the same issue.

Jan 12, 2013 at 5:53 PM

I started some documentation that includes some how-to on the GamePad.

As for the GZipInputStream, maybe we need to create a special Xbox 360 version of the sharp zip library. I've not tried to read a gzip file on the xbox.

Jan 12, 2013 at 7:36 PM

That's great, when do you think you'll have some documentation that I can look at?

I've tried compiling the SharpzipLib many different ways to try and get it to work, I finally gave up and started looking for alternatives, I replaced the SharpzipLib library with Ionic.Zip.Axiom

I then made the following changes to CCTMXMapInfo.cs


using ICSharpCode.SharpZipLib.GZip;


using Ionic.Zlib;



var inGZipStream = new GZipInputStream(new MemoryStream(pTMXMapInfo.CurrentString));


var inGZipStream = new ZInputStream(new MemoryStream(pTMXMapInfo.CurrentString));

Now I don't get that error any more, however, I've run into the next issue. Loading textures seems to be a problem. In CCTextureCache.cs, this line of code 

var textureXna = CCApplication.SharedApplication.Content.Load<Texture2D>(fileimage); seems to create a file location that does not exist. Here is a sample of the path it is creating:

Tilemaps\New Game\Project\New Game\tileset2

Tilemaps is a in the root of my content folder and tileset2 lies directly within the Tilemaps folder. I'm not sure why \New Game\Project\New Game\ is inserted in-between but it breaks it. I tested this by hardcoding the location of my tileset, replacing the fileimage variable like so: fileimage = "Tilemaps\tileset2";

This loaded the texture and deployed to the Xbox 360, finally got to see my tilemap of one of my levels on the Xbox 360.

Anyways, any ideas on the path issue?

Jan 12, 2013 at 7:45 PM

Ok, never mind the path issue, I figured it out, it was my own stupidity. The TMX file was using that path when I was originally using it in an XCode project. So that's all good now. Glad I have that figured out.

Can't wait to see some docs on the gamepad class. Thanks for all of your help.

Jan 12, 2013 at 9:10 PM

Are you using this with Axiom 3D? I just downloaded that and started to look at how it could integrate with cocos2d-xna. If you are doing this, can you add your progress to our github? We would all greatly appreciate that work!

The "My First Game" documentation mentions the GamePad support. There's not much to gamepad. if you have a CCLayer then you are already getting the events, you just need to enable it. See the ctor example in the "My First Game" tutorial.


Jan 12, 2013 at 9:25 PM

also, the GamePad support currently only handles the back button press. that's the minimum effort to make it work properly on mobile devices.

Jan 12, 2013 at 9:28 PM

Actually its not a complete implementation, I just used the zip library for the TMX parser. 

Jan 12, 2013 at 9:51 PM

I get an error when I try to enable the gamepad.

I'm using CCDirector.SharedDirector.GamePadEnabled = true;


Error 1 'cocos2d.CCDirector' does not contain a definition for 'GamePadEnabled' and no extension method 'GamePadEnabled' accepting a first argument of type 'cocos2d.CCDirector' could be found (are you missing a using directive or an assembly reference?) 

Any thoughts? Also, once I have this implemented how difficult would it be to fully implement the gamepad's functionality.

Jan 13, 2013 at 2:15 AM

I am going to change how the gamepad support is implemented. the current implementation is too restrictive so I am going to roll out a CCGamePad class that has more information about the state of the gamepad.



Jan 13, 2013 at 8:11 AM

I've put the new gamepad code up on github. I'll try to sync with codeplex soon.

Jan 13, 2013 at 3:24 PM

The gamepad code is up on codeplex now. The method for hooking up the gamepad handling is by way of subscribing to events in CCApplication. See the My First Game page for some rudimentary details.

The gamepad device is very different than a touch device. I suggest that you use the DPad as your "scroller" and the sticks for in-game movements.

Jan 14, 2013 at 3:56 AM

Haven't had a chance to checkout the new code yet, I'm having a bit of a problem with animations, hoping you could lend me some of your expertise. I'm pasting 2 versions, one is the Objective-C version the other is the C# version. The objective-c one runs fine but the C# version only displays the initial sprite and does not seem to run the animation at all. I'm using the exact same files in both versions.


Objective-C Version:

NSMutableArray *frames = [NSMutableArray array];
CCSprite *mysprite = [CCSprite spriteWithFile:@"player_idle_image.png"]; 
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"player_walking.plist"];
CCSpriteBatchNode *batchnode = [CCSpriteBatchNode batchNodeWithFile:@"player_walking.png"]; 
[mysprite addChild:batchnode]; 

for (int i = 1; i < 4; i++) { 

[frames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"player_walking__00%d.png", i]]];


CCAnimation *animationwalking = [CCAnimation animationWithFrames:frames delay:0.08f];
[mysprite runAction:[CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animationwalking]]];
[self addChild:mysprite]; 
mysprite.position = CGPointMake([CCDirector sharedDirector].winSize.width/2,[CCDirector sharedDirector].winSize.height/2); 


C# Version:            

var frames = new List<CCSpriteFrame>(3);
CCSprite mysprite = CCSprite.Create("animations/player_idle_image");
CCSpriteBatchNode batchnode = CCSpriteBatchNode.Create("animations/player_walking");

for (int i = 1; i < 4; i++) {                



CCAnimation animationwalking = CCAnimation.Create(frames,0.08f);
mysprite.Position = new CCPoint(CCDirector.SharedDirector.WinSize.width / 2, CCDirector.SharedDirector.WinSize.height / 2);

Jan 14, 2013 at 7:27 AM

One problem is that you need to add the sprite to the sprite batch.

Then you add the spritebatch to the display rather than the sprite (mysprite).

lastly, you modify the position of the sprite batch node to adjust where the sprite animation is displayed.


Jan 14, 2013 at 2:48 PM

When I do it that way, all that displays is the sprite sheet. Do you have an e-mail that I could send you the project to? I'm completely lost on this one. Should be a very simple thing but is turning out to be very complicated...

Jan 14, 2013 at 7:20 PM

Figured it out finally.

The issue was the plist file. I use Texture Packer when creating sprite sheets and apparently if you use the default cocos2d setting, it creates a plist that the cocos2d plist importer can't import. So I changed the setting in Texture Packer to cocos2d original which also produced a plist that didn't work.

I then compared the grossini plist to my plist and noticed that the only difference was a metadata dictionary that texture packer seems to append to the end of the plist. I deleted this section from the plist and just like magic, my animation started working...

I haven't looked at the code for the Coco2d - plist importer yet but my guess is that its very restrictive and we may need to get with the creators of some of the sprite sheet editors and see if they can create a setting for Cocos2d-XNA.

Lastly I wanted to mention something else, when you add the plist and the texture files, the base name MUST be the same. For example:



The issue here is that when adding these to files to the content folder in Visual Studio it strips the extensions and you end up with 2 files having the same name and Visual Studio will not allow you to compile. My first thought was renaming the plist file to player_walk_plist but this made the animations not work. So the fix here is to change the Asset Name in the properties of the plist file to include the .plist extension after adding the file to the content folder.

Hope this helps someone save several hours of trial and error :)

Jan 14, 2013 at 9:35 PM

Hi, glad you figured it out. Likely Texture Packer is sending the wrong file version number in the plist. I saw the same thing in Predator. cocos2d is sensitive to the version of the file as it supports up to 4 different formatting methods.

As for the content project stripping off the extension, you can put your images into a subfolder, or else rename them. I use "my_anim.plist" and "my_anim.png" for our animations. This works fine for us. What I do in the content project is set the Asset Name to be "my_anim_Sprites" for the PNG file. Then the output can be generated, otherwise the content builder will map "my_anim.plist" to "my_anim.xnb" and "my_anim.png" to "my_anim.xnb" which will not work.

The "Asset Name" is the name you use to pull in the content using the ContentLoader in your game.

Jan 14, 2013 at 9:40 PM

That makes sense.. Another quick question I have. Hopefully you can help me with this. Is there some sort of code implemented somewhere in cocos2d that draws lines when you rotate a node?

I'm using ccrotateby to rotate a layer, when the layer has rotated to 90 degrees there are 3 dark vertical lines in the center going all the way from top to bottom, when I rotate to 180 I get 3 lines vertical and 3 lines horizontal in the center, when I rotate to 270 I get 3 horizontal lines all the way from left to right... Is there any reason you can think of that this could be happening? It only happens on the Xbox 360 deployment.

On the Windows deployment I don't get those lines.. any ideas?


Jan 14, 2013 at 11:31 PM

I am seeing some odd behavior on the xbox version of cocos2d-xna. The lines are artifacts from prior frames rendered by your game. I am not sure what happens there, but I see it in our game when we do screen transitions.

Jan 15, 2013 at 3:06 AM

Are you implementing this ?


It seems to only happen for me when using a tile map. I was reading about artifact issues with tile maps and cocos2d and most of them say that setting the above to 1 will fix the issue.

Is this something you are looking into or will it be a while until it can be resolved? No rush, just curious.

Jan 15, 2013 at 10:30 PM

I haven't heard any other complaints about needing to stretch tiles on a tilemap. Are you tiles not uniformly sized?

Jan 15, 2013 at 10:48 PM

I honestly don't think that the issue is with my tilemap because it works great on OS X and iOS but on Windows & Xbox 360 I get lines / artifacts...

Jan 16, 2013 at 2:20 PM

Gena had this to say about your problem:

I thing that you should try to change the following definition:

{{ DrawManager.WorldMatrix = Matrix.Identity; }}

in the CCDirector.Projection setter . I used the next code and it helped: 

{{ DrawManager.WorldMatrix = Matrix.CreateTranslation(-0.5f, -0.5f, 0); }}

Maybe you could submit a bug report for it and attach a screen shot of the failure? That would help us understand where it is failing.

Jan 16, 2013 at 2:41 PM

I will try this out a little later tonight when I get home from work and let you know how it goes. If it doesn't work I will submit a bug report along with a screen shot. Thank you for your help.

Jan 16, 2013 at 3:03 PM

Did you try at some point prior to your porting to Xbox 360? Maybe your tiles are not POT square?

Jan 16, 2013 at 7:43 PM

No I haven't, I haven't had to make any adjustments to my tilesets or tilemaps to remove artifacts. The first time I have ever experienced any artifacts is with this framework. I'll let you know in a few hours if the suggested fix helps or not and if not I'll send you a screen shot of the issue. Thanks

Jan 17, 2013 at 8:24 PM

I've just submitted the bug report along with the screen shots for you to review, let me know what you think.


Jan 17, 2013 at 9:03 PM

isometric or orthographic tile map?

Jan 17, 2013 at 9:09 PM


Jan 17, 2013 at 9:16 PM

i will update the tests to work with the game pad and then create a test case for this. It looks like a rounding error. I bet the orthographic map has the border at the bottom when rotated 0 degrees.

Jan 18, 2013 at 6:22 AM

I've updated the github repository with gamepad support in the tests. I've also added a version of ICSharpZipLib that should be compatible with Xbox. The library was not loading because it referenced cryptography and made use of unsupported encoding options. Some notes about xbox - no crypto and UTF8 for your strings. I should be able to run the tilemap tests now, but that will be next week.