bgm autoreplay
This commit is contained in:
parent
a9301f7cd9
commit
25ac0e13cb
@ -1,32 +1,18 @@
|
||||
(function () {
|
||||
fs = {};
|
||||
var postsomething = function (data, _ip, callback) {
|
||||
//callback:function(err, data)
|
||||
//data:字符串
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
switch (xhr.readyState) {
|
||||
case 4 :
|
||||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
|
||||
if (Boolean(callback)) {
|
||||
if (xhr.responseText.slice(0, 6) == 'error:') {
|
||||
callback(xhr.responseText, null);
|
||||
} else {
|
||||
callback(null, xhr.responseText);
|
||||
}
|
||||
}
|
||||
//printf(xhr.responseText)
|
||||
} else {
|
||||
if (Boolean(callback)) callback(xhr.status, null);
|
||||
//printf('error:' + xhr.status+'<br>'+(xhr.responseText||''));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
xhr.open('post', _ip);
|
||||
xhr.setRequestHeader('Content-Type', 'text/plain');
|
||||
if (typeof(data) == typeof([][0]) || data == null) data = JSON.stringify({1: 2});
|
||||
xhr.send(data);
|
||||
core.http("POST", _ip, data, function (data) {
|
||||
if (data.slice(0, 6) == 'error:') {
|
||||
callback(data, null);
|
||||
}
|
||||
else {
|
||||
callback(null, data);
|
||||
}
|
||||
}, function (e) {
|
||||
console.log(e);
|
||||
callback(e+":请检查启动服务是否处于正常运行状态。");
|
||||
}, "text/plain; charset=x-user-defined");
|
||||
}
|
||||
|
||||
fs.readFile = function (filename, encoding, callback) {
|
||||
|
||||
@ -2138,11 +2138,10 @@ control.prototype.playBgm = function (bgm) {
|
||||
core.material.bgms[core.musicStatus.playingBgm].pause();
|
||||
}
|
||||
// 播放当前BGM
|
||||
core.musicStatus.playingBgm = bgm;
|
||||
core.material.bgms[bgm].volume = core.musicStatus.volume;
|
||||
core.material.bgms[bgm].play();
|
||||
core.musicStatus.playingBgm = bgm;
|
||||
core.musicStatus.isPlaying = true;
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
console.log("无法播放BGM "+bgm);
|
||||
|
||||
13
main.js
13
main.js
@ -457,6 +457,10 @@ main.statusBar.image.settings.onclick = function () {
|
||||
main.dom.playGame.onclick = function () {
|
||||
main.dom.startButtons.style.display='none';
|
||||
|
||||
if (main.core.isset(main.core.musicStatus) && main.core.musicStatus.startDirectly
|
||||
&& main.core.musicStatus.bgmStatus && main.core.musicStatus.playingBgm==null)
|
||||
main.core.playBgm(main.core.bgms[0]);
|
||||
|
||||
if (main.core.isset(main.core.flags.startDirectly) && main.core.flags.startDirectly) {
|
||||
core.events.startGame("");
|
||||
}
|
||||
@ -467,12 +471,21 @@ main.dom.playGame.onclick = function () {
|
||||
|
||||
////// 点击“载入游戏”时 //////
|
||||
main.dom.loadGame.onclick = function() {
|
||||
|
||||
if (main.core.isset(main.core.musicStatus) && main.core.musicStatus.startDirectly
|
||||
&& main.core.musicStatus.bgmStatus && main.core.musicStatus.playingBgm==null)
|
||||
main.core.playBgm(main.core.bgms[0]);
|
||||
|
||||
main.core.load();
|
||||
}
|
||||
|
||||
////// 点击“录像回放”时 //////
|
||||
main.dom.replayGame.onclick = function () {
|
||||
|
||||
if (main.core.isset(main.core.musicStatus) && main.core.musicStatus.startDirectly
|
||||
&& main.core.musicStatus.bgmStatus && main.core.musicStatus.playingBgm==null)
|
||||
main.core.playBgm(main.core.bgms[0]);
|
||||
|
||||
core.readFile(function (obj) {
|
||||
if (obj.name!=core.firstData.name) {
|
||||
alert("存档和游戏不一致!");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user