News

Cocos2d-x for wp8 v2.0 preview

By walzer Posted 2013-03-27 07:46 Comments 54

Today we released the v2.0 version of Cocos2d-x for Windows Phone 8. Note that it is the first version for wp8 which has v2.x API set migrated. We would like to thank Microsoft and Nokia for their support.

Download link: Cocos2dx-2.1.0-wp8-2.0-alpha.zip
Github repo: https://github.com/cocos2d-x/cocos2dx-win8/tree/wp8\_v2

This branch of Cocos2d-x uses Direct X 11 for rendering while still uses C++ to program, with the same API as Cocos2d-x v2.1.

There are already many games in the pipeline and scheduled to be available soon in Windows Phone Store, using Cocos2d-x WP8 2.0.

We look forward to hearing feedback from developers, and for those at the Game Developer Conference in San Francisco, come and visit us at booth 412.

Comments

  • Wriggler

    Excellent work, thank you all! I’ve been looking forward to this one. Thanks again.

    2013-03-27 10:21
  • pekayatt

    Perfect[]()!
    It is working here, I will try to port my game today :D

    2013-03-27 13:26
  • jandujar

    good work[]()

    now integrate it to the cocos2d-js binding and make me happy. ;)

    2013-03-27 15:18
  • jeffersonpita

    Congrats!

    Is there a way to use webservices with cocos2d-x for wp8?

    2013-03-27 17:00
  • Konrad

    Hello, I checked this yesterday and it looks not to be as stable as first version (cocos2dx-0.13.0-wp8-0.8).

    Crash in:
    1. MenuTest > Closes application
    2. Pressing on close button in top right corner
    > Throws exceptions
    3. SpriteTest, works only in 2 cases, produces > Unhandled exception at 0x71538F86 in TestCpp.exe: 0xC0000005: Access violation reading location 0x00000018.
    4. When I try to create simple Sprite animation from my .plist, it crashes on update object:
    void CCObject::retain
    {
    CCAssert; // <—
    here

    ++m_uReference;
    }
    When I retain almost everything, then it is not crashing, but nothing is displayed on screen instead.

    IMPORTANT:
    I’d like to mention that all above is working in previous version of cocos2d-x wp8 (cocos2dx-0.13.0-wp8-0.8).

    2013-03-28 06:48
  • hrust

    Cool!
    It also would be nice to update win8 metro branch))

    2013-03-28 09:57
  • eric2013

    Hi, I just installed this version.
    Problems:
    1. Works in simulator but did not display anything on real device.
    2. CCLabelBMFont ->getContentSizeInPixel return incorrect size

    The above all works in cocos2dx-0.13.0-wp8-0.8.

    2013-03-29 00:36
  • ZhiShuo

    wait a long time . thanks !

    2013-03-29 09:12
  • saudahmed

    When are you going to add support for CocosBuilder , CCScrollView, CCTableView and other GUI extensions in this branch.

    2013-04-02 08:18
  • Billy.Lavoie

    Does this mean we could see an updated build for Windows8 too soon? :)

    2013-04-02 21:17
  • 152688854

    Well, this is a good news[]()
    But the rendering implement is old. I think this version can’t work well :(

    2013-04-03 07:35
  • munir

    Great news!

    When can we expect v2 port for Windows 8?

    2013-04-03 17:18
  • vradgames@hotmail.com

    So, to confirm, can I port my Game developed using this Version to WP8, Android, IPhone and Blackberry?

    2013-04-04 05:59
  • eric2013

    This version is not working in real device. I am using Lumia 620, display shows blank when deployed to real device. Simulator works ok. Cocos2d-x team please post a tutorial to show how to work with real device, thanks.

    2013-04-04 08:11
  • pekayatt

    @Eric Hung
    You should change the deploy to ARM and not x86! (That only works in the emulator)

    I got the last version on Git (that got an update couple of days ago) and it almost working, some stuff as particles and transition effects are broken, but give some time to the guys, I know they are working on it!

    Good work guys!

    2013-04-04 17:19
  • eric2013

    @ Pedro Kayatt
    Thanks for your information. I finally find out what’s wrong.
    I download v2 from Git.
    1. Compile as Simulator, all working.
    2. Compile as Device~~>Release~~>ARM, HelloWorld, HelloWorldBox, TestCpp, all compile ok, install ok on Lumia 620, all with blank screen.
    3. Compile as Device~~>Debug~~>ARM, everything works ok on Lumia 620.
    Hope cocos2d-x team will fix this too. Thank you cocos2d-x team.

    2013-04-06 10:30
  • pinky2012

    I’ve ported my App finally to WP8; you guys rock. Thanks!

    2013-04-07 20:36
  • pinky2012

    .. just one request. It would be great if you can make an XAML hybrid version (on Win8 I managed to create an interop app on my own, but I’m afraid on WP8 that’s a bit harder).

    There are still bugs in this version that I had to fix to get it functioning:

    • Reading a string from CCDefaults that does not exist yet results in a crash;
    • Using a space in a label (ttf and BM) results in a crash;
    • I had to incorporate a delegate in CCApplication for the back button (which is a must have to get approved for the store);
    • I had to add code to show the onscreen keyboard on attach with IME;
    • It appears that some touch functions do not account for the actual device orientation (touch points as if the device is in portrait whilst is actually in landscape);

    On other platforms a libcurl lib is included. Would it be an idea to abstract and include the HTTPRequest sample from Microsoft into this project as a suitable libcurl replacement ?

    2013-04-07 20:52
  • jcclarke

    Is word wrapping not currently implemented? Can’t get paragraphs to word wrap using CCLabelTTF.

    2013-04-08 22:54
  • eric2013

    @Pink Nibor
    Can you share the code on

    1. how to incorporate a delegate in CCApplication for the back button ?
    2. how to show the onscreen keyboard on attach with IME ?

    That helps WP8 cocos2d-x developer a lot, thanks.

    2013-04-13 00:12
  • pinky2012

    Difficult to explain

    2013-04-13 12:00
  • pinky2012

    You can download the modified files I use on http://tinyurl.com/ct93vsv Replace with these files and the keyboard should just work (there is a new function in DirectXRenderer called ToggleKeyboard(bool visible))

    As for the backbutton: implement the BackbuttonDelegate in your scene like this:

    class GameLayer : public cocos2d::CCLayerColor , public CCTextFieldDelegate, public KSDialogInputDelegate, public GCDelegate, public KSDialogDelegate , public BackbuttonDelegate

    And add the delegate function:

    bool GameLayer::onBackPressed(bool result)
    {
    if (ActiveAlert == 0)
    {
    this->backhomeA(this);
    }
    return true;
    }

    If you want the App to close return False. If you handled the backbutton action within your app, return FALSE.

    Only problem I still have that if I specify the NDEBUG preprocessor directive, the screen stays black (both on simulator and on device).

    2013-04-13 12:07
  • pinky2012

    Sorry typo: return true if you do not want the app to close ;-)

    2013-04-13 12:09
  • eric2013

    Thanks Pink Nibor.

    I am stuck at :

    bool CCApplication::onBackButton()
    {
    bool ff = true;
    if (m_pDelegate) ff=m_pDelegate->onBackPressed(false);
    return ff;
    }

    m_pDelegate is always null. How to set pDelegate ?

    2013-04-14 05:04
  • pinky2012

    OnEnter:
    CCApplication::sharedApplication()->setBackDelegate(this);

    OnExit
    CCApplication::sharedApplication()->setBackDelegate(null);

    2013-04-14 07:24
  • kimiazhu

    the samples work fine on my Huawei device. :)

    2013-04-14 11:58
  • Vladimir_BL

    Hello.
    I’m making big project for WP8 using Cocos.
    I’ve fixed 2 serious bugs:
    File CCActionInterval.cpp
    Method void CCAnimate::update(float time)

    void CCAnimate::update(float time)
    {
        CCArray *pFrames = m_pAnimation->getFrames();
        unsigned int numberOfFrames = pFrames->count();
    
        unsigned int idx = (unsigned int)(time * numberOfFrames);
    
        if (idx >= numberOfFrames)
        {
            idx = numberOfFrames - 1;
        }
    
        // NEED FIX.Here is Cocos bug: pFrames->objectAtIndex(idx) returns CCAnimationFrame but not CCSpriteFrame
        CCSprite *pSprite = (CCSprite*)(m_pTarget);
        // NEED FIX+
        CCAnimationFrame* aniFrame = (CCAnimationFrame*)(pFrames->objectAtIndex(idx));
        CCSpriteFrame* frame = aniFrame->getSpriteFrame();
        /*if (! pSprite->isFrameDisplayed((CCSpriteFrame*)pFrames->objectAtIndex(idx)))
        {
            pSprite->setDisplayFrame((CCSpriteFrame*)pFrames->objectAtIndex(idx));
        }*/
        if (! pSprite->isFrameDisplayed(frame))
        {
            pSprite->setDisplayFrame(frame);
        }
        // NEED FIX-
    }
    

    File CCLayer.cpp
    Constructor of CCLayerColor: 2 arrays were not initialized

    /// ColorLayer
    CCDXLayerColor CCLayerColor::mDXLayerColor;
    
    CCLayerColor::CCLayerColor()
    : m_cOpacity(0)
    , m_tColor( ccc3(0,0,0) )
    {
        // default blend function
        m_tBlendFunc.src = CC_BLEND_SRC;
        m_tBlendFunc.dst = CC_BLEND_DST;
    
        mDXLayerColor.setIsInit(FALSE);
        // NEEDED FIX+
        updateColor();
        for (unsigned int i=0; i
    

    Also I was forced to implement HTTPRequest instead of “curl” and use std::thread instead of “pthread”. Also I was forced to comment some CCAsserts.
    ——————

    Do you have plans when will new WP8 version of cocos be released?

    2013-04-18 13:57
  • pinky2012

    Submission of a release build to Microsoft results in an error:

    The application cannot be tested for compliance for Windows Phone Application Certification Requirements due to geographic, hardware, and/or software limitation. The application cannot be found from the application list or from the game hub after installation.

    It’s obvious the App does show up on my device when testing (either debug or release version)…

    Any ideas?

    2013-04-18 17:46
  • 152688854

    don’t working in real device.
    because CCTexture2D.cpp ln551 :
    CCAssert(this~~>initWithData, “Create texture failed!”);
    in release, #define assert 0)
    so this~~>initWithData() is not be activity.

    2013-04-19 08:40
  • pinky2012

    The application cannot be tested for compliance for Windows Phone Application Certification Requirements due to geographic, hardware, and/or software limitation. The application cannot be found from the application list or from the game hub after installation.

    Occurs when you set the App type to Game. Can be solved by adding an AppManifest.xaml and a dummy DLL. After that your game will show up in the Game Hub (and not in the App list).

    2013-04-19 16:28
  • eric2013

    This alpha release is not being updated for over a month. I appreciate the hard work of the team. Thanks. Would the team accelerate to stable release as soon as possible. We would like to release the potential of WP8.

    2013-04-21 10:22
  • saudahmed

    I am trying to add inApp purchase for my game for cocos2dx-wp8-v2.0. I have gone through the api but I am not able to call methods in C# from the Visual C++ in my code. Has anybody implemented the inApp purchase. Help will be appreciated.

    2013-04-25 07:01
  • saudahmed

    I am trying to submit my app as beta for inApp purchase testing but When upload the release build after validation it gives me this error

    1028: The native API api-ms-win-core-debug-l1-1-1.dll:OutputDebugStringA() isn’t allowed in assembly Cocos2dWindowsPhone.dll. Update it and then try again

    How were you able to submit your app. What necessary changes you made to submit your app?

    2013-04-26 12:36
  • pinky2012

    It’s in CCfileutils and is just for debugging (search the solution for OutputDebugString and you’ll find it soon enough). Just comment out the line or replace it with CCLog

    My App passed certification today with the 2.0 Alpha framework :)

    2013-04-27 01:39
  • eric2013

    HI,
    Summary of workaround to publish app to market:

    1.CCFileUtils_win8_metro.cpp
    comment out the line with OutputDebugStringA

    2.CCTexture2D.cpp
    replace
    CCAssert(this~~>initWithData, “Create texture failed!”);
    by
    this~~>initWithData(data, pixelFormat, POTWide, POTHigh, imageSize);

    1. Compile to Device~~>release~~>ARM

    Your app should pass then.

    2013-05-01 01:47
  • elanser

    Hello community! :)
    Some bugs which don’t allow to issue the final version of game:

    1 - after some time data in CCUserDefaults, an error 24 too many open files cease to remain… Here:
    tintxml.cpp module, function: bool TiXmlDocument::SaveFile(const wchar_t* filename) const, line: errno_t err = _wfopen_s( &fp, filename, L“w” ); <— err=24

    2 - at each level in my game, on the screen, time in seconds is drawn. I use, for example: timettf = CCLabelTTF:: create (“0”, myconst~~>fontName, sizefnt);
    after some time in the console was out that the font isn’t found and the sizes of letters become huge. This problem managed to be solved
    3~~ In my game I use CCSpriteBatch, at each level new textures are loaded, and old are cleared. On level end I clear a cache
    CCDirector::sharedDirector()->purgeCachedData();
    CCTextureCache::sharedTextureCache ()->purgeSharedTextureCache();
    But all the same, after loading of 5-6 levels of texture cease to be created and the program crash here:
    CCTexture2D.cpp module, function: bool CCTexture2D:: initWithData, line: if (FAILED (pdevice->CreateTexture2D (both tdesc, and tbsd, &tex)))

    All this doesn’t allow to port the game version for wp8
    What it is possible to undertake for elimination of these bugs?

    2013-05-12 03:50
  • Vladimir_BL

    Most probably all problems with opening files (“too many open files”?) is because of incorrect using FT_New_Face inside of bool FTTextPainter::SetFont.
    FT_New_Face should be called once for each font (to create it). In current alpha release it is called on EVERY frame for any font. You should make light fixes to use already created fonts instead of creating them at each new frame.

    2013-05-13 05:38
  • elanser

    Thanks :) Vladimir.
    I will fix this bug and will showing fixed code….

    2013-05-13 12:41
  • Sentiz

    Hello Community.. I want to use ccprogressTimer in my wp8 game. I have used ccprogresstimer in ios and android projects, its working fine there. But in WP8 it is not displaying and its not crashing also. Can anyone put example here..??

    2013-05-23 07:45
  • Vladimir_BL

    About CCProgressTimer:
    In Android and iOS versions there is “kCCProgressTimerTypeBar”. But in WP8 it is not used. You should specify one of new type: kCCProgressTimerTypeRadialCCW, kCCProgressTimerTypeHorizontalBarLR, etc…

    2013-05-23 07:54
  • Sentiz

    Hi,
    Currently WP8 Cocos2dx 2.0 is not supporting for ExcatFit or NoBorder options while setting design resoultion. So will it be added in update version ?

    2013-05-23 09:42
  • jacob_m99

    so I’m now stuck with the back button..
    I updated the CCApplication .cpp and CCApplication .h but now my question is how do I use it in my scene.

    I got the hello world example up and running with the back button implementation. how would I check on helloworldscene to see if the back button as been pressed.?
    now from what I understood if I wanted my app to close all I have to do is return false. if I wanted it not to close, for instance return to a previous scene I turn true and replace scene with whatever previous scene I want..

    2013-06-20 12:25
  • Jasim9

    Hello Pink Nibor,

    I used your files for the back button implementation. But it is not working DirectXRender has many errors like
    Error 31 error C2039: ‘OnKeyDown’ : is not a member of ‘cocos2d::DirectXRender’

    Please help me out. I only want the back button functionality to transition to a specific scene I want.

    Thanks

    2013-07-16 07:31
  • pinky2012

    You should add those new methods to the include file (DirectXRender.h):

    Add:

    void OnKeyDown(
    _In_ Windows::UI::Core::CoreWindow^ sender,
    _In_ Windows::UI::Core::KeyEventArgs^ args
    );

    and add:

    @ void ToggleKeyboard(bool status);@

    That should be it.

    2013-07-17 20:03
  • pinky2012

    To use the backbuttondelegate:

    1) add the delegate to your scenes include file:

    `class HelloWorld : public cocos2d::CCLayer, public BackbuttonDelegate
    {

    public:

    virtual bool onBackPressed(bool result);`
    

    Implement that function in your scene:

    `bool HelloWorld::onBackPressed(bool result)
    {

    return false; // if you want your game to exit

    do something and return true if you want your game not to exit but switch scene's.

    }`

    2013-07-17 20:08
  • pinky2012

    Has anyone come up with a solution to mingle XAML and Cocos2d-x on WP8 (so we can use ads, facebook, webviews etc.). It should be possible but I can’t get it to work.

    2013-07-17 20:11
  • jacob_m99

    thanks for the backbuttondelegate help

    I followed your instruction and it seams to not get the false when I want it to close the application.
    on the scene I added the fuction
    bool helloworld::onBackPressed(bool result) {
    return false;
    }

    I figured it out all the way to
    @bool CCApplication::onBacButton()
    {
    bool ff = true;
    if (m_pDelegate)
    ff=m_pDelegate~~>onBackPressed;
    return ff;
    }
    it looks to me that m_pDelegate is always null so it never gets to run
    ff=m_pDelegate~~>onBackPressed(false);
    so then ff is always true since its set to true on the first line.

    on an earlier post it said something about
    OnEnter:
    CCApplication::sharedApplication()->setBackDelegate(this);

    OnExit
    CCApplication::sharedApplication()->setBackDelegate(null);

    where would that go.?

    2013-07-24 19:02
  • muhammadsaad

    I am facing a problem with custom fonts. when i add a font it gets a reddish color. i have no idea what the problem is. this is how im doing it
    scoreText = CCLabelTTF::create((scoreValue).c_str(), “BlackBoard.ttf”, 20);
    scoreText~~>setPosition);
    this~~>addChild(scoreText, 3);

    Any help?

    2013-08-06 06:40
  • kirjushyk

    Hi, Muhammad Saad.

    I faced the same proble when ported my game to WP8.
    I solved it by changing

    unsigned char pixelValNew[PIXEL_WIDTH] = { 255, pix, pix, pix };

    to

    unsigned char pixelValNew[PIXEL_WIDTH] = { pix, pix, pix, pix };

    in platform\win8_metro\FTTextPainter.cpp

    2013-09-24 11:46
  • kirjushyk

    Abadoned? Any news? I wanna update :) Hey, fellows, let’s continue work on WP8. I can help.

    2013-09-30 10:51
  • saudahmed

    Hi Kyrylo Polezhaiev,

    I want to open a link to internet explorer on windows phone 8 from within my app. I also want to open an email composer. These api’s are available in native C-sharp. There is a concept like launchers. But on Visual C++ side this functionality is not available in Windows api. I have done these for my windows 8 app but these set of apis have not been implemented for windows phone8. Any work around?

    2013-10-01 09:17
  • saudahmed

    Anybody has an idea how to call applicationdidenterbackground and applicationdidenterforeground of Appdelegate. Uptill now this is not being evoked when app goes to homescreen and returns back from home screen.

    2013-10-01 10:05
  • Vladimir_BL

    To launch IE from WP8 native application I use:
    static std::wstring stows(const std::string& s)
    {
    std::wstring ws;
    ws.assign(s.begin(), s.end());
    return ws;
    }
    void appOpenURL(const char *url)
    {
    // Create a Uri object from a URI string
    auto uri = ref new Windows::Foundation::Uri(ref new Platform::String(stows(url).c_str()));
    try
    {
    // Launch the URI
    Windows::System::Launcher::LaunchUriAsync(uri);
    }
    catch (…)
    {
    }
    }

    2013-10-01 11:48
  • elanser

    Hello community! :)
    This is the last version cocos2d-x 2.x for wp8: https://github.com/QiMa/Cocos2dWindows

    2013-10-12 02:51

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps