Downloading and reading files

Downloading and reading files
0.0 0


Hello everyone,

I was wondering if the following was possible to do directly in Cocos2d-X (without needing to create separate code for Android and iOS):

  • Query a server by calling a php script to find out if there is an update (read the result as text or other and parse it)

  • Download an xml file as well as some images (if there is an update)

  • Read the xml file (using libxml I suppose if it can read downloaded files, not just ones in the bundle)

  • Display the images in game (with CCSprite if you can create them with downloaded files)

Thank you for any enlightenment


It’s possible to do that.
You can implement that by using curl library(it’s prebuilt… and you can test it with tests project.).


Thank you, I have managed to use libxml to read an xml file in the bundle, I am now going to look at curl to see how to download and save the file.


I am looking for the same solution too. It is easy to implement this using objective c.


Yes in Objective C I have already downloaded files and used them on another project but that was with Cocos2d iPhone.
Here the objective is to not have to write different code for iPhone and Android so I am avoiding Objective C if possible.

Currently I am trying to integrate the curl example in my project.
Next I will have to look how to save the data downloaded with curl to a file.


have a look at these two libs:
libcurl( a classic url downloader
easyget( a commercial file download library for IOS/Andriod/Windows