Browse Source

更新代码

master
song 4 years ago
parent
commit
d30894db2d
  1. BIN
      public/RECOVER_跨栏(右脚)_HTML5 Canvas.fla
  2. BIN
      public/images/AA.png
  3. BIN
      public/images/Bitmap1.png
  4. BIN
      public/images/Bitmap2.png
  5. BIN
      public/images/Bitmap2_1.png
  6. BIN
      public/images/Bitmap3.png
  7. BIN
      public/images/Bitmap4.png
  8. BIN
      public/images/Bitmap5.png
  9. BIN
      public/images/_01.png
  10. BIN
      public/images/_02.png
  11. BIN
      public/images/level.png
  12. BIN
      public/images/source_code_atlas_2.png
  13. BIN
      public/images/stopDemo.png
  14. BIN
      public/images/suspend.png
  15. BIN
      public/images/任务完成_.png
  16. BIN
      public/images/倒计时_.png
  17. BIN
      public/images/再来一次_.png
  18. BIN
      public/images/计时_.png
  19. BIN
      public/images/跨栏右脚_HTML5Canvas_1.png
  20. BIN
      public/images/返回按钮_.png
  21. BIN
      public/sounds/audio2.mp3
  22. BIN
      public/sounds/bgmMusic.mp3
  23. 2864
      public/source-code.js
  24. BIN
      public/跨栏(右脚)_HTML5 Canvas.fla
  25. BIN
      public/跨栏(右脚)_HTML5-Canvas.png
  26. 7
      src/classes/main.js
  27. 33
      src/classes/sound.js
  28. 5
      src/classes/time.js
  29. 6
      src/custom.js
  30. 3
      src/index.js
  31. 3
      src/test.js

BIN
public/RECOVER_跨栏(右脚)_HTML5 Canvas.fla

Binary file not shown.

BIN
public/images/AA.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
public/images/Bitmap1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
public/images/Bitmap2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
public/images/Bitmap2_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
public/images/Bitmap3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
public/images/Bitmap4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
public/images/Bitmap5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
public/images/_01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
public/images/_02.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
public/images/level.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
public/images/source_code_atlas_2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

BIN
public/images/stopDemo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
public/images/suspend.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
public/images/任务完成_.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
public/images/倒计时_.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
public/images/再来一次_.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
public/images/计时_.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
public/images/跨栏右脚_HTML5Canvas_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
public/images/返回按钮_.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
public/sounds/audio2.mp3

Binary file not shown.

BIN
public/sounds/bgmMusic.mp3

Binary file not shown.

2864
public/source-code.js

File diff suppressed because it is too large

BIN
public/跨栏(右脚)_HTML5 Canvas.fla

Binary file not shown.

BIN
public/跨栏(右脚)_HTML5-Canvas.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

7
src/classes/main.js

@ -49,7 +49,12 @@ Main.prototype.init = function () {
// 游戏状态在进行中才能触发
// play次数 >= 最多完成次数 调用结束的callback
Main.prototype.play = function (direction) {
if (Date.now() - this.prevTime <= 1200 || state !== 1) return;
if (direction === 0) {
if (Date.now() - this.prevTime <= 4500 || state !== 1) return;
}
if (direction === 1) {
if (Date.now() - this.prevTime <= 3800 || state !== 1) return;
}
// if (state !== 1) return;
this.element.play();
if (direction === 99) return;

33
src/classes/sound.js

@ -21,6 +21,7 @@ Sound.prototype.init = function () {
const sounds = [
{ src: 'sounds/bgmMusic.mp3', id: 'bgm' },
{ src: 'sounds/audio1.mp3', id: 'audio1' },
{ src: 'sounds/audio2.mp3', id: 'audio2' },
];
const _this = this;
createjs.Sound.addEventListener('fileload', function (event) {
@ -34,23 +35,23 @@ Sound.prototype.playBgm = function () {
this.music.bgm && this.music.bgm.play({ loop: -1, volume: 0.3 }); // 播放背景音乐
};
Sound.prototype.playFootsteps = function () {
console.log('播放脚步声: ', this.music.audio2);
this.music.audio2 && this.music.audio2.play({ loop: -1 }); // 播放脚步声
};
Sound.prototype.pauseFootsteps = function () {
this.music.audio2 && this.music.audio2.pause(); // 停止脚步声
console.log('停止脚步声: ', this.music.audio2);
};
Sound.prototype.playBomb = function (direction) {
if (direction === 0 || direction === 1) {
this.music.audio1 && this.music.audio1.play(); // 播放爆炸声
this.music.audio1 && this.music.audio1.play(); // 播放跨栏声
this.music.audio2.paused = true;
}
const _this = this;
setTimeout(function () {
_this.music.audio2.paused = false;
}, 2000);
};
// let music = {};
// function initSound() {
// createjs.Sound.alternateExtensions = ['mp3'];
// const sounds = [
// { src: 'public/sounds/bgmMusic.mp3', id: 'bgm' },
// { src: 'public/sounds/excitationMusic.mp3', id: 'excitation' },
// { src: 'public/sounds/amazing.mp3', id: 'amazing' },
// { src: 'public/sounds/unbelievable.mp3', id: 'unbelievable' },
// ];
// createjs.Sound.addEventListener('fileload', function (event) {
// music[event.id] = createjs.Sound.createInstance(event.id);
// });
// createjs.Sound.registerSounds(sounds, '../../');
// }

5
src/classes/time.js

@ -65,7 +65,10 @@ Time.prototype.start = function (startTime = Date.now()) {
this.startTime = startTime;
this.duration = leftDuration ? leftDuration : this.duration;
this.update();
main.play(99);
if (move) {
main.play(99);
}
window.soundInstance.playFootsteps();
};
// 暂停游戏 暂停倒计时

6
src/custom.js

@ -1,6 +1,6 @@
const config = {
count: 5, // 默认倒计时时长
duration: 60, // 总时长 s
duration: 90, // 总时长 s
total: 100, // 总分
times: 15, // 动作次数
level: 1, // 游戏难度级别
@ -20,6 +20,8 @@ let library = null;
let state = 0; // 游戏状态 0->未开始 1->进行中 2->结束 3->暂停
let isDemo = false; // 是不是演示模式
let leftDuration = null; // 暂停时的时间
let move = true; // 是否执行动作
let timer = null; // 背景音乐定时
function initStage(lib) {
library = lib;
@ -46,6 +48,8 @@ function initStage(lib) {
// 游戏结束 显示结束得分面板
function gameOver() {
state = 2;
window.soundInstance.pauseFootsteps();
window.soundInstance = Sound.of();
const times = main.times;
setTimeout(() => {
End.of(config.currentScore || 0);

3
src/index.js

@ -35,11 +35,12 @@ function handleComplete(evt, comp) {
canvas.style.display = 'block';
exportRoot = new lib.跨栏右脚_HTML5Canvas();
stage = new lib.Stage(canvas);
stage.enableMouseOver();
//Registers the "tick" event listener.
fnStartAnimation = function () {
stage.addChild(exportRoot);
initStage(lib);
createjs.Ticker.framerate = lib.properties.fps;
createjs.Ticker.addEventListener('tick', stage);
};

3
src/test.js

@ -40,6 +40,9 @@ function sevenClick() {
// 倒计时结束 开始游戏
function countOver() {
timeInstance.start();
setTimeout(function () {
move = false;
}, 500);
}
// 添加hash值

Loading…
Cancel
Save