commit 28de64ba2b15796656e7e24df2a1013ff9010a59
Author: wally <18603454788@163.com>
Date: Wed Jul 28 14:44:43 2021 +0800
7月底演示版本调整
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f26427b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,24 @@
+# Build and Release Folders
+bin-debug/
+bin-release/
+[Oo]bj/
+[Bb]in/
+
+# Other files and folders
+.settings/
+
+node_modules/
+.idea
+.vscode
+pullRadish-v1.6.html
+.DS_Store
+
+# Executables
+*.swf
+*.air
+*.ipa
+*.apk
+
+# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
+# should NOT be excluded as they contain compiler settings and other important
+# information for Eclipse / Flash Builder.
diff --git a/images/pullRadish_v1.6_atlas_1.png b/images/pullRadish_v1.6_atlas_1.png
new file mode 100644
index 0000000..d0bfdc7
Binary files /dev/null and b/images/pullRadish_v1.6_atlas_1.png differ
diff --git a/images/pullRadish_v1.6_atlas_2.json b/images/pullRadish_v1.6_atlas_2.json
new file mode 100644
index 0000000..f3c0e84
--- /dev/null
+++ b/images/pullRadish_v1.6_atlas_2.json
@@ -0,0 +1,203 @@
+{"frames": {
+
+"B1":
+{
+ "frame": {"x":1795,"y":410,"w":29,"h":29},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":29,"h":29},
+ "sourceSize": {"w":29,"h":29}
+},
+"B2":
+{
+ "frame": {"x":1987,"y":165,"w":53,"h":53},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":53,"h":53},
+ "sourceSize": {"w":53,"h":53}
+},
+"B3":
+{
+ "frame": {"x":1618,"y":410,"w":88,"h":89},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":88,"h":89},
+ "sourceSize": {"w":88,"h":89}
+},
+"B4":
+{
+ "frame": {"x":1695,"y":501,"w":73,"h":67},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":73,"h":67},
+ "sourceSize": {"w":73,"h":67}
+},
+"B5":
+{
+ "frame": {"x":1708,"y":410,"w":85,"h":89},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":85,"h":89},
+ "sourceSize": {"w":85,"h":89}
+},
+"B6":
+{
+ "frame": {"x":1933,"y":418,"w":91,"h":97},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":91,"h":97},
+ "sourceSize": {"w":91,"h":97}
+},
+"B7":
+{
+ "frame": {"x":1428,"y":410,"w":93,"h":92},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":93,"h":92},
+ "sourceSize": {"w":93,"h":92}
+},
+"B8":
+{
+ "frame": {"x":1523,"y":410,"w":93,"h":92},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":93,"h":92},
+ "sourceSize": {"w":93,"h":92}
+},
+"LB1":
+{
+ "frame": {"x":1830,"y":323,"w":101,"h":126},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":101,"h":126},
+ "sourceSize": {"w":101,"h":126}
+},
+"bg_grassland":
+{
+ "frame": {"x":0,"y":475,"w":1024,"h":350},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":1024,"h":350},
+ "sourceSize": {"w":1024,"h":350}
+},
+"bg_ground":
+{
+ "frame": {"x":0,"y":0,"w":1024,"h":473},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":1024,"h":473},
+ "sourceSize": {"w":1024,"h":473}
+},
+"hole1":
+{
+ "frame": {"x":1770,"y":523,"w":108,"h":31},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":108,"h":31},
+ "sourceSize": {"w":108,"h":31}
+},
+"hole2":
+{
+ "frame": {"x":1428,"y":504,"w":112,"h":30},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":112,"h":30},
+ "sourceSize": {"w":112,"h":30}
+},
+"rabit1":
+{
+ "frame": {"x":1900,"y":165,"w":85,"h":156},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":85,"h":156},
+ "sourceSize": {"w":85,"h":156}
+},
+"rabit2":
+{
+ "frame": {"x":1900,"y":0,"w":120,"h":163},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":120,"h":163},
+ "sourceSize": {"w":120,"h":163}
+},
+"radish":
+{
+ "frame": {"x":1933,"y":323,"w":104,"h":93},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":104,"h":93},
+ "sourceSize": {"w":104,"h":93}
+},
+"任务完成":
+{
+ "frame": {"x":1463,"y":0,"w":435,"h":307},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":435,"h":307},
+ "sourceSize": {"w":435,"h":307}
+},
+"倒计时":
+{
+ "frame": {"x":1026,"y":0,"w":435,"h":307},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":435,"h":307},
+ "sourceSize": {"w":435,"h":307}
+},
+"再来一次":
+{
+ "frame": {"x":1026,"y":410,"w":400,"h":99},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":400,"h":99},
+ "sourceSize": {"w":400,"h":99}
+},
+"分数":
+{
+ "frame": {"x":1882,"y":517,"w":124,"h":46},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":124,"h":46},
+ "sourceSize": {"w":124,"h":46}
+},
+"开始按钮":
+{
+ "frame": {"x":1026,"y":309,"w":400,"h":99},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":400,"h":99},
+ "sourceSize": {"w":400,"h":99}
+},
+"开始训练":
+{
+ "frame": {"x":1428,"y":309,"w":400,"h":99},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":400,"h":99},
+ "sourceSize": {"w":400,"h":99}
+},
+"计时":
+{
+ "frame": {"x":1795,"y":451,"w":85,"h":70},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":85,"h":70},
+ "sourceSize": {"w":85,"h":70}
+},
+"返回按钮":
+{
+ "frame": {"x":1618,"y":501,"w":75,"h":75},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":75,"h":75},
+ "sourceSize": {"w":75,"h":75}
+}},
+"meta": {
+ "app": "Adobe Animate",
+ "version": "21.0.0.35450",
+ "image": "pullRadish_v1.6_atlas_2.png",
+ "format": "undefined",
+ "size": {"w":2048,"h":1024},
+ "scale": "1"
+}
+}
diff --git a/images/pullRadish_v1.json b/images/pullRadish_v1.json
new file mode 100644
index 0000000..05ad97b
--- /dev/null
+++ b/images/pullRadish_v1.json
@@ -0,0 +1,155 @@
+{"frames": {
+
+"B1":
+{
+ "frame": {"x":984,"y":918,"w":29,"h":29},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":29,"h":29},
+ "sourceSize": {"w":29,"h":29}
+},
+"B2":
+{
+ "frame": {"x":746,"y":921,"w":53,"h":53},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":53,"h":53},
+ "sourceSize": {"w":53,"h":53}
+},
+"B3":
+{
+ "frame": {"x":822,"y":827,"w":88,"h":89},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":88,"h":89},
+ "sourceSize": {"w":88,"h":89}
+},
+"B4":
+{
+ "frame": {"x":909,"y":918,"w":73,"h":67},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":73,"h":67},
+ "sourceSize": {"w":73,"h":67}
+},
+"B5":
+{
+ "frame": {"x":912,"y":827,"w":85,"h":89},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":85,"h":89},
+ "sourceSize": {"w":85,"h":89}
+},
+"B6":
+{
+ "frame": {"x":539,"y":827,"w":91,"h":97},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":91,"h":97},
+ "sourceSize": {"w":91,"h":97}
+},
+"B7":
+{
+ "frame": {"x":632,"y":827,"w":93,"h":92},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":93,"h":92},
+ "sourceSize": {"w":93,"h":92}
+},
+"B8":
+{
+ "frame": {"x":727,"y":827,"w":93,"h":92},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":93,"h":92},
+ "sourceSize": {"w":93,"h":92}
+},
+"LB1":
+{
+ "frame": {"x":330,"y":827,"w":101,"h":126},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":101,"h":126},
+ "sourceSize": {"w":101,"h":126}
+},
+"bg_grassland":
+{
+ "frame": {"x":0,"y":475,"w":1024,"h":350},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":1024,"h":350},
+ "sourceSize": {"w":1024,"h":350}
+},
+"bg_ground":
+{
+ "frame": {"x":0,"y":0,"w":1024,"h":473},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":1024,"h":473},
+ "sourceSize": {"w":1024,"h":473}
+},
+"hole1":
+{
+ "frame": {"x":433,"y":926,"w":108,"h":31},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":108,"h":31},
+ "sourceSize": {"w":108,"h":31}
+},
+"hole2":
+{
+ "frame": {"x":632,"y":921,"w":112,"h":30},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":112,"h":30},
+ "sourceSize": {"w":112,"h":30}
+},
+"rabit1":
+{
+ "frame": {"x":122,"y":827,"w":85,"h":156},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":85,"h":156},
+ "sourceSize": {"w":85,"h":156}
+},
+"rabit2":
+{
+ "frame": {"x":0,"y":827,"w":120,"h":163},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":120,"h":163},
+ "sourceSize": {"w":120,"h":163}
+},
+"radish":
+{
+ "frame": {"x":433,"y":827,"w":104,"h":93},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":104,"h":93},
+ "sourceSize": {"w":104,"h":93}
+},
+"sun":
+{
+ "frame": {"x":209,"y":827,"w":119,"h":110},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":119,"h":110},
+ "sourceSize": {"w":119,"h":110}
+},
+"time":
+{
+ "frame": {"x":822,"y":918,"w":85,"h":85},
+ "rotated": false,
+ "trimmed": false,
+ "spriteSourceSize": {"x":0,"y":0,"w":85,"h":85},
+ "sourceSize": {"w":85,"h":85}
+}},
+"meta": {
+ "app": "Adobe Animate",
+ "version": "20.5.1.31044",
+ "image": "pullRadish_v1.6_atlas_1.png",
+ "format": "undefined",
+ "size": {"w":1024,"h":1024},
+ "scale": "1"
+}
+}
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..2a44661
--- /dev/null
+++ b/index.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+pullRadish-v1.6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..7b60ba4
--- /dev/null
+++ b/index.js
@@ -0,0 +1,478 @@
+var canvas, stage, exportRoot, anim_container, dom_overlay_container, fnStartAnimation;
+const obj = {
+ lib: null,
+ holes: [], // 洞洞的实例集合
+ radishes: [], // 萝卜的集合
+ rabbit: null, // 兔子对象
+ timeBg: null, // 倒计时背景对象
+ timeText: null, // 倒计时文本对象
+ totalTime: 60, // 总时长 s
+ scoreText: null, // 得分文本对象
+ totalScore: 0, // 总分 满分100分 每拔一个萝卜+5分
+ pulledRadishNum: 0, // 已经拔了的萝卜的数量
+ timerId: null, // 倒计时计时器的id
+ btnBegin: null, // 开始游戏的按钮
+ btnAgain: null, // 再玩一次的按钮
+ bgModalBegin: null, // 开始倒计时面板
+ countTimer: null, // 开始游戏的倒计时的 计时器id
+ count: 5, // 开始游戏时的倒计时
+ music: {
+ bgm: null, // 背景音乐
+ excitation: null, // 拔出一个萝卜的激励声音
+ amazing: null,
+ unbelievable: null, //
+ },
+ gameStart: false, // 游戏时候开始
+ lock: false, // 锁 拔的过程中不能出发下一次拔的动作
+};
+
+function init() {
+ initMessage();
+
+ canvas = document.getElementById("canvas");
+ anim_container = document.getElementById("animation_container");
+ dom_overlay_container = document.getElementById("dom_overlay_container");
+ var comp = AdobeAn.getComposition("94CA090E719F4688AE0D01901C9EA0D7");
+ var lib = comp.getLibrary();
+ var loader = new createjs.LoadQueue(false);
+ loader.addEventListener("fileload", function (evt) {
+ handleFileLoad(evt, comp)
+ });
+ loader.addEventListener("complete", function (evt) {
+ handleComplete(evt, comp)
+ });
+ var lib = comp.getLibrary();
+ loader.loadManifest(lib.properties.manifest);
+}
+
+function handleFileLoad(evt, comp) {
+ var images = comp.getImages();
+ if (evt && (evt.item.type == "image")) {
+ images[evt.item.id] = evt.result;
+ }
+}
+
+function handleComplete(evt, comp) {
+ //This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
+ var lib = comp.getLibrary();
+ var ss = comp.getSpriteSheet();
+ var queue = evt.target;
+ var ssMetadata = lib.ssMetadata;
+ for (i = 0; i < ssMetadata.length; i++) {
+ ss[ssMetadata[i].name] = new createjs.SpriteSheet({
+ "images": [queue.getResult(ssMetadata[i].name)],
+ "frames": ssMetadata[i].frames
+ })
+ }
+ exportRoot = new lib.pullRadishv16();
+ stage = new lib.Stage(canvas);
+ //Registers the "tick" event listener.
+ fnStartAnimation = function () {
+ stage.addChild(exportRoot);
+ obj.lib = lib;
+ initStage(lib);
+
+ createjs.Ticker.framerate = lib.properties.fps;
+ createjs.Ticker.addEventListener("tick", stage);
+ }
+ //Code to support hidpi screens and responsive scaling.
+ AdobeAn.makeResponsive(true, 'both', true, 1, [canvas, anim_container, dom_overlay_container]);
+ AdobeAn.compositionLoaded(lib.properties.id);
+ fnStartAnimation();
+}
+
+// 初始绘制舞台相关元素
+function initStage(lib) {
+ initSound();
+ initRadishes(lib);
+ initRabbit(lib);
+ initHoles(lib);
+ initTime(lib);
+ initScore(lib);
+ initBeginBtn();
+ initBackBtn();
+
+ // test();
+}
+
+// 初始化音频资源
+function initSound() {
+ createjs.Sound.alternateExtensions = ["mp3"];
+ const sounds = [
+ { src: './sounds/bgmMusic.mp3', id: 'bgm'},
+ { src: './sounds/excitationMusic.mp3', id: 'excitation'},
+ { src: './sounds/amazing.mp3', id: 'amazing'},
+ { src: './sounds/unbelievable.mp3', id: 'unbelievable'},
+ ];
+ createjs.Sound.addEventListener('fileload', function (event) {
+ obj.music[event.id] = createjs.Sound.createInstance(event.id);
+ });
+ createjs.Sound.registerSounds(sounds, './');
+}
+
+// 初始化开始按钮
+function initBeginBtn() {
+ obj.btnBegin = new obj.lib.btnBegin();
+ obj.btnBegin.x = obj.lib.properties.width / 2;
+ obj.btnBegin.y = obj.lib.properties.height / 2;
+ // 点了以后开始游戏
+ obj.btnBegin.addEventListener('click', function() {
+ send()
+ }, false);
+
+ stage.addChild(obj.btnBegin);
+}
+
+// 初始 开始倒计时面板
+function initBeginCount() {
+ obj.music.bgm && obj.music.bgm.play({ loop: -1, volume: 0.3 }); // 播放背景音乐
+
+ obj.bgModalBegin = new obj.lib.bgModalBegin();
+ obj.bgModalBegin.x = obj.lib.properties.width / 2;
+ obj.bgModalBegin.y = obj.lib.properties.height / 2;
+ stage.addChild(obj.bgModalBegin); // 显示开始游戏的倒计时面板
+
+ stage.removeChild(obj.btnBegin); // 移除开始游戏的按钮
+ const startTime = +gameInfo.startTime;
+ const endCountTime = startTime + obj.count * 1000;
+ obj.count = Math.floor((endCountTime - Date.now()) / 1000);
+
+ changeBeginTime(obj.count); // 开始开始游戏的 倒计时
+ obj.countTimer = setInterval(function() {
+ obj.count = Math.floor((endCountTime - Date.now()) / 1000)
+ stage.removeChild(obj.beginTimeText);
+ changeBeginTime(obj.count);
+ }, 1000);
+}
+
+// 修改开始倒计时
+function changeBeginTime(time) {
+ if (time === 0) {
+ console.log(time);
+ // 发送倒计时结束的消息
+ clearInterval(obj.countTimer);
+ stage.removeChild(obj.beginTimeText);
+ stage.removeChild(obj.bgModalBegin);
+ sendEndCountRequest();
+ return;
+ }
+ const text = new createjs.Text(time, "bold 100px Arial", "#87431c");
+ text.x = obj.lib.properties.width / 2;
+ text.y = obj.lib.properties.height / 2 + 20;
+ text.textAlign = 'center';
+ text.textBaseline = "alphabetic";
+ obj.beginTimeText = text;
+ stage.addChild(text);
+}
+
+// 收到倒计时结束的消息
+function onCountdownMessage() {
+ obj.gameStart = true;
+ interval();
+}
+
+/**
+ * 初始绘制holes 洞洞
+ * @param {object} lib
+ */
+function initHoles(lib) {
+ const deltaX = 185; // 列偏移
+ const deltaY = 132; // 行偏移
+ const initX = 108; // 第一个坑X
+ const initY = 290; // 第一个坑Y
+
+ for (let j = 0; j < 4; j++) {
+ for (let i = 0; i < 5; i++) {
+ const holeInstance = new lib.hole();
+ holeInstance.x = initX + deltaX * i;
+ holeInstance.y = initY + deltaY * j;
+ obj.holes.push(holeInstance);
+ stage.addChild(holeInstance);
+ }
+ }
+}
+
+/**
+ * 初始绘制radishes 萝卜
+ * @param {object} lib
+ */
+function initRadishes(lib) {
+ const deltaX = 185; // 列偏移
+ const deltaY = 132; // 行偏移
+ const initX = 150; // 第一个坑X
+ const initY = 260; // 第一个坑Y
+
+ for (let j = 0; j < 4; j++) {
+ for (let i = 0; i < 5; i++) {
+ const radishInstance = new lib.radish_1();
+ radishInstance.x = initX + deltaX * i;
+ radishInstance.y = initY + deltaY * j;
+ obj.radishes.push(radishInstance);
+ stage.addChild(radishInstance);
+ }
+ }
+}
+
+/**
+ * 初始绘制兔子
+ * @param {object} lib
+ */
+function initRabbit(lib) {
+ const initX = 100;
+ const initY = 250;
+ const deltaX = 185;
+ const deltaY = 132;
+ const rabbitInstance = new lib.rabbitCell();
+ rabbitInstance.x = initX + deltaX * (obj.pulledRadishNum % 5);
+ rabbitInstance.y = initY + deltaY * Math.floor(obj.pulledRadishNum / 5);
+ obj.rabbit = rabbitInstance;
+ stage.addChild(rabbitInstance);
+}
+
+/**
+ * 初始绘制倒计时
+ * @param {object} lib
+ */
+function initTime(lib) {
+ const initX = 920;
+ const initY = 80;
+ const instance = new lib.timeBg();
+ instance.x = initX;
+ instance.y = initY;
+ obj.timeBg = instance;
+ stage.addChild(instance);
+ changeTime(obj.totalTime);
+}
+
+/**
+ * 修改倒计时
+ * @param {number} totalTime 游戏剩余秒数
+ */
+function changeTime(totalTime) {
+ const text = new createjs.Text(totalTime, "bold 40px Arial", "#823d16");
+ text.x = 922;
+ text.y = 100;
+ text.textAlign = 'center';
+ text.textBaseline = "alphabetic";
+ obj.timeText = text;
+ stage.addChild(text);
+}
+
+/**
+ * 修改得分
+ * @param {number} score 得分
+ */
+function changeScore(score) {
+ const text = new createjs.Text(score, "bold 32px Arial", "#FFF");
+ text.x = obj.lib.properties.width / 2 + 50;
+ text.y = 97;
+ text.textAlign = 'center';
+ text.textBaseline = "alphabetic";
+ obj.scoreText = text;
+ stage.addChild(text);
+}
+
+/**
+ * 初始绘制得分
+ * @param {object} lib
+ */
+function initScore(lib) {
+ const initX = obj.lib.properties.width / 2;
+ const initY = 80;
+ const instance = new lib.scoreBg();
+ instance.x = initX;
+ instance.y = initY;
+ instance.scaleX = 1.5;
+ instance.scaleY = 1.5;
+ obj.timeBg = instance;
+ stage.addChild(instance);
+ changeScore(obj.totalScore);
+}
+
+// 测试
+function test() {
+ document.addEventListener('click', handlePull, false);
+}
+
+// 一次拔萝卜的动作
+// 测试函数
+// 1. 萝卜动画
+// 2. 兔子动画
+// 3. 动画结束后 洞洞变状态
+// 4. 分数+5
+// 5. 兔子跑到下一个洞洞附近
+// 时间到游戏结束
+// 拔完了20个萝卜游戏结束
+function handlePull() {
+ if (obj.lock || !obj.gameStart) return;
+ obj.lock = true;
+
+ if (obj.totalTime <= 0 || obj.pulledRadishNum >= 20) return;
+
+ // 1. 设置萝卜的动画及状态
+ obj.radishes[obj.pulledRadishNum].gotoAndPlay('radish_start');
+ // 2. 兔子的动画
+ obj.rabbit.gotoAndPlay('rabbit_start');
+
+ // 3. 延时修改洞洞的状态
+ // 没找到动画的回调 目前只能用延时来处理
+ setTimeout(function () {
+ // obj.holes[obj.pulledRadishNum].gotoAndPlay('hole_active');
+
+ if (obj.pulledRadishNum >= 20) {
+ // 游戏结束
+ gameOver();
+ return
+ }
+ obj.rabbit && stage.removeChild(obj.rabbit);
+ initRabbit(obj.lib);
+
+ for (let i = 0; i < obj.pulledRadishNum; i++) {
+ obj.holes[i].gotoAndStop('hole_active');
+ obj.radishes[i].gotoAndStop('radish_bomb_end');
+ }
+
+ obj.lock = false;
+ }, 1250);
+}
+
+// 收到了计分的消息
+function onScoreMessage(score, times) {
+ console.log('score, times',score, times)
+ obj.totalScore = score;
+ obj.pulledRadishNum = times;
+ playExcitationMusic(); // 播放激励音乐
+
+ obj.scoreText && stage.removeChild(obj.scoreText); // 清除原有的分数
+ changeScore(obj.totalScore); // 显示新的分数
+}
+
+// 播放激励音乐
+function playExcitationMusic() {
+ switch (obj.pulledRadishNum % 5) {
+ case 0:
+ obj.music.unbelievable.play();
+ break;
+ case 3:
+ case 4:
+ obj.music.amazing.play();
+ break;
+ default:
+ obj.music.excitation.play();
+ break;
+ }
+}
+
+// 游戏结束
+function gameOver() {
+ console.log('game over', obj);
+ obj.rabbit && stage.removeChild(obj.rabbit);
+ obj.timerId && clearInterval(obj.timerId);
+ obj.timerId = null;
+ sendEndRequest(); // 发送结束http请求
+ showEndModal();
+}
+
+// 发送倒计时结束http请求
+function sendEndCountRequest() {
+ const data = { "param": { "id": gameInfo.patientId, "recordId": gameInfo.recordId } }
+ fetch('//www.tall.wiki/gateway/recovery/patient/countdown', {
+ method: 'POST',
+ mode: 'cors',
+ body: JSON.stringify(data),
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ })
+ .then(res => res.json())
+ .then(response => {
+ if (response && response.code === 200) {
+ // 结束成功
+ } else {
+ alert('网络异常, 请检查网络刷新重试');
+ console.error(response.msg);
+ }
+ })
+ .catch(error => console.error('Error:', error));
+}
+
+// 发送结束http请求
+function sendEndRequest() {
+ /**
+ gameId: "1"
+ patientId: "1"
+ recordId: "1400659869853421568"
+ */
+ const data = { "param": { "id": gameInfo.recordId, "patientId": gameInfo.patientId, "score": obj.totalScore } };
+ fetch('//www.tall.wiki/gateway/recovery/patient/end', {
+ method: 'POST',
+ mode: 'cors',
+ body: JSON.stringify(data),
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ })
+ .then(res => res.json())
+ .then(response => {
+ if (response && response.code === 200) {
+ // 结束成功
+ } else {
+ console.error(response.msg);
+ }
+ })
+ .catch(error => console.error('Error:', error));
+}
+
+// 处理倒计时
+function interval() {
+ if (obj.timerId) return;
+ const endTime = +gameInfo.startTime + 10 * 1000 + +gameInfo.duration;
+ obj.timerId = setInterval(function () {
+ if (obj.totalTime === 0) {
+ gameOver();
+ return;
+ }
+ obj.totalTime = Math.floor((endTime - Date.now()) / 1000);
+ obj.timeText && stage.removeChild(obj.timeText);
+ changeTime(obj.totalTime);
+ }, 1000);
+}
+
+// 显示结束游戏面板 及得分
+function showEndModal() {
+ obj.endModal = new obj.lib.bgModalEnd();
+ obj.endModal.x = obj.lib.properties.width / 2;
+ obj.endModal.y = obj.lib.properties.height / 2
+ stage.addChild(obj.endModal);
+
+ const text = new createjs.Text(obj.totalScore, "bold 100px Arial", "#793b18");
+ text.x = obj.lib.properties.width / 2;
+ text.y = obj.lib.properties.height / 2 + 70;
+ text.textAlign = 'center';
+ text.textBaseline = "alphabetic";
+ obj.endText = text;
+ stage.addChild(text);
+ showAgainBtn();
+}
+
+// 显示再玩一次的按钮
+function showAgainBtn() {
+ const btnAgain = new obj.lib.btnAgain();
+ btnAgain.x = obj.lib.properties.width / 2;
+ btnAgain.y = obj.lib.properties.height / 2 + 150;
+ obj.btnAgain = btnAgain;
+ obj.btnAgain.addEventListener('click', function() {
+ location.reload();
+ }, false);
+ stage.addChild(btnAgain);
+}
+
+// 初始化返回按钮/退出游戏按钮
+function initBackBtn() {
+ obj.btnBack = new obj.lib.btnBack();
+ obj.btnBack.x = 40;
+ obj.btnBack.y = 80;
+ obj.btnBack.scaleX = 1.3;
+ obj.btnBack.scaleY = 1.3;
+ stage.addChild(obj.btnBack);
+}
diff --git a/message.js b/message.js
new file mode 100644
index 0000000..7865b8c
--- /dev/null
+++ b/message.js
@@ -0,0 +1,15 @@
+function initMessage() {
+ window.parent.postMessage('created', '*');
+ window.addEventListener('message', function (event) {
+ try {
+ const data = JSON.parse(event.data);
+ // 消息格式: {type: 'data', data: { ... }}
+ if (data.type === 'data') {
+ console.log('game message: -->', data.data);
+ window.parentData = data.data;
+ }
+ } catch (error) {
+ // console.error(error);
+ }
+ })
+}
diff --git a/pullRadish-v1.6.fla b/pullRadish-v1.6.fla
new file mode 100644
index 0000000..c09996c
Binary files /dev/null and b/pullRadish-v1.6.fla differ
diff --git a/pullRadish-v1.6.js b/pullRadish-v1.6.js
new file mode 100644
index 0000000..9608ccc
--- /dev/null
+++ b/pullRadish-v1.6.js
@@ -0,0 +1,870 @@
+(function (cjs, an) {
+
+var p; // shortcut to reference prototypes
+var lib={};var ss={};var img={};
+lib.ssMetadata = [
+ {name:"pullRadish_v1.6_atlas_1", frames: [[1026,309,400,99],[1428,309,400,99],[1882,517,124,46],[1026,0,435,307],[1795,410,29,29],[1987,165,53,53],[1618,410,88,89],[1695,501,73,67],[1708,410,85,89],[1933,418,91,97],[1428,410,93,92],[1523,410,93,92],[0,475,1024,350],[0,0,1024,473],[1770,523,108,31],[1428,504,112,30],[1830,323,101,126],[1900,165,85,156],[1900,0,120,163],[1933,323,104,93],[1463,0,435,307],[1026,410,400,99],[1795,451,85,70],[1618,501,75,75]]}
+];
+
+
+(lib.AnMovieClip = function(){
+ this.actionFrames = [];
+ this.ignorePause = false;
+ this.gotoAndPlay = function(positionOrLabel){
+ cjs.MovieClip.prototype.gotoAndPlay.call(this,positionOrLabel);
+ }
+ this.play = function(){
+ cjs.MovieClip.prototype.play.call(this);
+ }
+ this.gotoAndStop = function(positionOrLabel){
+ cjs.MovieClip.prototype.gotoAndStop.call(this,positionOrLabel);
+ }
+ this.stop = function(){
+ cjs.MovieClip.prototype.stop.call(this);
+ }
+}).prototype = p = new cjs.MovieClip();
+// symbols:
+
+
+
+(lib.开始按钮 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(0);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.开始训练 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(1);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.分数 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(2);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.倒计时 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(3);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B1 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(4);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B2 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(5);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B3 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(6);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B4 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(7);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B5 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(8);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B6 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(9);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B7 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(10);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.B8 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(11);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.bg_grassland = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(12);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.bg_ground = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(13);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.hole1 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(14);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.hole2 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(15);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.LB1 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(16);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.rabit1 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(17);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.rabit2 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(18);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.radish = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(19);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.任务完成 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(20);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.再来一次 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(21);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.计时 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(22);
+}).prototype = p = new cjs.Sprite();
+
+
+
+(lib.返回按钮 = function() {
+ this.initialize(ss["pullRadish_v1.6_atlas_1"]);
+ this.gotoAndStop(23);
+}).prototype = p = new cjs.Sprite();
+// helper functions:
+
+function mc_symbol_clone() {
+ var clone = this._cloneProps(new this.constructor(this.mode, this.startPosition, this.loop, this.reversed));
+ clone.gotoAndStop(this.currentFrame);
+ clone.paused = this.paused;
+ clone.framerate = this.framerate;
+ return clone;
+}
+
+function getMCSymbolPrototype(symbol, nominalBounds, frameBounds) {
+ var prototype = cjs.extend(symbol, cjs.MovieClip);
+ prototype.clone = mc_symbol_clone;
+ prototype.nominalBounds = nominalBounds;
+ prototype.frameBounds = frameBounds;
+ return prototype;
+ }
+
+
+(lib.timeBg = 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]);
+
+ this.isSingleFrame = false;
+ // timeline functions:
+ this.frame_0 = function() {
+ if(this.isSingleFrame) {
+ return;
+ }
+ if(this.totalFrames == 1) {
+ this.isSingleFrame = true;
+ }
+ this.stop();
+ }
+
+ // actions tween:
+ this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));
+
+ // timeBg
+ this.instance = new lib.计时();
+ this.instance.setTransform(-60,-49,1.4118,1.4121);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.timeBg, new cjs.Rectangle(-60,-49,120,98.9), null);
+
+
+(lib.scoreBg = 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]);
+
+ this.isSingleFrame = false;
+ // timeline functions:
+ this.frame_0 = function() {
+ if(this.isSingleFrame) {
+ return;
+ }
+ if(this.totalFrames == 1) {
+ this.isSingleFrame = true;
+ }
+ this.stop();
+ }
+
+ // actions tween:
+ this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));
+
+ // scoreBg
+ this.instance = new lib.分数();
+ this.instance.setTransform(-62,-23);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.scoreBg, new cjs.Rectangle(-62,-23,124,46), null);
+
+
+(lib.LB1_1 = 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.LB1();
+ this.instance.setTransform(-50.5,-63);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.LB1_1, new cjs.Rectangle(-50.5,-63,101,126), null);
+
+
+(lib.hole = 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 = {hole_normal:0,hole_active:1};
+ props.loop = loop;
+ props.reversed = reversed;
+ cjs.MovieClip.apply(this,[props]);
+
+ // timeline functions:
+ this.frame_0 = function() {
+ this.stop();
+ }
+ this.frame_1 = function() {
+ this.stop();
+ }
+
+ // actions tween:
+ this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1));
+
+ // Hole
+ this.instance = new lib.hole1();
+
+ this.instance_1 = new lib.hole2();
+ this.instance_1.setTransform(0,1);
+
+ this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1}]},1).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = p = new cjs.MovieClip();
+p.nominalBounds = new cjs.Rectangle(0,0,112,31);
+
+
+(lib.补间3 = 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.radish();
+ this.instance.setTransform(-52,-46.5);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = p = new cjs.MovieClip();
+p.nominalBounds = new cjs.Rectangle(-52,-46.5,104,93);
+
+
+(lib.补间1 = 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.rabit2();
+ this.instance.setTransform(-60,-81.5);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = p = new cjs.MovieClip();
+p.nominalBounds = new cjs.Rectangle(-60,-81.5,120,163);
+
+
+(lib.bgModalEnd = 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.任务完成();
+ this.instance.setTransform(-218,-154);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.bgModalEnd, new cjs.Rectangle(-218,-154,435,307), null);
+
+
+(lib.btnBack = 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.返回按钮();
+ this.instance.setTransform(0,-38);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.btnBack, new cjs.Rectangle(0,-38,75,75), null);
+
+
+(lib.btnBegin = 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.开始按钮();
+ this.instance.setTransform(-180,-50,0.9,1);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.btnBegin, new cjs.Rectangle(-180,-50,360,99), null);
+
+
+(lib.bomb = 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 = {bomb_start:0,bomb_end:8};
+ props.loop = loop;
+ props.reversed = reversed;
+ cjs.MovieClip.apply(this,[props]);
+
+ // timeline functions:
+ this.frame_8 = function() {
+ this.stop();
+ }
+
+ // actions tween:
+ this.timeline.addTween(cjs.Tween.get(this).wait(8).call(this.frame_8).wait(1));
+
+ // bomb
+ this.instance = new lib.B1();
+ this.instance.setTransform(-15,-15);
+
+ this.instance_1 = new lib.B2();
+ this.instance_1.setTransform(-27,-27);
+
+ this.instance_2 = new lib.B3();
+ this.instance_2.setTransform(-44,-45);
+
+ this.instance_3 = new lib.B4();
+ this.instance_3.setTransform(-37,-34);
+
+ this.instance_4 = new lib.B5();
+ this.instance_4.setTransform(-43,-45);
+
+ this.instance_5 = new lib.B6();
+ this.instance_5.setTransform(-46,-49);
+
+ this.instance_6 = new lib.B7();
+ this.instance_6.setTransform(-47,-46);
+
+ this.instance_7 = new lib.B8();
+ this.instance_7.setTransform(-47,-46);
+
+ this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1}]},1).to({state:[{t:this.instance_2}]},1).to({state:[{t:this.instance_3}]},1).to({state:[{t:this.instance_4}]},1).to({state:[{t:this.instance_5}]},1).to({state:[{t:this.instance_6}]},1).to({state:[{t:this.instance_7}]},1).to({state:[]},1).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = p = new cjs.MovieClip();
+p.nominalBounds = new cjs.Rectangle(-47,-49,93,97);
+
+
+(lib.btnBeginTrain = 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.开始训练();
+ this.instance.setTransform(-180,-50,0.9,1.0101);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.btnBeginTrain, new cjs.Rectangle(-180,-50,360,100), null);
+
+
+(lib.bgModalBegin = 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.倒计时();
+ this.instance.setTransform(-218,-154);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.bgModalBegin, new cjs.Rectangle(-218,-154,435,307), null);
+
+
+(lib.btnAgain = 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.再来一次();
+ this.instance.setTransform(-125,-35,0.625,0.707);
+
+ this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = getMCSymbolPrototype(lib.btnAgain, new cjs.Rectangle(-125,-35,250,70), null);
+
+
+(lib.radish_1 = 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 = {radish_normal:0,radish_start:1,radish_fly_start:10,radish_bomb_start:12,"radish_fly_start":17,"radish_bomb_start":22,"radish_bomb_start":28,radish_bomb_end:36};
+ props.loop = loop;
+ props.reversed = reversed;
+ cjs.MovieClip.apply(this,[props]);
+
+ // timeline functions:
+ this.frame_0 = function() {
+ this.stop();
+ }
+ this.frame_36 = function() {
+ this.stop();
+ }
+
+ // actions tween:
+ this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(36).call(this.frame_36).wait(1));
+
+ // radish
+ this.instance = new lib.radish();
+ this.instance.setTransform(-52,-47);
+
+ this.instance_1 = new lib.补间3("synched",0);
+ this.instance_1.setTransform(0,-0.5);
+ this.instance_1._off = true;
+
+ this.instance_2 = new lib.LB1_1();
+ this.instance_2.setTransform(-1.55,-0.1,0.9306,0.9303,0,0,0,-0.1,-0.1);
+ this.instance_2.alpha = 0.5313;
+ this.instance_2._off = true;
+
+ this.instance_3 = new lib.B1();
+ this.instance_3.setTransform(-92,-89);
+ this.instance_3._off = true;
+
+ this.instance_4 = new lib.B2();
+ this.instance_4.setTransform(-104,-101);
+ this.instance_4._off = true;
+
+ this.instance_5 = new lib.B3();
+ this.instance_5.setTransform(-121,-119);
+ this.instance_5._off = true;
+
+ this.instance_6 = new lib.B4();
+ this.instance_6.setTransform(-114,-108);
+ this.instance_6._off = true;
+
+ this.instance_7 = new lib.B5();
+ this.instance_7.setTransform(-120,-119);
+ this.instance_7._off = true;
+
+ this.instance_8 = new lib.B6();
+ this.instance_8.setTransform(-123,-123);
+ this.instance_8._off = true;
+
+ this.instance_9 = new lib.B7();
+ this.instance_9.setTransform(-124,-120);
+ this.instance_9._off = true;
+
+ this.instance_10 = new lib.B8();
+ this.instance_10.setTransform(-124,-123);
+
+ this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1}]},1).to({state:[{t:this.instance_1}]},11).to({state:[{t:this.instance_1}]},11).to({state:[{t:this.instance_2}]},1).to({state:[{t:this.instance_2}]},3).to({state:[{t:this.instance_3}]},1).to({state:[{t:this.instance_4}]},1).to({state:[{t:this.instance_5}]},1).to({state:[{t:this.instance_6}]},1).to({state:[{t:this.instance_7}]},1).to({state:[{t:this.instance_8}]},1).to({state:[{t:this.instance_9}]},1).to({state:[{t:this.instance_10}]},1).to({state:[]},1).wait(1));
+ this.timeline.addTween(cjs.Tween.get(this.instance_1).wait(1).to({_off:false},0).to({scaleX:0.8654,scaleY:0.8651,y:-0.45},11).to({scaleX:1,scaleY:1,y:-0.5},11).to({_off:true,regX:-0.1,regY:-0.1,scaleX:0.9306,scaleY:0.9303,x:-1.55,y:-0.1,alpha:0.5313,mode:"independent"},1).wait(13));
+ this.timeline.addTween(cjs.Tween.get(this.instance_2).wait(23).to({_off:false},1).to({regX:0.1,scaleX:0.594,scaleY:0.594,rotation:-14.9986,x:-77.5,y:-75.05},3).to({_off:true,regX:0,regY:0,scaleX:1,scaleY:1,rotation:0,x:-92,y:-89,alpha:1},1).wait(9));
+ this.timeline.addTween(cjs.Tween.get(this.instance_3).wait(27).to({_off:false},1).to({_off:true,x:-104,y:-101},1).wait(8));
+ this.timeline.addTween(cjs.Tween.get(this.instance_4).wait(28).to({_off:false},1).to({_off:true,x:-121,y:-119},1).wait(7));
+ this.timeline.addTween(cjs.Tween.get(this.instance_5).wait(29).to({_off:false},1).to({_off:true,x:-114,y:-108},1).wait(6));
+ this.timeline.addTween(cjs.Tween.get(this.instance_6).wait(30).to({_off:false},1).to({_off:true,x:-120,y:-119},1).wait(5));
+ this.timeline.addTween(cjs.Tween.get(this.instance_7).wait(31).to({_off:false},1).to({_off:true,x:-123,y:-123},1).wait(4));
+ this.timeline.addTween(cjs.Tween.get(this.instance_8).wait(32).to({_off:false},1).to({_off:true,x:-124,y:-120},1).wait(3));
+ this.timeline.addTween(cjs.Tween.get(this.instance_9).wait(33).to({_off:false},1).to({_off:true,y:-123},1).wait(2));
+
+ this._renderFirstFrame();
+
+}).prototype = p = new cjs.MovieClip();
+p.nominalBounds = new cjs.Rectangle(-124,-123,176,181.6);
+
+
+(lib.rabbitCell = 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 = {rabbit_normal:0,rabbit_start:1,rabbit_end:31};
+ props.loop = loop;
+ props.reversed = reversed;
+ cjs.MovieClip.apply(this,[props]);
+
+ // timeline functions:
+ this.frame_0 = function() {
+ this.stop();
+ }
+ this.frame_31 = function() {
+ this.stop();
+ }
+
+ // actions tween:
+ this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(31).call(this.frame_31).wait(1));
+
+ // rabit
+ this.instance = new lib.rabit1();
+ this.instance.setTransform(-43,-78);
+
+ this.instance_1 = new lib.补间1("synched",0);
+ this.instance_1._off = true;
+
+ this.instance_2 = new lib.B2();
+ this.instance_2.setTransform(-27,-27);
+ this.instance_2._off = true;
+
+ this.instance_3 = new lib.B3();
+ this.instance_3.setTransform(-44,-45);
+ this.instance_3._off = true;
+
+ this.instance_4 = new lib.B4();
+ this.instance_4.setTransform(-37,-34);
+ this.instance_4._off = true;
+
+ this.instance_5 = new lib.B5();
+ this.instance_5.setTransform(-43,-45);
+ this.instance_5._off = true;
+
+ this.instance_6 = new lib.B6();
+ this.instance_6.setTransform(-46,-49);
+ this.instance_6._off = true;
+
+ this.instance_7 = new lib.B7();
+ this.instance_7.setTransform(-47,-46);
+ this.instance_7._off = true;
+
+ this.instance_8 = new lib.B8();
+ this.instance_8.setTransform(-47,-46);
+
+ this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1}]},1).to({state:[{t:this.instance_1}]},11).to({state:[{t:this.instance_1}]},11).to({state:[{t:this.instance_2}]},1).to({state:[{t:this.instance_3}]},1).to({state:[{t:this.instance_4}]},1).to({state:[{t:this.instance_5}]},1).to({state:[{t:this.instance_6}]},1).to({state:[{t:this.instance_7}]},1).to({state:[{t:this.instance_8}]},1).to({state:[]},1).wait(1));
+ this.timeline.addTween(cjs.Tween.get(this.instance_1).wait(1).to({_off:false},0).to({scaleX:0.9167,scaleY:0.9166},11).to({scaleX:1,scaleY:1},11).to({_off:true,x:-27,y:-27},1).wait(8));
+ this.timeline.addTween(cjs.Tween.get(this.instance_2).wait(23).to({_off:false},1).to({_off:true,x:-44,y:-45},1).wait(7));
+ this.timeline.addTween(cjs.Tween.get(this.instance_3).wait(24).to({_off:false},1).to({_off:true,x:-37,y:-34},1).wait(6));
+ this.timeline.addTween(cjs.Tween.get(this.instance_4).wait(25).to({_off:false},1).to({_off:true,x:-43,y:-45},1).wait(5));
+ this.timeline.addTween(cjs.Tween.get(this.instance_5).wait(26).to({_off:false},1).to({_off:true,x:-46,y:-49},1).wait(4));
+ this.timeline.addTween(cjs.Tween.get(this.instance_6).wait(27).to({_off:false},1).to({_off:true,x:-47,y:-46},1).wait(3));
+ this.timeline.addTween(cjs.Tween.get(this.instance_7).wait(28).to({_off:false},1).to({_off:true},1).wait(2));
+
+ this._renderFirstFrame();
+
+}).prototype = p = new cjs.MovieClip();
+p.nominalBounds = new cjs.Rectangle(-60,-81.5,120,163);
+
+
+// stage content:
+(lib.pullRadishv16 = function(mode,startPosition,loop,reversed) {
+if (loop == null) { loop = false; }
+if (reversed == null) { reversed = false; }
+ var props = new Object();
+ props.mode = mode;
+ props.startPosition = startPosition;
+ props.labels = {bgm:0};
+ props.loop = loop;
+ props.reversed = reversed;
+ cjs.MovieClip.apply(this,[props]);
+
+ // 图层_1
+ this.instance = new lib.bg_ground();
+ this.instance.setTransform(0.5,214,1,1.1733);
+
+ this.instance_1 = new lib.bg_grassland();
+ this.instance_1.setTransform(0.5,-73);
+
+ this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance_1},{t:this.instance}]}).wait(1));
+
+ this._renderFirstFrame();
+
+}).prototype = p = new lib.AnMovieClip();
+p.nominalBounds = new cjs.Rectangle(512.5,311,512,458);
+// library properties:
+lib.properties = {
+ id: '94CA090E719F4688AE0D01901C9EA0D7',
+ width: 1024,
+ height: 768,
+ fps: 24,
+ color: "#F5F5F5",
+ opacity: 0.00,
+ manifest: [
+ {src:"images/pullRadish_v1.6_atlas_1.png", id:"pullRadish_v1.6_atlas_1"},
+ {src:"sounds/excitationMusic.mp3", id:"excitationMusic"}
+ ],
+ preloads: []
+};
+
+
+
+// bootstrap callback support:
+
+(lib.Stage = function(canvas) {
+ createjs.Stage.call(this, canvas);
+}).prototype = p = new createjs.Stage();
+
+p.setAutoPlay = function(autoPlay) {
+ this.tickEnabled = autoPlay;
+}
+p.play = function() { this.tickEnabled = true; this.getChildAt(0).gotoAndPlay(this.getTimelinePosition()) }
+p.stop = function(ms) { if(ms) this.seek(ms); this.tickEnabled = false; }
+p.seek = function(ms) { this.tickEnabled = true; this.getChildAt(0).gotoAndStop(lib.properties.fps * ms / 1000); }
+p.getDuration = function() { return this.getChildAt(0).totalFrames / lib.properties.fps * 1000; }
+
+p.getTimelinePosition = function() { return this.getChildAt(0).currentFrame / lib.properties.fps * 1000; }
+
+an.bootcompsLoaded = an.bootcompsLoaded || [];
+if(!an.bootstrapListeners) {
+ an.bootstrapListeners=[];
+}
+
+an.bootstrapCallback=function(fnCallback) {
+ an.bootstrapListeners.push(fnCallback);
+ if(an.bootcompsLoaded.length > 0) {
+ for(var i=0; i handleMessagesData(item));
+ // console.log('ackId', ackId);
+ // 有ackId 发送ack
+ ackId && send({ type: 'Ack', data: { ackId } });
+ }
+ } catch (error) {
+ console.error(error);
+ }
+}
+
+/**
+ * 处理收到的消息内容
+ * @param {object} item 单个消息体对象
+ */
+function handleMessagesData(item) {
+ const data = JSON.parse(item.data);
+ switch (data.type) {
+ case 'ChannelStatus': // 认证消息
+ handleAuthMessage(data);
+ break;
+ case 'feedback': // 收到拔萝卜的动作反馈
+ console.log('score', data.data.score)
+ data.data && data.data.result === 1 && handlePull(data.data.times);
+ onScoreMessage(data.data.score, data.data.times);
+ break;
+ case 'startDrill': // 开始训练游戏
+ console.log(data.data);
+ window.gameInfo = data.data;
+ initBeginCount();
+ break;
+ case 'countdown':
+ onCountdownMessage();
+ break;
+ case 'score':
+ onScoreMessage(data.data.score, data.data.times);
+ break;
+ default:
+ break;
+ }
+}
+
+// ws 关闭
+function onClose(event) {
+ connected = false;
+ if (sendHeartTimer) clearInterval(sendHeartTimer);
+ // console.warn('close:', connected, new Date().toLocaleString());
+ if (!event || event.code !== 1005) {
+ socket.close();
+ }
+
+ setTimeout(() => {
+ // connected 在这里的作用是:
+ // 在发生重连 但是还没连上之前 不要再次重连
+ initSocket();
+ }, 300);
+}
+
+/**
+ * 发送消息
+ * @param data
+ */
+function send(data) {
+ if (connected) {
+ if (ws.readyState === 1) {
+ ws.send(JSON.stringify({ toDomain: 'Server', data: JSON.stringify(data) }));
+ }
+ } else {
+ socketMsgQueue.push(data);
+ }
+}
+
+
+// 认证消息
+function auth() {
+ // TODO: userId拿父框架传递过来的
+ const data = { type: 'Auth', data: { userId: '1399952569681448962' } };
+ send(data);
+}
+
+// 心跳检测
+function sendHeart() {
+ if (sendHeartTimer) clearInterval(sendHeartTimer);
+ sendHeartTimer = setInterval(() => {
+ if (Date.now() - prevTimestamp >= 15000) {
+ send({ type: 'Ping' });
+
+ if (Date.now() - prevTimestamp > 20000) {
+ // console.warn('手动断开');
+ ws.close();
+ }
+ }
+ }, 5000);
+}
+
+/**
+ * 处理auth认证返回的ChannelStatus消息
+ * @param {object} data 消息内容对象
+ */
+function handleAuthMessage(data) {
+ if (data.data.authed) {
+ // 认证成功
+ sendHeart();
+ } else {
+ console.error('消息系统认证失败');
+ // 清除掉本地无用的token
+ ws = null;
+ }
+}
diff --git a/sounds/amazing.mp3 b/sounds/amazing.mp3
new file mode 100644
index 0000000..490c10b
Binary files /dev/null and b/sounds/amazing.mp3 differ
diff --git a/sounds/bgmMusic.mp3 b/sounds/bgmMusic.mp3
new file mode 100644
index 0000000..0204957
Binary files /dev/null and b/sounds/bgmMusic.mp3 differ
diff --git a/sounds/excitationMusic.mp3 b/sounds/excitationMusic.mp3
new file mode 100644
index 0000000..822c1d0
Binary files /dev/null and b/sounds/excitationMusic.mp3 differ
diff --git a/sounds/unbelievable.mp3 b/sounds/unbelievable.mp3
new file mode 100644
index 0000000..9bbf63f
Binary files /dev/null and b/sounds/unbelievable.mp3 differ