cocos2d-x for Mac OS X ?

cocos2d-x for Mac OS X ?
0.0 0


Is there going to be cocos2d-x runnable on Mac OS X like in its PC version ?


Here’s the contributed source code of mac port. We’re busy upgrading gles20 branch, so have no time to merge it into master branch.
If someone need mac port badly, he can start from this zip ball.


That’s okay. I can wait until you guys merge it.
Glad to hear it’s still in development.


Thanks for the hint in the other thread, glad that there is still some development for the Mac platform going on.

I’ll try to merge the sources in my project later on, are there any statements from the original author for which (major) version of Cocos2d-x this port is intended?



I use this with the last cocos2d-x release to make nice video of my new cocos2d-x game
But I think there is a mistake
in the following method of CCDisplayLinkDirectorMac

void CCDisplayLinkDirectorMac::mainLoop(void)
    if (m_bPurgeDirecotorInNextLoop)
        m_bPurgeDirecotorInNextLoop = false;
    else if (! m_bInvalid)

        // release the objects

Someone have forgotten to remove a comment


it should not be commented
or nothing will be autorelease


Hey Joseph,
could you please share the working library for Mac OS X with a simple Hello World running? Thanks a lot.


it will be available here
Original cocos2d-x plateform test are a bit hacked to have both Mac and Iphone plateform in the same project file, I didn’t figure well how it works


Thank you very much I was able to run my project on Mac platform thanks to your effort!
I’m very grateful.


I would like to thank you as well! I as having a hard time figuring out how to get the hello world sample running on OS X. You can do a proper platform check like this:

#ifdef __APPLE__
#include "TargetConditionals.h"

    #define CC_SUPPORT_UNICODE 0
    #define CC_SUPPORT_PVRTC
// mac
    #define CC_SUPPORT_UNICODE 0

TargetConditionals.h defines TARGET_OS_IPHONE as 0 on Mac, but since it is still defined you have to check the value instead of just checking for the definition.


Thanks greatly to the help from Joseph, I put a working version on github here All I have is the hello world demo up now, but I hope to add the tests soon and begin the process of seeing what bug fixes and features need to be added.


Thanks everyone for bumping this up, great to see working version on Mac! :slight_smile:


I just added support for Truetype fonts to the port and pushed it to the github address above. Is there an official github repo somewhere for the macosx port that I can send a pull request to? There’s still a lot of things that I want to fix and I’d like to be able to share the fixes with everyone.


Thanks for joseph’s sharing! I’m looking for this for long time!


Imperial Penguin: is the github macosx branch removed now? I downloaded it a few days ago and started to play around and found a few bugs I’d like to report…


No, I didn’t delete the branch, I just merged it with the master because I had fixed everything that I wanted to (or at least I thought I did. Let me know if there are more problems and I’ll take a look at them).
I did make some changes to fit my needs that others might not appreciate so much though. For example, you now have to call a create function that takes four arguments. The first two are the width and height of the window in pixels, and the next two are the width and height of the window in points. This will make it easier to port over existing mobile titles, by allowing you to keep working in the 320x480 coordinate system. Enabling retina display will allow the use of larger images.
I also added preliminary joystick support hooked to the accelerometer. Right now it needs an analog joystick (the d-pad doesn’t do anything) and the DDHIDLib framework needs to be copies to the app’s bundle. Eventually, I want to build a static version of the library to take a away that requirement, but I’ve been busy with other things. I’ve also added support for keyboard input. You can type in the textinputtest directly, of course. The keypad test keys (back, and menu) are mapped to Shift-F1 and Shift-F2, although I doubt that will be very useful to anybody.
There is one bug left in the github branch, and that is that glView is being initialized twice in the test and helloworld projects. I haven’t bothered pushing the fix because I didn’t think anyone was paying attention. I’ll try to find time to do that today. Let me know if I missed anything.


ah, great!

I’ve stumbled upon some strange behaviors while trying to run an old Cocos2d-x game of mine for mac… I have a helper function that generates buttons that consist of a sprite container, a background sprite and a CCLabelBMFont instance on top of that. After creating a few of these buttons and adding them to the scenery I get an assertion at CCSprite::addChild —> CCAssert(((CCSprite*)pChild)->getTexture()>getName == m_pobTextureAtlas>getTexture()->getName(), “”); (EXC_BAD_ACCESS)

This happens approx 50% of the times i run the app. Otherwise everything works. My dirty work-around is to set m_bUsesBatchNode to false which works in my case… I have a zip of a Xcode project that generates the assertion but it’s too big to attach here. If anyone wants it, send me a PM containing an email address and I’ll send it that way…


Hey all.

Just wanted to let everybody know I’m starting an effort to merge all the mac code into the latest gles20 branch so it can hopefully be a part of the next Cocos2d-X release, even if some features are limited.

I’m using ImperialPenguin’s cocos2d-x mac branch and the zip Walzer provided above and piecing things together in a fresh branch of gles20.

When everything’s ready I will submit a pull request to the Cocos2d-X team so they can merge it.


Got it working! Whew. It was quite a trick to sort out all the changes from 1.x to 2.x and make the Mac version happy.

So yeah, it works! Full screen support works. Mouse input. Sound. All the basics are in there.

Here’s a little video showing it off:

The pull request I am submitting to the Cocos2d-X team has only basic Mac support. I will leave it to somebody else to make the HelloWorld, test project and proj.mac folders.

ImperialPenguin? :slight_smile:

Here’s the pull request:


I’d be happy to have a go at it when I get a chance, but unfortunately right now I’m looking at a month or so of work before I even find time for a nap. I overextended myself when when down for a week or so and I created a replacement forum even with a boatload of work ahead of me. Of course iPhoneDevDSK came back up as minutes after I was done, but I figure I might as well finish polishing up the forum. Even if no one joins it gives me a break from my current Cocos2d-x project. Sometimes you get tired of looking at the same codebase for two months straight. Haha. Anyhow, I’ll take a look when I have time, but someone else may beat me to it.


When will Mac code ready for use and bundled in stable version of Cocos2dx?