/**
* 网络请求过关
**/
gameover:function(url){
var self = this ;
var xhr = cc.loader.getXMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader("Content-Type","text/plain;charset=UTF-8");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status <= 207)) {
var response = xhr.responseText;
//json 解析
var jsonData = JSON.parse(response);
var code = jsonData["code"];
if(code == 1){
self.successSprite.getComponent(cc.Animation).play('resAnimate');
}
}
};
xhr.send();
},
cocos2d-js 网络请求(GET)
最新推荐文章于 2023-10-18 11:11:08 发布