News

A trap of adding resources into cocos2dx-wp8 project

By lihex Posted 2012-11-06 09:04 Comments 13

If you download the previous version of cocos2dx-0.13.0-wp8-0.8.zip, you will find some test cases that has marked as pass but can not run properly on wp8 devices.
We sincerely regret this error, as it was caused by our sloppiness

I’ll explain why it is not running correctly on devices in debug mode.

In the project of the cocos2dx-wp8, game resources are placed in the Assets directory, this directory is also the root directory of the game resources:

If you want to create a sprite from a picture:

    CCSprite :: spriteWithFile ("Image / sprite.png");

It will read as:

    "App / Install / PATH / Assets / Image / sprite.png "

Not only we need to copy the game resources to the Assets directory, but also add each resource file to the VS project.
So how do we do it specifically?

For example to add sprite.png:

  1. Select Assets filter
  2. Right click > Add New Filter, named it Image # Select Image filter # Right click> Add Existing Item…
  3. Choose the \$YOUR_PROJECT/Assets/Image/sprite.png

This seems to work, but there are still problems:

The problem is, if we add a “sprite.plist” file, according to the above procedures, it is added to the project, but when you run the program, you will found that the program could not find “sprite.plist”!
Why is that? This problem has also plagued me for long time, fortunately, this has been resolved The reason is that only the file formats that Visual Studio can identify will be automatically packed into the app package, such as images: png, jpg. If you right-click to view the properties of these files, you will find the “Content field” is set as “Yes” and “Item Type” is set to properly type, such as “Image” in case of sprite.png
However VS does not recognize “plist”, so its Content is set to “No” and it’s “Item type” is set to “Does not participate in build”, which means plist files will not be packed into the application package.

The solution is very simple, that is to set the resource file Content field to “ Yes” , the Item type field to “Does not participate in build”.

The reason why it works in the Emulator but not on the physical devices is because Device Debugging configuration forgot to add those attributes to files.

The cocos2dx-0.13.0-wp8-0.8.zip was updated, Please download again with the same url.
Download Zipball: http://cocos2d-x.googlecode.com/files/cocos2dx-0.13.0-wp8-0.8.zip

Comments

  • jonsd3

    Nice posts,…I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here
    porno izle

    2014-01-15 07:07
  • jonsd3

    Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    sex game

    2014-01-15 09:25
  • asadalikhatri

    Online Allure Formula is a digital product and can be downloaded instantly after purchase in PDF (ebook) format or viewed online. The complete system includes a private members area with an interactive community, video training, PDF guides, and MP3 audio file.http://www.rebelmouse.com/onlinealluremichaelfiore

    2014-09-25 12:54
  • Muneer ahmed

    Established and family owned since 1983 and with over a quarter of century experience in sunless tanning products, Sun Laboratories, Inc. is the first professional self-tanning product manufacturer and distributor. Sothys

    2014-09-26 11:43
  • Muneer ahmed

    Your article is very interesting, make persistent efforts, I believe there will be more and more people are concerned about your article! claw foot tub

    2014-10-16 17:52
  • Muneer ahmed

    I have read your excellent post. This is a great job. I have enjoyed reading your post first time. I want to say thanks for this post. Thank you... logistika

    2014-10-19 10:57
  • sukh

    Contamos com o melhor pessoal com os melhores equipamentos do mercado para acabar de vez com o entupimento na sua casa."desentupidora zona oeste":http://www.mcdesentupidora.com.br/localizacao/desentupidora-zona-oeste

    2014-10-20 11:20
  • deborahphilip007

    You done certain good points there. I did a search on the subject and found nearly all persons will agree with your blog. <a href="http://www.primovpn.net" rel="follow">The Best VPN Service</a>

    2014-12-03 08:31
  • deborahphilip007

    I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The Best VPN Service

    2014-12-03 08:35

Copyright © 2010 - 2014 Cocos2d-x.org Support Email: support@cocos.org