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 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了