Browse Source

添加背景音乐

master
song 4 years ago
parent
commit
a0fd216448
  1. BIN
      public/RECOVER_source-code.fla
  2. BIN
      public/sounds/bgmMusic.mp3
  3. BIN
      public/source-code.fla
  4. 20
      public/source-code.js
  5. 16
      src/classes/main.js
  6. 16
      src/test.js

BIN
public/恢复_source-code.fla → public/RECOVER_source-code.fla

Binary file not shown.

BIN
public/sounds/bgmMusic.mp3

Binary file not shown.

BIN
public/source-code.fla

Binary file not shown.

20
public/source-code.js

@ -2306,16 +2306,13 @@ if (reversed == null) { reversed = false; }
var props = new Object(); var props = new Object();
props.mode = mode; props.mode = mode;
props.startPosition = startPosition; props.startPosition = startPosition;
props.labels = {"action-1":2,"action-2":25,"action-3":44,"action-4":75,"action-5":104,"action-6":145,"action-7":174,"action-8":205,"action-9":235,"action-10":284,"action-11":324,"action-12":445,"action-13":476,"action-14":505,"action-15":534,"action-16":606}; props.labels = {"action-1":15,"action-2":44,"action-3":75,"action-4":104,"action-5":145,"action-6":174,"action-7":205,"action-8":235,"action-9":284,"action-10":330,"action-11":417,"action-12":445,"action-13":476,"action-14":505,"action-15":534,"action-16":609};
props.loop = loop; props.loop = loop;
props.reversed = reversed; props.reversed = reversed;
cjs.MovieClip.apply(this,[props]); cjs.MovieClip.apply(this,[props]);
// timeline functions: // timeline functions:
this.frame_2 = function() { this.frame_15 = function() {
this.stop();
}
this.frame_25 = function() {
this.stop(); this.stop();
} }
this.frame_44 = function() { this.frame_44 = function() {
@ -2342,7 +2339,10 @@ if (reversed == null) { reversed = false; }
this.frame_284 = function() { this.frame_284 = function() {
this.stop(); this.stop();
} }
this.frame_324 = function() { this.frame_330 = function() {
this.stop();
}
this.frame_417 = function() {
this.stop(); this.stop();
} }
this.frame_445 = function() { this.frame_445 = function() {
@ -2355,14 +2355,14 @@ if (reversed == null) { reversed = false; }
this.stop(); this.stop();
} }
this.frame_534 = function() { this.frame_534 = function() {
this.stop(); this.stop()
} }
this.frame_606 = function() { this.frame_609 = function() {
this.stop() this.stop()
} }
// actions tween: // actions tween:
this.timeline.addTween(cjs.Tween.get(this).wait(2).call(this.frame_2).wait(23).call(this.frame_25).wait(19).call(this.frame_44).wait(31).call(this.frame_75).wait(29).call(this.frame_104).wait(41).call(this.frame_145).wait(29).call(this.frame_174).wait(31).call(this.frame_205).wait(30).call(this.frame_235).wait(49).call(this.frame_284).wait(40).call(this.frame_324).wait(121).call(this.frame_445).wait(31).call(this.frame_476).wait(29).call(this.frame_505).wait(29).call(this.frame_534).wait(72).call(this.frame_606).wait(4)); this.timeline.addTween(cjs.Tween.get(this).wait(15).call(this.frame_15).wait(29).call(this.frame_44).wait(31).call(this.frame_75).wait(29).call(this.frame_104).wait(41).call(this.frame_145).wait(29).call(this.frame_174).wait(31).call(this.frame_205).wait(30).call(this.frame_235).wait(49).call(this.frame_284).wait(46).call(this.frame_330).wait(87).call(this.frame_417).wait(28).call(this.frame_445).wait(31).call(this.frame_476).wait(29).call(this.frame_505).wait(29).call(this.frame_534).wait(75).call(this.frame_609).wait(1));
// mask // mask
this.shape = new cjs.Shape(); this.shape = new cjs.Shape();
@ -2375,7 +2375,7 @@ if (reversed == null) { reversed = false; }
this.instance = new lib._218d7f87fgfh("single",20); this.instance = new lib._218d7f87fgfh("single",20);
this.instance.setTransform(771.2,337.55,1,1,0,0,0,30,26); this.instance.setTransform(771.2,337.55,1,1,0,0,0,30,26);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(2).to({startPosition:20},0).wait(23).to({startPosition:0},0).wait(19).to({startPosition:1},0).wait(31).to({startPosition:2},0).wait(29).to({startPosition:3},0).wait(41).to({startPosition:4},0).wait(29).to({startPosition:5},0).wait(31).to({startPosition:6},0).wait(30).to({startPosition:7},0).wait(49).to({startPosition:8},0).wait(40).to({startPosition:9},0).wait(121).to({startPosition:10},0).wait(31).to({startPosition:11},0).wait(29).to({startPosition:12},0).wait(29).to({startPosition:13},0).wait(32).to({startPosition:14},0).wait(44)); this.timeline.addTween(cjs.Tween.get(this.instance).wait(15).to({startPosition:20},0).wait(29).to({startPosition:0},0).wait(31).to({startPosition:1},0).wait(29).to({startPosition:2},0).wait(41).to({startPosition:3},0).wait(29).to({startPosition:4},0).wait(31).to({startPosition:5},0).wait(30).to({startPosition:6},0).wait(49).to({startPosition:7},0).wait(46).to({startPosition:8},0).wait(87).to({startPosition:9},0).wait(28).to({startPosition:10},0).wait(31).to({startPosition:11},0).wait(29).to({startPosition:12},0).wait(29).to({startPosition:13},0).wait(32).to({startPosition:14},0).wait(44));
// score-bg // score-bg
this.shape_1 = new cjs.Shape(); this.shape_1 = new cjs.Shape();

16
src/classes/main.js

@ -55,6 +55,7 @@ Main.prototype.play = function (direction) {
this.times += 1; this.times += 1;
this.computeScore(this.times, direction); this.computeScore(this.times, direction);
this.setMusic(direction);
this.prevTime = Date.now(); this.prevTime = Date.now();
if (this.times >= this.max) { if (this.times >= this.max) {
@ -76,3 +77,18 @@ Main.prototype.computeScore = function (times, direction = 0) {
sendMessage({ event: 'play', data: { currentTimes: times, currentScore: config.currentScore } }); sendMessage({ event: 'play', data: { currentTimes: times, currentScore: config.currentScore } });
} }
}; };
Main.prototype.setMusic = function (direction) {
let audio1 = document.getElementById('audio1');
let audio2 = document.getElementById('audio2');
let audio3 = document.getElementById('audio3');
if (direction === 0) {
audio1.play();
}
if (direction === 1) {
audio2.play();
}
if (direction === 2) {
audio3.play();
}
};

16
src/test.js

@ -53,22 +53,6 @@ function test() {
if (!isDemo) return; if (!isDemo) return;
const code = config.config.directions[config.currentTimes]; const code = config.config.directions[config.currentTimes];
main.play(code); main.play(code);
setMusic(code);
}); });
} }
test(); test();
function setMusic(code) {
var audio1 = document.getElementById('audio1');
var audio2 = document.getElementById('audio2');
var audio3 = document.getElementById('audio3');
if (code === 0) {
audio1.play();
}
if (code === 1) {
audio2.play();
}
if (code === 2) {
audio3.play();
}
}

Loading…
Cancel
Save