Browse Source

添加关闭演示模式按钮

master
song 4 years ago
parent
commit
40e58da7b6
  1. BIN
      dist.zip
  2. BIN
      public/RECOVER_鸟妈妈回家_HTML5 Canvas.fla
  3. 4
      public/bird.html
  4. 548
      public/bird.js
  5. BIN
      public/images/stopDemo.png
  6. BIN
      public/images/再来一次_.png
  7. BIN
      public/恢复_鸟妈妈回家_HTML5 Canvas.fla
  8. BIN
      public/鸟妈妈回家_HTML5 Canvas.fla
  9. 38
      src/classes/again.js
  10. 1
      src/classes/count.js
  11. 41
      src/classes/demo.js
  12. 1
      src/classes/end.js
  13. 1
      src/classes/sound.js
  14. 4
      src/classes/time.js
  15. 4
      src/custom.js
  16. 14
      src/test.js

BIN
dist.zip

Binary file not shown.

BIN
public/RECOVER_鸟妈妈回家_HTML5 Canvas.fla

Binary file not shown.

4
public/bird.html

@ -22,7 +22,7 @@
} }
</style> </style>
<script src="libs/1.0.0/createjs.min.js"></script> <script src="libs/1.0.0/createjs.min.js"></script>
<script src="bird.js?1632731010092"></script> <script src="bird.js"></script>
<script> <script>
var canvas, stage, exportRoot, anim_container, dom_overlay_container, fnStartAnimation; var canvas, stage, exportRoot, anim_container, dom_overlay_container, fnStartAnimation;
function init() { function init() {
@ -75,6 +75,6 @@ function handleComplete(evt,comp) {
<div id="dom_overlay_container" style="pointer-events:none; overflow:hidden; width:1280px; height:720px; position: absolute; left: 0px; top: 0px; display: none;"> <div id="dom_overlay_container" style="pointer-events:none; overflow:hidden; width:1280px; height:720px; position: absolute; left: 0px; top: 0px; display: none;">
</div> </div>
</div> </div>
<div id='_preload_div_' style='position:absolute; top:0; left:0; display: inline-block; height:720px; width: 1280px; text-align: center;'> <span style='display: inline-block; height: 100%; vertical-align: middle;'></span> <img src=images/_preloader.gif?1632731010092 style='vertical-align: middle; max-height: 100%'/></div> <div id='_preload_div_' style='position:absolute; top:0; left:0; display: inline-block; height:720px; width: 1280px; text-align: center;'> <span style='display: inline-block; height: 100%; vertical-align: middle;'></span> <img src=images/_preloader.gif style='vertical-align: middle; max-height: 100%'/></div>
</body> </body>
</html> </html>

548
public/bird.js

File diff suppressed because one or more lines are too long

BIN
public/images/stopDemo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
public/恢复_鸟妈妈回家_HTML5 Canvas.fla

Binary file not shown.

BIN
public/鸟妈妈回家_HTML5 Canvas.fla

Binary file not shown.

38
src/classes/again.js

@ -0,0 +1,38 @@
/**
* 再玩一次类
* @property {object} lib 库对象
* @property {object} btnAgain 面板元素对象
*/
function Again() {
this.lib = library;
this.btnAgain = null;
}
Again.of = function () {
const instance = new Again();
instance.init();
return instance;
};
// 初始化
Again.prototype.init = function () {
this.showAgainBtn();
};
// 渲染背景面板
Again.prototype.showAgainBtn = function () {
const lib = this.lib;
const btnAgain = new lib.btnAgain();
btnAgain.x = lib.properties.width / 2;
btnAgain.y = lib.properties.height / 2 + 150;
this.btnAgain = btnAgain;
this.btnAgain.addEventListener(
'click',
function () {
location.reload();
},
false,
);
stage.addChild(btnAgain);
};

1
src/classes/count.js

@ -92,7 +92,6 @@ Count.prototype.renderText = function (time) {
// 结束倒计时 开始游戏 // 结束倒计时 开始游戏
Count.prototype.countEnd = function () { Count.prototype.countEnd = function () {
console.log('结束倒计时: ');
// 执行结束后的回调 // 执行结束后的回调
this.countEndCallback(); this.countEndCallback();
}; };

41
src/classes/demo.js

@ -0,0 +1,41 @@
/**
* 演示模式类
* @property {object} lib 库对象
* @property {object} stopDemo 面板元素对象
*/
function Demo() {
this.lib = library;
this.stopDemo = null;
}
Demo.of = function () {
const instance = new Demo();
instance.init();
return instance;
};
// 初始化
Demo.prototype.init = function () {
this.showStopDemo();
};
// 显示演示模式按钮
Demo.prototype.showStopDemo = function () {
const lib = this.lib;
const stopDemo = new lib.stopDemo();
stopDemo.x = 50;
stopDemo.y = lib.properties.height - 100;
this.stopDemo = stopDemo;
// 关闭演示模式
this.stopDemo.addEventListener(
'click',
function () {
stage.removeChild(stopDemo);
location.hash = '';
location.reload();
},
false,
);
stage.addChild(stopDemo);
};

1
src/classes/end.js

@ -31,6 +31,7 @@ End.of = function (score) {
End.prototype.init = function () { End.prototype.init = function () {
this.renderModal(); this.renderModal();
this.renderText(this.score); this.renderText(this.score);
Again.of();
}; };
// 渲染背景面板 // 渲染背景面板

1
src/classes/sound.js

@ -20,7 +20,6 @@ Sound.prototype.init = function () {
{ src: 'sounds/unbelievable.mp3', id: 'unbelievable' }, { src: 'sounds/unbelievable.mp3', id: 'unbelievable' },
]; ];
createjs.Sound.addEventListener('fileload', function (event) { createjs.Sound.addEventListener('fileload', function (event) {
console.log('event: ', event);
this.music[event.id] = createjs.Sound.createInstance(event.id); this.music[event.id] = createjs.Sound.createInstance(event.id);
}); });
createjs.Sound.registerSounds(sounds, '../../'); createjs.Sound.registerSounds(sounds, '../../');

4
src/classes/time.js

@ -54,12 +54,10 @@ Time.prototype.start = function (startTime = Date.now()) {
state = 1; state = 1;
this.startTime = startTime; this.startTime = startTime;
this.update(); this.update();
console.log('开始游戏: ', state);
}; };
// 开始游戏 开始倒计时 // 开始游戏 开始倒计时
Time.prototype.end = function () { Time.prototype.end = function () {
console.log('结束游戏');
this.started = false; this.started = false;
this.timerId && clearTimeout(this.timerId); this.timerId && clearTimeout(this.timerId);
this.timerId = null; this.timerId = null;
@ -94,10 +92,8 @@ Time.prototype.update = function () {
if (this.timerId || !this.started) return; if (this.timerId || !this.started) return;
// const endTime = this.startTime + this.count * 1000 + this.duration * 1000; // const endTime = this.startTime + this.count * 1000 + this.duration * 1000;
const endTime = this.startTime + this.duration * 1000; const endTime = this.startTime + this.duration * 1000;
// console.log('endTime: ', endTime);
this.timerId = setInterval(() => { this.timerId = setInterval(() => {
let leftTime = Math.round((endTime - Date.now()) / 1000); let leftTime = Math.round((endTime - Date.now()) / 1000);
console.log('leftTime: ', leftTime);
this.text && stage.removeChild(this.text); this.text && stage.removeChild(this.text);
if (leftTime <= 0) { if (leftTime <= 0) {
leftTime = 0; leftTime = 0;

4
src/custom.js

@ -3,7 +3,7 @@ const config = {
duration: 60, // 总时长 s duration: 60, // 总时长 s
level: 1, // 游戏难度级别 level: 1, // 游戏难度级别
total: 100, // 总分 total: 100, // 总分
times: 20, // 动作次数 times: 21, // 动作次数
}; };
let library = null; let library = null;
@ -17,11 +17,11 @@ function initStage(lib) {
// window.soundInstance = Sound.of(); // 初始化音频 // window.soundInstance = Sound.of(); // 初始化音频
Level.of(2); // 游戏难度级别 Level.of(2); // 游戏难度级别
Back.of(); // 返回按钮 Back.of(); // 返回按钮
isHash();
} }
// 游戏结束 显示结束得分面板 // 游戏结束 显示结束得分面板
function gameOver() { function gameOver() {
console.log('显示结束得分面板');
state = 2; state = 2;
const times = main.times; const times = main.times;
const score = parseInt((config.total / config.times) * times); const score = parseInt((config.total / config.times) * times);

14
src/test.js

@ -1,11 +1,7 @@
// window.hash = '#p';
isHash();
// 判断是否在演示模式 能否直接开始游戏 // 判断是否在演示模式 能否直接开始游戏
function isHash() { function isHash() {
console.log('window.hash: ', window.hash); if (location.hash && location.hash === 'p') {
if (window.hash && window.hash === '#p') { Demo.of();
Count.of(countOver); Count.of(countOver);
} else { } else {
// 连点7次触发倒计时 // 连点7次触发倒计时
@ -34,8 +30,7 @@ function startGame() {
} }
function sevenClick() { function sevenClick() {
console.log('连点7次开始游戏'); Count.of(countOver);
window.count = Count.of(countOver);
addHash(); addHash();
} }
@ -46,7 +41,8 @@ function countOver() {
// 添加hash值 // 添加hash值
function addHash() { function addHash() {
window.hash = '#p'; location.hash = 'p';
Demo.of();
} }
function test() { function test() {

Loading…
Cancel
Save