cocos2d-js 网络请求(GET)

    xiaoxiao2022-06-23  21

    /** * 网络请求过关 **/ 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(); },
    转载请注明原文地址: https://ju.6miu.com/read-1123440.html

    最新回复(0)