Browse Source

添加暂停按钮

master
song 4 years ago
parent
commit
1dffec2665
  1. BIN
      public/RECOVER_鸟妈妈回家_HTML5 Canvas.fla
  2. 42
      public/bird.js
  3. BIN
      public/images/stopDemo.png
  4. BIN
      public/images/suspend.png
  5. BIN
      public/恢复_鸟妈妈回家_HTML5 Canvas.fla
  6. BIN
      public/鸟妈妈回家_HTML5 Canvas.fla
  7. 1
      src/classes/demo.js
  8. 40
      src/classes/suspend.js
  9. 1
      src/custom.js
  10. 7
      src/test.js

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

Binary file not shown.

42
public/bird.js

@ -76,7 +76,13 @@ p.nominalBounds = new cjs.Rectangle(0,0,449,161);
(lib.stopDemo = function() { (lib.stopDemo = function() {
this.initialize(img.stopDemo); this.initialize(img.stopDemo);
}).prototype = p = new cjs.Bitmap(); }).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,161,57); p.nominalBounds = new cjs.Rectangle(0,0,107,42);
(lib.suspend = function() {
this.initialize(img.suspend);
}).prototype = p = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,107,43);
(lib.任务完成 = function() { (lib.任务完成 = function() {
@ -156,6 +162,28 @@ if (reversed == null) { reversed = false; }
}).prototype = getMCSymbolPrototype(lib.timeBg, new cjs.Rectangle(-60,-49,120,98.9), null); }).prototype = getMCSymbolPrototype(lib.timeBg, new cjs.Rectangle(-60,-49,120,98.9), null);
(lib.Suspend = function(mode,startPosition,loop,reversed) {
if (loop == null) { loop = true; }
if (reversed == null) { reversed = false; }
var props = new Object();
props.mode = mode;
props.startPosition = startPosition;
props.labels = {};
props.loop = loop;
props.reversed = reversed;
cjs.MovieClip.apply(this,[props]);
// 图层_1
this.instance = new lib.suspend();
this.instance.setTransform(37,-21);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
this._renderFirstFrame();
}).prototype = getMCSymbolPrototype(lib.Suspend, new cjs.Rectangle(37,-21,107,43), null);
(lib.stopDemo_1 = function(mode,startPosition,loop,reversed) { (lib.stopDemo_1 = function(mode,startPosition,loop,reversed) {
if (loop == null) { loop = true; } if (loop == null) { loop = true; }
if (reversed == null) { reversed = false; } if (reversed == null) { reversed = false; }
@ -169,13 +197,13 @@ if (reversed == null) { reversed = false; }
// 图层_1 // 图层_1
this.instance = new lib.stopDemo(); this.instance = new lib.stopDemo();
this.instance.setTransform(-79,-28); this.instance.setTransform(129,-20);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1)); this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
this._renderFirstFrame(); this._renderFirstFrame();
}).prototype = getMCSymbolPrototype(lib.stopDemo_1, new cjs.Rectangle(-79,-28,161,57), null); }).prototype = getMCSymbolPrototype(lib.stopDemo_1, new cjs.Rectangle(129,-20,107,42), null);
(lib.前景 = function(mode,startPosition,loop,reversed) { (lib.前景 = function(mode,startPosition,loop,reversed) {
@ -2142,19 +2170,16 @@ if (reversed == null) { reversed = false; }
this.frame_621 = function() { this.frame_621 = function() {
this.stop() this.stop()
} }
this.frame_643 = function() {
this.stop()
}
// actions tween: // actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(16).call(this.frame_16).wait(38).call(this.frame_54).wait(54).call(this.frame_108).wait(26).call(this.frame_134).wait(25).call(this.frame_159).wait(34).call(this.frame_193).wait(54).call(this.frame_247).wait(25).call(this.frame_272).wait(24).call(this.frame_296).wait(25).call(this.frame_321).wait(25).call(this.frame_346).wait(27).call(this.frame_373).wait(63).call(this.frame_436).wait(23).call(this.frame_459).wait(27).call(this.frame_486).wait(26).call(this.frame_512).wait(25).call(this.frame_537).wait(24).call(this.frame_561).wait(24).call(this.frame_585).wait(36).call(this.frame_621).wait(22).call(this.frame_643).wait(861)); this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(16).call(this.frame_16).wait(38).call(this.frame_54).wait(54).call(this.frame_108).wait(26).call(this.frame_134).wait(25).call(this.frame_159).wait(34).call(this.frame_193).wait(54).call(this.frame_247).wait(25).call(this.frame_272).wait(24).call(this.frame_296).wait(25).call(this.frame_321).wait(25).call(this.frame_346).wait(27).call(this.frame_373).wait(63).call(this.frame_436).wait(23).call(this.frame_459).wait(27).call(this.frame_486).wait(26).call(this.frame_512).wait(25).call(this.frame_537).wait(24).call(this.frame_561).wait(24).call(this.frame_585).wait(36).call(this.frame_621).wait(883));
// mask // mask
this.shape = new cjs.Shape(); this.shape = new cjs.Shape();
this.shape.graphics.f("#000000").s().p("EjxyDCfMAAAmE9MHjlAAAMAAAGE9gEh1CBEhMDH/AAAMAAAhwfMh1rAAAIABAAMg5XAAAIAAAAI4+AAg"); this.shape.graphics.f("#000000").s().p("EjxyDCfMAAAmE9MHjlAAAMAAAGE9gEh1CBEhMDH/AAAMAAAhwfMh1rAAAIABAAMg5XAAAIAAAAI4+AAg");
this.shape.setTransform(749.1,281.525); this.shape.setTransform(749.1,281.525);
this.timeline.addTween(cjs.Tween.get(this.shape).to({_off:true},1500).wait(4)); this.timeline.addTween(cjs.Tween.get(this.shape).wait(713).to({_off:true},787).wait(4));
// score // score
this.instance = new lib._218d7f87fgfh("single",20); this.instance = new lib._218d7f87fgfh("single",20);
@ -2267,6 +2292,7 @@ lib.properties = {
{src:"images/Bitmap5.png", id:"Bitmap5"}, {src:"images/Bitmap5.png", id:"Bitmap5"},
{src:"images/level.png", id:"level"}, {src:"images/level.png", id:"level"},
{src:"images/stopDemo.png", id:"stopDemo"}, {src:"images/stopDemo.png", id:"stopDemo"},
{src:"images/suspend.png", id:"suspend"},
{src:"images/任务完成_.png", id:"任务完成"}, {src:"images/任务完成_.png", id:"任务完成"},
{src:"images/再来一次_.png", id:"再来一次"}, {src:"images/再来一次_.png", id:"再来一次"},
{src:"images/计时_.png", id:"计时"}, {src:"images/计时_.png", id:"计时"},

BIN
public/images/stopDemo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
public/images/suspend.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

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

Binary file not shown.

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

Binary file not shown.

1
src/classes/demo.js

@ -34,6 +34,7 @@ Demo.prototype.showStopDemo = function () {
stage.removeChild(stopDemo); stage.removeChild(stopDemo);
location.hash = ''; location.hash = '';
location.reload(); location.reload();
isDemo = false;
}, },
false, false,
); );

40
src/classes/suspend.js

@ -0,0 +1,40 @@
/**
* 暂停游戏类暂停继续游戏
* @property {object} lib 库对象
* @property {object} suspend 面板元素对象
*/
function Suspend() {
this.lib = library;
this.suspend = null;
}
Suspend.of = function () {
const instance = new Suspend();
instance.init();
return instance;
};
// 初始化
Suspend.prototype.init = function () {
this.suspendGame();
};
// 暂停游戏按钮
Suspend.prototype.suspendGame = function () {
const lib = this.lib;
const suspend = new lib.suspend();
suspend.x = 180;
suspend.y = lib.properties.height - 100;
this.suspend = suspend;
// 关闭演示模式
this.suspend.addEventListener(
'click',
function () {
console.log('暂停游戏');
stage.removeChild(stopDemo);
},
false,
);
stage.addChild(suspend);
};

1
src/custom.js

@ -8,6 +8,7 @@ const config = {
let library = null; let library = null;
let state = 0; // 游戏状态 0->未开始 1->进行中 2->结束 let state = 0; // 游戏状态 0->未开始 1->进行中 2->结束
let isDemo = false; // 是不是演示模式
function initStage(lib) { function initStage(lib) {
library = lib; library = lib;

7
src/test.js

@ -1,6 +1,7 @@
// 判断是否在演示模式 能否直接开始游戏 // 判断是否在演示模式 能否直接开始游戏
function isHash() { function isHash() {
if (location.hash && location.hash === 'p') { if (location.hash && location.hash === '#p') {
isDemo = true;
Demo.of(); Demo.of();
Count.of(countOver); Count.of(countOver);
} else { } else {
@ -13,6 +14,7 @@ function startGame() {
var count = 0, var count = 0,
timer; timer;
document.onclick = function () { document.onclick = function () {
if (isDemo) return;
if (count < 6) { if (count < 6) {
if (timer) { if (timer) {
clearTimeout(timer); clearTimeout(timer);
@ -30,6 +32,7 @@ function startGame() {
} }
function sevenClick() { function sevenClick() {
isDemo = true;
Count.of(countOver); Count.of(countOver);
addHash(); addHash();
} }
@ -41,7 +44,7 @@ function countOver() {
// 添加hash值 // 添加hash值
function addHash() { function addHash() {
location.hash = 'p'; location.hash = '#p';
Demo.of(); Demo.of();
} }

Loading…
Cancel
Save