1、清理仓库

This commit is contained in:
贝密游戏
2017-12-21 23:04:13 +08:00
parent eeb1c9e07b
commit b52d442381
1317 changed files with 138642 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
bgVolume:1.0, // 背景音量
deskVolume:1.0, // 房间 房间音量
bgAudioID:-1 // 背景 音乐 id
},
// use this for initialization
init: function () {
var t = cc.sys.localStorage.getItem("bgVolume");
if(t != null){
this.bgVolume = parseFloat(t);
}
var t = cc.sys.localStorage.getItem("deskVolume");
if(t != null){
this. deskVolume = parseFloat(t);
}
cc.game.on(cc.game.EVENT_HIDE, function () {
cc.audioEngine.pauseAll();
});
cc.game.on(cc.game.EVENT_SHOW, function () {
cc.audioEngine.resumeAll();
});
},
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
getUrl:function(url){
return cc.url.raw("resources/sounds/" + url);
},
playBGM:function(url){
var audioUrl = this.getUrl(url);
if(this.bgAudioID >= 0){
cc.audioEngine.stop(this.bgAudioID);
}
this.bgAudioID = cc.audioEngine.play(audioUrl,true,this.bgVolume);
},
playSFX:function(url){
var audioUrl = this.getUrl(url);
if(this.sfxVolume > 0){
var audioId = cc.audioEngine.play(audioUrl,false,this.deskVolume);
}
},
setSFXVolume:function(v){
if(this.sfxVolume != v){
cc.sys.localStorage.setItem("deskVolume",v);
this.deskVolume = v;
}
},
getState:function(){
return cc.audioEngine.getState(this.bgAudioID);
},
setBGMVolume:function(v,force){
if(this.bgAudioID >= 0){
if(v > 0 && cc.audioEngine.getState(this.bgAudioID) === cc.audioEngine.AudioState.PAUSED){
cc.audioEngine.resume(this.bgAudioID);
}else if(v == 0){
cc.audioEngine.pause(this.bgAudioID);
}
}
if(this.bgVolume != v || force){
cc.sys.localStorage.setItem("bgVolume",v);
this.bgmVolume = v;
cc.audioEngine.setVolume(this.bgAudioID,v);
}
},
pauseAll:function(){
cc.audioEngine.pauseAll();
},
resumeAll:function(){
cc.audioEngine.resumeAll();
}
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "d983b1b1-aeb6-47b7-a57f-fdb08e9eb497",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,137 @@
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
statics:{
decode : function(_base64Str){
var BASE64_MAPPING = [
'A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X',
'Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n',
'o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3',
'4','5','6','7','8','9','+','/'
];
var _len = _base64Str.length;
var extra_Zero_Count = 0;
/**
*计算在进行BASE64编码的时候补了几个0
*/
if(_base64Str.charAt(_len-1) == '='){
//alert(_base64Str.charAt(_len-1));
//alert(_base64Str.charAt(_len-2));
if(_base64Str.charAt(_len-2) == '='){//两个等号说明补了4个0
extra_Zero_Count = 4;
_base64Str = _base64Str.substring(0 , _len-2);
}else{//一个等号说明补了2个0
extra_Zero_Count = 2;
_base64Str = _base64Str.substring(0 , _len - 1);
}
}
var binaryArray = [];
for(var i = 0 , len = _base64Str.length; i < len ; ++i){
var c = _base64Str.charAt(i);
for(var j = 0 , size = BASE64_MAPPING.length ; j < size ; ++j){
if(c == BASE64_MAPPING[j]){
var _tmp = this._toBinary(j);
/*不足6位的补0*/
var _tmpLen = _tmp.length;
if(6-_tmpLen > 0){
for(var k = 6-_tmpLen ; k > 0 ; --k){
_tmp.unshift(0);
}
}
binaryArray = binaryArray.concat(_tmp);
break;
}
}
}
if(extra_Zero_Count > 0){
binaryArray = binaryArray.slice(0 , binaryArray.length - extra_Zero_Count);
}
var unicode = [];
var unicodeBinary = [];
for(var i = 0 , len = binaryArray.length ; i < len ; ){
if(binaryArray[i] == 0){
unicode=unicode.concat(this._toDecimal(binaryArray.slice(i,i+8)));
i += 8;
}else{
var sum = 0;
while(i < len){
if(binaryArray[i] == 1){
++sum;
}else{
break;
}
++i;
}
unicodeBinary = unicodeBinary.concat(binaryArray.slice(i+1 , i+8-sum));
i += 8 - sum;
while(sum > 1){
unicodeBinary = unicodeBinary.concat(binaryArray.slice(i+2 , i+8));
i += 8;
--sum;
}
unicode = unicode.concat(this._toDecimal(unicodeBinary));
unicodeBinary = [];
}
}
return unicode;
},
_toBinary : function(ascii){
var binary = new Array();
while(ascii > 0){
var b = ascii%2;
ascii = Math.floor(ascii/2);
binary.push(b);
}
/*
var len = binary.length;
if(6-len > 0){
for(var i = 6-len ; i > 0 ; --i){
binary.push(0);
}
}*/
binary.reverse();
return binary;
},
_toDecimal : function(binary){
var dec = 0;
var p = 0;
for(var i = binary.length-1 ; i >= 0 ; --i){
var b = binary[i];
if(b == 1){
dec += Math.pow(2 , p);
}
++p;
}
return dec;
}
},
// use this for initialization
onLoad: function () {
},
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "8a9bc3e8-e066-4bd9-a62e-a92e466ecf3f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,112 @@
cc.VERSION = 2017061001;
var HTTP = cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
statics: {
baseURL:"http://192.168.1.155",
wsURL : "http://192.168.1.155:9081",
authorization: null,
httpGet: function (url , success , error , object) {
var xhr = cc.loader.getXMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if(xhr.status >= 200 && xhr.status < 300){
var respone = xhr.responseText;
if(success){
success(respone , object);
}
}else{
if(error){
error(object);
}
}
}
};
xhr.open("GET", HTTP.baseURL+url, true);
if(HTTP.authorization != null){
xhr.setRequestHeader("authorization", HTTP.authorization) ;
}
if (cc.sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
}
//超时回调
xhr.ontimeout = function(event){
error(object);
};
xhr.onerror = function(event){
error(object);
};
// note: In Internet Explorer, the timeout property may be set only after calling the open()
// method and before calling the send() method.
xhr.timeout = 3000;// 5 seconds for timeout
xhr.send();
},
encodeFormData : function(data)
{
var pairs = [];
var regexp = /%20/g;
for (var name in data){
var value = data[name].toString();
var pair = encodeURIComponent(name).replace(regexp, "+") + "=" +
encodeURIComponent(value).replace(regexp, "+");
pairs.push(pair);
}
return pairs.join("&");
},
httpPost: function (url, params, success , error , object) {
var xhr = cc.loader.getXMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if(xhr.status >= 200 && xhr.status < 300){
var respone = xhr.responseText;
if(success){
success(respone , object);
}
}else{
if(error){
error(object);
}
}
}
};
xhr.open("POST", HTTP.baseURL+url, true);
if(HTTP.authorization !== null){
xhr.setRequestHeader("authorization", HTTP.authorization) ;
}
if (cc.sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
}
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
// note: In Internet Explorer, the timeout property may be set only after calling the open()
// method and before calling the send() method.
xhr.timeout = 5000;// 5 seconds for timeout
xhr.send( HTTP.encodeFormData(params));
}
},
// use this for initialization
onLoad: function () {
},
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "bf727d78-b7e3-4048-9a7e-2757b9c2fd08",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "32da8e05-13e1-4f5f-b6c5-0eced61d4a7b",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "83e71045-b4c1-4751-9f2f-79f2fc631979",
"isPlugin": false,
"loadPluginInWeb": false,
"loadPluginInNative": false,
"loadPluginInEditor": false,
"subMetas": {}
}