no commit message

This commit is contained in:
贝密游戏
2017-08-04 17:31:46 +08:00
parent 681cf88522
commit d076c849e4
13 changed files with 148 additions and 35 deletions

View File

@@ -33,9 +33,12 @@ cc.Class({
cc.tools.http.authorization = ret ; cc.tools.http.authorization = ret ;
cc.tools.http.httpGet("/tokens",function(ret){ cc.tools.http.httpGet("/tokens",function(ret){
//console.log(ret); //console.log(ret);
/**
* 后台交互需要token
**/
io("http://127.0.0.1:9081/bm/system?token="+cc.tools.http.authorization);
}); });
}); });
io("http://127.0.0.1:9081/im/user?userid=admin");
}, },
start:function(){ start:function(){
var self = this; var self = this;

View File

@@ -33,11 +33,9 @@ cc.Class({
} }
cc.game.on(cc.game.EVENT_HIDE, function () { cc.game.on(cc.game.EVENT_HIDE, function () {
console.log("cc.audioEngine.pauseAll");
cc.audioEngine.pauseAll(); cc.audioEngine.pauseAll();
}); });
cc.game.on(cc.game.EVENT_SHOW, function () { cc.game.on(cc.game.EVENT_SHOW, function () {
console.log("cc.audioEngine.resumeAll");
cc.audioEngine.resumeAll(); cc.audioEngine.resumeAll();
}); });
}, },
@@ -53,7 +51,6 @@ cc.Class({
playBGM(url){ playBGM(url){
var audioUrl = this.getUrl(url); var audioUrl = this.getUrl(url);
console.log(audioUrl);
if(this.bgAudioID >= 0){ if(this.bgAudioID >= 0){
cc.audioEngine.stop(this.bgAudioID); cc.audioEngine.stop(this.bgAudioID);
} }

File diff suppressed because one or more lines are too long

View File

@@ -39,11 +39,9 @@ cc.Class({
} }
cc.game.on(cc.game.EVENT_HIDE, function () { cc.game.on(cc.game.EVENT_HIDE, function () {
console.log("cc.audioEngine.pauseAll");
cc.audioEngine.pauseAll(); cc.audioEngine.pauseAll();
}); });
cc.game.on(cc.game.EVENT_SHOW, function () { cc.game.on(cc.game.EVENT_SHOW, function () {
console.log("cc.audioEngine.resumeAll");
cc.audioEngine.resumeAll(); cc.audioEngine.resumeAll();
}); });
}, },
@@ -59,7 +57,6 @@ cc.Class({
playBGM: function playBGM(url) { playBGM: function playBGM(url) {
var audioUrl = this.getUrl(url); var audioUrl = this.getUrl(url);
console.log(audioUrl);
if (this.bgAudioID >= 0) { if (this.bgAudioID >= 0) {
cc.audioEngine.stop(this.bgAudioID); cc.audioEngine.stop(this.bgAudioID);
} }

File diff suppressed because one or more lines are too long

View File

@@ -39,9 +39,12 @@ cc.Class({
cc.tools.http.authorization = ret; cc.tools.http.authorization = ret;
cc.tools.http.httpGet("/tokens", function (ret) { cc.tools.http.httpGet("/tokens", function (ret) {
//console.log(ret); //console.log(ret);
/**
* 后台交互需要token
**/
io("http://127.0.0.1:9081/bm/system?token=" + cc.tools.http.authorization);
}); });
}); });
io("http://127.0.0.1:9081/im/user?userid=admin");
}, },
start: function start() { start: function start() {
var self = this; var self = this;

View File

@@ -1 +1 @@
{"version":3,"sources":["assets\\script\\components\\loading.js"],"names":["cc","Class","extends","Component","properties","_progress","_splash","_isLoading","onLoad","sys","isNative","isMobile","canvas","node","getComponent","Canvas","fitHeight","fitWidth","initMgr","find","active","tools","audio","playBGM","xhr","http","httpPost","username","password","ret","authorization","httpGet","io","start","self","SHOW_TIME","FADE_TIME","os","OS_IOS","require","Audio","init","window","SocketIO"],"mappings":";;;;;;AAAAA,GAAGC,KAAH,CAAS;AACLC,aAASF,GAAGG,SADP;;AAGLC,gBAAY;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAC,mBAAU,GAXF;AAYRC,iBAAQ,IAZA;AAaRC,oBAAW;AAbH,KAHP;;AAmBL;AACAC,YAAQ,kBAAY;AAChB,YAAG,CAACR,GAAGS,GAAH,CAAOC,QAAR,IAAoBV,GAAGS,GAAH,CAAOE,QAA9B,EAAuC;AACnC,gBAAIC,SAAS,KAAKC,IAAL,CAAUC,YAAV,CAAuBd,GAAGe,MAA1B,CAAb;AACAH,mBAAOI,SAAP,GAAmB,IAAnB;AACAJ,mBAAOK,QAAP,GAAkB,IAAlB;AACH;AACD,aAAKC,OAAL;AACA,aAAKZ,OAAL,G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ACH,SAFD,MAEK;AACDD,mBAAOV,EAAP,GAAYO,QAAQ,WAAR,CAAZ;AACH;AACJ;;AA9DI,CAAT","file":"unknown","sourcesContent":["cc.Class({\r\n extends: cc.Component,\r\n\r\n properties: {\r\n // foo: {\r\n // default: null, // The default value will be used only when the component attaching\r\n // to a node for the first time\r\n // url: cc.Texture2D, // optional, default is typeof default\r\n // serializable: true, // optional, default is true\r\n // visible: true, // optional, default is true\r\n // displayName: 'Foo', // optional\r\n // readonly: false, // optional, default is false\r\n // },\r\n // ...\r\n _progress:0.0,\r\n _splash:null,\r\n _isLoading:false\r\n },\r\n\r\n // use this for initialization\r\n onLoad: function () {\r\n if(!cc.sys.isNative && cc.sys.isMobile){\r\n var canvas = this.node.getComponent(cc.Canvas);\r\n canvas.fitHeight = true;\r\n canvas.fitWidth = true;\r\n }\r\n this.initMgr();\r\n this._splash = cc.find(\"Canvas/splash\");\r\n this._splash.active = true;\r\n \r\n cc.tools.audio.playBGM(\"bgMain.mp3\");\r\n var xhr = cc.tools.http.httpPost(\"/tokens\",{username:'admin',password:'123456'},function(ret){\r\n cc.tools.http.authorization = ret ;\r\n cc.tools.http.httpGet(\"/tokens\",function(ret){\r\n //console.log(ret);\r\n });\r\n });\r\n io(\"http://127.0.0.1:9081/im/user?userid=admin\");\r\n },\r\n start:function(){ \r\n var self = this;\r\n var SHOW_TIME = 3000;\r\n var FADE_TIME = 500;\r\n if(cc.sys.os != cc.sys.OS_IOS || !cc.sys.isNative){\r\n self._splash.active = true;\r\n }else{\r\n self._splash.active = false;\r\n }\r\n },\r\n initMgr:function(){\r\n cc.tools = {}; \r\n cc.tools.http = require(\"HTTP\");\r\n \r\n var Audio = require(\"Audio\");\r\n cc.tools.audio = new Audio();\r\n cc.tools.audio.init();\r\n \r\n if(cc.sys.isNative){\r\n window.io = SocketIO;\r\n }else{\r\n window.io = require(\"socket.io\"); \r\n }\r\n }\r\n\r\n});\r\n"]} {"version":3,"sources":["assets\\script\\components\\loading.js"],"names":["cc","Class","extends","Component","properties","_progress","_splash","_isLoading","onLoad","sys","isNative","isMobile","canvas","node","getComponent","Canvas","fitHeight","fitWidth","initMgr","find","active","tools","audio","playBGM","xhr","http","httpPost","username","password","ret","authorization","httpGet","io","start","self","SHOW_TIME","FADE_TIME","os","OS_IOS","require","Audio","init","window","SocketIO"],"mappings":";;;;;;AAAAA,GAAGC,KAAH,CAAS;AACLC,aAASF,GAAGG,SADP;;AAGLC,gBAAY;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAC,mBAAU,GAXF;AAYRC,iBAAQ,IAZA;AAaRC,oBAAW;AAbH,KAHP;;AAmBL;AACAC,YAAQ,kBAAY;AAChB,YAAG,CAACR,GAAGS,GAAH,CAAOC,QAAR,IAAoBV,GAAGS,GAAH,CAAOE,QAA9B,EAAuC;AACnC,gBAAIC,SAAS,KAAKC,IAAL,CAAUC,YAAV,CAAuBd,GAAGe,MAA1B,CAAb;AACAH,mBAAOI,SAAP,GAAmB,IAAnB;AACAJ,mBAAOK,QAAP,GAAkB,IAAlB;AACH;AACD,aAAKC,OAAL;AACA,aAAKZ,OAAL,GAAeN,GAAGmB,IAAH,CAAQ,eAAR,CAAf;AACA,aAAKb,OAAL,CAAac,MAAb,GAAsB,IAAtB;;AAEApB,WAAGqB,KAAH,CAASC,KAAT,CAAeC,OAAf,CAAuB,YAAvB;AACA,YAAIC,MAAMxB,GAAGqB,KAAH,CAASI,IAAT,CAAcC,QAAd,CAAuB,SAAvB,EAAiC,EAACC,UAAS,OAAV,EAAkBC,UAAS,QAA3B,EAAjC,EAAsE,UAASC,GAAT,EAAa;AACzF7B,eAAGqB,KAAH,CAASI,IAAT,CAAcK,aAAd,GAA8BD,GAA9B;AACA7B,eAAGqB,KAAH,CAASI,IAAT,CAAcM,OAAd,CAAsB,SAAtB,EAAgC,UAASF,GAAT,EAAa;AACzC;AACA;;;AAGAG,mBAAG,2CAAyChC,GAAGqB,KAAH,CAASI,IAAT,CAAcK,aAA1D;AACH,aAND;AAOH,SATS,CAAV;AAUH,KAzCI;AA0CLG,WAAM,iBAAU;AACZ,YAAIC,OAAO,IAAX;AACA,YAAIC,YAAY,IAAhB;AACA,YAAIC,YAAY,GAAhB;AACA,YAAGpC,GAAGS,GAAH,CAAO4B,EAAP,IAAarC,GAAGS,GAAH,CAAO6B,MAApB,IAA8B,CAACtC,GAAGS,GAAH,CAAOC,QAAzC,EAAkD;AAC9CwB,iBAAK5B,OAAL,CAAac,MAAb,GAAuB,IAAvB;AACH,SAFD,MAEK;AACDc,iBAAK5B,OAAL,CAAac,MAAb,GAAsB,KAAtB;AACH;AACJ,KAnDI;AAoDLF,aAAQ,mBAAU;AACdlB,WAAGqB,KAAH,GAAW,EAAX;AACArB,WAAGqB,KAAH,CAASI,IAAT,GAAgBc,QAAQ,MAAR,CAAhB;;AAEA,YAAIC,QAAQD,QAAQ,OAAR,CAAZ;AACAvC,WAAGqB,KAAH,CAASC,KAAT,GAAiB,IAAIkB,KAAJ,EAAjB;AACAxC,WAAGqB,KAAH,CAASC,KAAT,CAAemB,IAAf;;AAEA,YAAGzC,GAAGS,GAAH,CAAOC,QAAV,EAAmB;AACfgC,mBAAOV,EAAP,GAAYW,QAAZ;AACH,SAFD,MAEK;AACDD,mBAAOV,EAAP,GAAYO,QAAQ,WAAR,CAAZ;AACH;AACJ;;AAjEI,CAAT","file":"unknown","sourcesContent":["cc.Class({\r\n extends: cc.Component,\r\n\r\n properties: {\r\n // foo: {\r\n // default: null, // The default value will be used only when the component attaching\r\n // to a node for the first time\r\n // url: cc.Texture2D, // optional, default is typeof default\r\n // serializable: true, // optional, default is true\r\n // visible: true, // optional, default is true\r\n // displayName: 'Foo', // optional\r\n // readonly: false, // optional, default is false\r\n // },\r\n // ...\r\n _progress:0.0,\r\n _splash:null,\r\n _isLoading:false\r\n },\r\n\r\n // use this for initialization\r\n onLoad: function () {\r\n if(!cc.sys.isNative && cc.sys.isMobile){\r\n var canvas = this.node.getComponent(cc.Canvas);\r\n canvas.fitHeight = true;\r\n canvas.fitWidth = true;\r\n }\r\n this.initMgr();\r\n this._splash = cc.find(\"Canvas/splash\");\r\n this._splash.active = true;\r\n \r\n cc.tools.audio.playBGM(\"bgMain.mp3\");\r\n var xhr = cc.tools.http.httpPost(\"/tokens\",{username:'admin',password:'123456'},function(ret){\r\n cc.tools.http.authorization = ret ;\r\n cc.tools.http.httpGet(\"/tokens\",function(ret){\r\n //console.log(ret);\r\n /**\r\n * 后台交互需要token \r\n **/ \r\n io(\"http://127.0.0.1:9081/bm/system?token=\"+cc.tools.http.authorization);\r\n });\r\n });\r\n },\r\n start:function(){ \r\n var self = this;\r\n var SHOW_TIME = 3000;\r\n var FADE_TIME = 500;\r\n if(cc.sys.os != cc.sys.OS_IOS || !cc.sys.isNative){\r\n self._splash.active = true;\r\n }else{\r\n self._splash.active = false;\r\n }\r\n },\r\n initMgr:function(){\r\n cc.tools = {}; \r\n cc.tools.http = require(\"HTTP\");\r\n \r\n var Audio = require(\"Audio\");\r\n cc.tools.audio = new Audio();\r\n cc.tools.audio.init();\r\n \r\n if(cc.sys.isNative){\r\n window.io = SocketIO;\r\n }else{\r\n window.io = require(\"socket.io\"); \r\n }\r\n }\r\n\r\n});\r\n"]}

View File

@@ -270,13 +270,13 @@
"relativePath": "script\\lib" "relativePath": "script\\lib"
}, },
"cb804921-c57f-4d32-84f3-5ba70007a34b": { "cb804921-c57f-4d32-84f3-5ba70007a34b": {
"asset": 1501773146837, "asset": 1501838529889,
"meta": 1501774010773, "meta": 1501838529988,
"relativePath": "script\\components\\loading.js" "relativePath": "script\\components\\loading.js"
}, },
"088657d1-aafb-450b-8525-cc8d95776cca": { "088657d1-aafb-450b-8525-cc8d95776cca": {
"asset": 1501772748687, "asset": 1501839082182,
"meta": 1501772749750, "meta": 1501839082361,
"relativePath": "script\\lib\\Audio.js" "relativePath": "script\\lib\\Audio.js"
}, },
"fb977eef-db8f-432a-8f42-bf3d8d970e95": { "fb977eef-db8f-432a-8f42-bf3d8d970e95": {

View File

@@ -20,7 +20,7 @@
], ],
"height": 468.984375, "height": 468.984375,
"type": "panel", "type": "panel",
"width": 310 "width": 334
}, },
{ {
"active": 0, "active": 0,
@@ -29,12 +29,12 @@
], ],
"height": 440, "height": 440,
"type": "panel", "type": "panel",
"width": 310 "width": 334
} }
], ],
"height": 912, "height": 912,
"type": "dock-v", "type": "dock-v",
"width": 310 "width": 334
}, },
{ {
"children": [ "children": [
@@ -45,23 +45,23 @@
"children": [ "children": [
"scene" "scene"
], ],
"height": 440, "height": 683,
"type": "panel", "type": "panel",
"width": 814.984375 "width": 912.984375
}, },
{ {
"active": 0, "active": 0,
"children": [ "children": [
"node-library" "node-library"
], ],
"height": 440, "height": 683,
"type": "panel", "type": "panel",
"width": 311 "width": 347.984375
} }
], ],
"height": 440, "height": 683,
"type": "dock-h", "type": "dock-h",
"width": 1128.984375 "width": 1263.984375
}, },
{ {
"active": 0, "active": 0,
@@ -69,14 +69,14 @@
"console", "console",
"timeline" "timeline"
], ],
"height": 468.984375, "height": 226,
"type": "panel", "type": "panel",
"width": 1128.984375 "width": 1263.984375
} }
], ],
"height": 912, "height": 912,
"type": "dock-v", "type": "dock-v",
"width": 1128.984375 "width": 1263.984375
}, },
{ {
"active": 0, "active": 0,
@@ -85,7 +85,7 @@
], ],
"height": 912, "height": 912,
"type": "panel", "type": "panel",
"width": 463 "width": 304
} }
], ],
"type": "dock-h" "type": "dock-h"
@@ -99,6 +99,19 @@
"node-library", "node-library",
"timeline" "timeline"
] ]
},
"window-1501839040808": {
"main": false,
"url": "packages://code-editor/panel/index.html",
"windowType": "simple",
"x": -9,
"y": -9,
"width": 1932,
"height": 1048,
"layout": null,
"panels": [
"code-editor"
]
} }
}, },
"panels": { "panels": {

View File

@@ -1 +1 @@
{"D:\\wordspace\\program\\beimi\\Client\\beimi\\library\\imports\\08\\088657d1-aafb-450b-8525-cc8d95776cca.js":{"size":3053,"mtime":1501772749721},"D:\\wordspace\\program\\beimi\\Client\\beimi\\library\\imports\\9e\\9e146e9e-d85e-4863-b061-aece26cbd6c3.js":{"size":1075,"mtime":1501772749509},"D:\\wordspace\\program\\beimi\\Client\\beimi\\library\\imports\\fb\\fb977eef-db8f-432a-8f42-bf3d8d970e95.js":{"size":3596,"mtime":1501772749740},"D:\\wordspace\\program\\beimi\\Client\\beimi\\library\\imports\\c3\\c3362f07-3cd8-4e58-8025-6ae3c744fd20.js":{"size":243069,"mtime":1501774020103},"D:\\wordspace\\program\\beimi\\Client\\beimi\\library\\imports\\cb\\cb804921-c57f-4d32-84f3-5ba70007a34b.js":{"size":2211,"mtime":1501774010763}} {"D:\\wordspace\\program\\beimi\\chess\\client\\beimi\\library\\imports\\c3\\c3362f07-3cd8-4e58-8025-6ae3c744fd20.js":{"size":243069,"mtime":1501774020103},"D:\\wordspace\\program\\beimi\\chess\\client\\beimi\\library\\imports\\9e\\9e146e9e-d85e-4863-b061-aece26cbd6c3.js":{"size":1075,"mtime":1501772749509},"D:\\wordspace\\program\\beimi\\chess\\client\\beimi\\library\\imports\\08\\088657d1-aafb-450b-8525-cc8d95776cca.js":{"size":2917,"mtime":1501839082352},"D:\\wordspace\\program\\beimi\\chess\\client\\beimi\\library\\imports\\fb\\fb977eef-db8f-432a-8f42-bf3d8d970e95.js":{"size":3596,"mtime":1501772749740},"D:\\wordspace\\program\\beimi\\chess\\client\\beimi\\library\\imports\\cb\\cb804921-c57f-4d32-84f3-5ba70007a34b.js":{"size":2333,"mtime":1501838529980}}

File diff suppressed because one or more lines are too long

View File

@@ -33,9 +33,12 @@ cc.Class({
cc.tools.http.authorization = ret ; cc.tools.http.authorization = ret ;
cc.tools.http.httpGet("/tokens",function(ret){ cc.tools.http.httpGet("/tokens",function(ret){
//console.log(ret); //console.log(ret);
/**
* 后台交互需要token
**/
io("http://127.0.0.1:9081/bm/system?token="+cc.tools.http.authorization);
}); });
}); });
io("http://127.0.0.1:9081/im/user?userid=admin");
}, },
start:function(){ start:function(){
var self = this; var self = this;

View File

@@ -0,0 +1,97 @@
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(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(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;
}
},
setBGMVolume:function(v,force){
if(this.bgAudioID >= 0){
if(v > 0){
cc.audioEngine.resume(this.bgAudioID);
}
else{
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();
}
});