duanguochi6194 2013-05-08 13:03
浏览 53
已采纳

在Cocos2d Javascript游戏中将文件保存到服务器

I've been struggling with this for a while and eventually gave up on inpementing any sort of savegame option client side with my cocos2d javascript game (structure based on this tutorial http://www.raywenderlich.com/33028/how-to-make-a-cross-platform-game-with-cocos2d-javascript-tutorial-the-platforms .. thx Ray .. ) Now i'm trying to find a way to save xml files to a webserver while running my game, firstly in a browser (because that seems the most straightforward way to get this going) and then hopefully later as an app that can access that same webserver.

I have a fair idea how to generate the xml from my array objects and I realise php is my friend when it comes to writing that xml file to disk on the server side. I've even heard of his pal AJAX that seems to have his contact details : )

My biggest problem at the moment is that the AJAX exampes I have found all use jquery. I realise this might be to simplify the cross browser compatibility issues but I can't fiure out how to add JQuery functionality to the JS in my game (probably stupidly basic or impossible as it will mess up all the bindings, I don't know). Most examples assume were doing all this straight form a browser script so any help with that would be great.

If jquery is a no go , does anyone have and example of how to send xml data in any format to php?
I'm sure there are enough tutorials out there on how to hande things from there...

If there is a simpler or better way to save savegames locally or on a server using the cocos2d javascript idea i'd be happy to hear it.

Thx..

Edit

I have managed to figure out that the simple answer to the jquery option (at least when deploying to web) is to include jquery at the top of the cocos2d.js file where all the other js files are loaded... might not be a sound option when it comes to porting it all to iphone though.

  • 写回答

1条回答 默认 最新

  • donmqryh49993 2013-08-17 15:01
    关注

    sys.localstorage is the way to save data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭