Commit 5de85225 authored by liujiaxin's avatar liujiaxin

feat: init

parent 4e17a6b5
<div class="model-content"> <div class="model-content">
<div style="padding: 10px;"> <div style="padding: 10px;">
<div style="margin-top: 5px">
<span>开头音频: </span>
<app-audio-recorder
[audioUrl]="item.begin_audio"
(audioUploaded)="onAudioUploadSuccess($event, 'begin_audio')"
></app-audio-recorder>
</div>
<div style="margin-top: 5px">
<span>背景循环音频: </span>
<app-audio-recorder
[audioUrl]="item.playing_audio"
(audioUploaded)="onAudioUploadSuccess($event, 'playing_audio')"
></app-audio-recorder>
</div>
<div style="margin-top: 5px">
<span>结尾音频: </span>
<app-audio-recorder
[audioUrl]="item.end_audio"
(audioUploaded)="onAudioUploadSuccess($event, 'end_audio')"
></app-audio-recorder>
</div>
<h2>热区配置:</h2> <h2>热区配置:</h2>
<app-custom-hot-zone <app-custom-hot-zone
[bgItem]="item.bgItem" [bgItem]="item.bgItem"
......
...@@ -10,21 +10,22 @@ import { JsonPipe } from '@angular/common'; ...@@ -10,21 +10,22 @@ import { JsonPipe } from '@angular/common';
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_001"; saveKey = 'test_op15';
// 储存对象 // 储存对象
item; item;
customTypeGroupArr = [ customTypeGroupArr = [
{ {
name: '轮播图片', name: '动画',
anima: true, anima: true,
// audio: true, audio: true,
// pic: true, // pic: true,
rect: true, rect: true,
// text: true,
// isShowPos: true, // isShowPos: true,
// isCopy: true, // isCopy: true,
// label: '比对', label: '开始提示时间点',
}, },
]; ];
saveHotZone(group, e) { saveHotZone(group, e) {
......
...@@ -57,7 +57,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -57,7 +57,7 @@ export class PlayComponent implements OnInit, OnDestroy {
canvasLeft; canvasLeft;
canvasTop; canvasTop;
saveKey = 'test_0011'; saveKey = 'test_op15';
btnLeft; btnLeft;
......
...@@ -923,7 +923,7 @@ ...@@ -923,7 +923,7 @@
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 18 "__id__": 18
...@@ -952,15 +952,15 @@ ...@@ -952,15 +952,15 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
168.946, 145.326,
151.208, 133.912,
0, 0,
0, 0,
0, 0,
0, 0,
1, 1,
0.25, 0.22,
0.25, 0.22,
0.25 0.25
] ]
}, },
...@@ -1019,13 +1019,13 @@ ...@@ -1019,13 +1019,13 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "apple", "_name": "cow",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 20 "__id__": 20
...@@ -1042,8 +1042,8 @@ ...@@ -1042,8 +1042,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 799, "width": 490,
"height": 565 "height": 373
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1077,7 +1077,7 @@ ...@@ -1077,7 +1077,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "a4xySIvblKnYP3MSugLg2o" "_id": "32TEJDnbhMN7KT3gByoG4t"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -1098,7 +1098,7 @@ ...@@ -1098,7 +1098,7 @@
"_cacheMode": 0, "_cacheMode": 0,
"playTimes": -1, "playTimes": -1,
"premultipliedAlpha": false, "premultipliedAlpha": false,
"_armatureKey": "4d85228f-ec02-4cbe-a0d8-cc8628fe805d#146d0d76-3625-438b-a6c8-dbd27ca2af63", "_armatureKey": "ff8e808c-0f2c-437d-93a2-e427b8036108#e49a7f11-180e-464a-b737-4100c50c5293",
"_accTime": 0, "_accTime": 0,
"_playCount": 0, "_playCount": 0,
"_frameCache": null, "_frameCache": null,
...@@ -1106,10 +1106,10 @@ ...@@ -1106,10 +1106,10 @@
"_playing": false, "_playing": false,
"_armatureCache": null, "_armatureCache": null,
"_N$dragonAsset": { "_N$dragonAsset": {
"__uuid__": "4d85228f-ec02-4cbe-a0d8-cc8628fe805d" "__uuid__": "ff8e808c-0f2c-437d-93a2-e427b8036108"
}, },
"_N$dragonAtlasAsset": { "_N$dragonAtlasAsset": {
"__uuid__": "146d0d76-3625-438b-a6c8-dbd27ca2af63" "__uuid__": "e49a7f11-180e-464a-b737-4100c50c5293"
}, },
"_N$_defaultArmatureIndex": 0, "_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0, "_N$_animationIndex": 0,
...@@ -1117,17 +1117,17 @@ ...@@ -1117,17 +1117,17 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "552Xm8CDxMpIOVobC+Q//U" "_id": "13p+CDbYxKh6Neq43ZxC7X"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "bird", "_name": "apple",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 22 "__id__": 22
...@@ -1144,8 +1144,8 @@ ...@@ -1144,8 +1144,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 214, "width": 799,
"height": 171 "height": 565
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1179,7 +1179,7 @@ ...@@ -1179,7 +1179,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "9aJcXS8bdKj47wtsfNhmXs" "_id": "a4xySIvblKnYP3MSugLg2o"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -1200,7 +1200,7 @@ ...@@ -1200,7 +1200,7 @@
"_cacheMode": 0, "_cacheMode": 0,
"playTimes": -1, "playTimes": -1,
"premultipliedAlpha": false, "premultipliedAlpha": false,
"_armatureKey": "c09e0f09-3dcd-48ab-96e9-b3411b332e30#f7c2a4ed-1ea1-47fa-af1a-b0a87503411a", "_armatureKey": "4d85228f-ec02-4cbe-a0d8-cc8628fe805d#146d0d76-3625-438b-a6c8-dbd27ca2af63",
"_accTime": 0, "_accTime": 0,
"_playCount": 0, "_playCount": 0,
"_frameCache": null, "_frameCache": null,
...@@ -1208,10 +1208,10 @@ ...@@ -1208,10 +1208,10 @@
"_playing": false, "_playing": false,
"_armatureCache": null, "_armatureCache": null,
"_N$dragonAsset": { "_N$dragonAsset": {
"__uuid__": "c09e0f09-3dcd-48ab-96e9-b3411b332e30" "__uuid__": "4d85228f-ec02-4cbe-a0d8-cc8628fe805d"
}, },
"_N$dragonAtlasAsset": { "_N$dragonAtlasAsset": {
"__uuid__": "f7c2a4ed-1ea1-47fa-af1a-b0a87503411a" "__uuid__": "146d0d76-3625-438b-a6c8-dbd27ca2af63"
}, },
"_N$_defaultArmatureIndex": 0, "_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0, "_N$_animationIndex": 0,
...@@ -1219,17 +1219,17 @@ ...@@ -1219,17 +1219,17 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "04F4O9iptO77MTN5BpBjLp" "_id": "552Xm8CDxMpIOVobC+Q//U"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "car", "_name": "bird",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 24 "__id__": 24
...@@ -1246,8 +1246,8 @@ ...@@ -1246,8 +1246,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 314, "width": 214,
"height": 175 "height": 171
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1281,7 +1281,7 @@ ...@@ -1281,7 +1281,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "58za+HBcxMWJ6BCVXzaDJ9" "_id": "9aJcXS8bdKj47wtsfNhmXs"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -1302,7 +1302,7 @@ ...@@ -1302,7 +1302,7 @@
"_cacheMode": 0, "_cacheMode": 0,
"playTimes": -1, "playTimes": -1,
"premultipliedAlpha": false, "premultipliedAlpha": false,
"_armatureKey": "927c2190-9931-4948-bc8f-f93273d386f1#cb558b4f-c46d-4597-be52-2a01e9919a07", "_armatureKey": "c09e0f09-3dcd-48ab-96e9-b3411b332e30#f7c2a4ed-1ea1-47fa-af1a-b0a87503411a",
"_accTime": 0, "_accTime": 0,
"_playCount": 0, "_playCount": 0,
"_frameCache": null, "_frameCache": null,
...@@ -1310,10 +1310,10 @@ ...@@ -1310,10 +1310,10 @@
"_playing": false, "_playing": false,
"_armatureCache": null, "_armatureCache": null,
"_N$dragonAsset": { "_N$dragonAsset": {
"__uuid__": "927c2190-9931-4948-bc8f-f93273d386f1" "__uuid__": "c09e0f09-3dcd-48ab-96e9-b3411b332e30"
}, },
"_N$dragonAtlasAsset": { "_N$dragonAtlasAsset": {
"__uuid__": "cb558b4f-c46d-4597-be52-2a01e9919a07" "__uuid__": "f7c2a4ed-1ea1-47fa-af1a-b0a87503411a"
}, },
"_N$_defaultArmatureIndex": 0, "_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0, "_N$_animationIndex": 0,
...@@ -1321,17 +1321,17 @@ ...@@ -1321,17 +1321,17 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "25dK2Sp95JZLKy6DBkvVC2" "_id": "04F4O9iptO77MTN5BpBjLp"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "cat", "_name": "car",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 26 "__id__": 26
...@@ -1348,8 +1348,8 @@ ...@@ -1348,8 +1348,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 451, "width": 314,
"height": 489 "height": 175
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1383,7 +1383,7 @@ ...@@ -1383,7 +1383,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "65ayr7TKxHAag/Ti4Xmp+i" "_id": "58za+HBcxMWJ6BCVXzaDJ9"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -1404,7 +1404,7 @@ ...@@ -1404,7 +1404,7 @@
"_cacheMode": 0, "_cacheMode": 0,
"playTimes": -1, "playTimes": -1,
"premultipliedAlpha": false, "premultipliedAlpha": false,
"_armatureKey": "0d98c5c3-f6ce-4b53-8b13-3f64793c6c2a#6f320da8-7ad6-4576-9ed9-9f008f467cf7", "_armatureKey": "927c2190-9931-4948-bc8f-f93273d386f1#cb558b4f-c46d-4597-be52-2a01e9919a07",
"_accTime": 0, "_accTime": 0,
"_playCount": 0, "_playCount": 0,
"_frameCache": null, "_frameCache": null,
...@@ -1412,10 +1412,10 @@ ...@@ -1412,10 +1412,10 @@
"_playing": false, "_playing": false,
"_armatureCache": null, "_armatureCache": null,
"_N$dragonAsset": { "_N$dragonAsset": {
"__uuid__": "0d98c5c3-f6ce-4b53-8b13-3f64793c6c2a" "__uuid__": "927c2190-9931-4948-bc8f-f93273d386f1"
}, },
"_N$dragonAtlasAsset": { "_N$dragonAtlasAsset": {
"__uuid__": "6f320da8-7ad6-4576-9ed9-9f008f467cf7" "__uuid__": "cb558b4f-c46d-4597-be52-2a01e9919a07"
}, },
"_N$_defaultArmatureIndex": 0, "_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0, "_N$_animationIndex": 0,
...@@ -1423,17 +1423,17 @@ ...@@ -1423,17 +1423,17 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "24iVKgQhhEqoFPGYtXW6yO" "_id": "25dK2Sp95JZLKy6DBkvVC2"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "cow", "_name": "cat",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 28 "__id__": 28
...@@ -1450,8 +1450,8 @@ ...@@ -1450,8 +1450,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 490, "width": 451,
"height": 373 "height": 489
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1485,7 +1485,7 @@ ...@@ -1485,7 +1485,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "32TEJDnbhMN7KT3gByoG4t" "_id": "65ayr7TKxHAag/Ti4Xmp+i"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -1506,7 +1506,7 @@ ...@@ -1506,7 +1506,7 @@
"_cacheMode": 0, "_cacheMode": 0,
"playTimes": -1, "playTimes": -1,
"premultipliedAlpha": false, "premultipliedAlpha": false,
"_armatureKey": "ff8e808c-0f2c-437d-93a2-e427b8036108#e49a7f11-180e-464a-b737-4100c50c5293", "_armatureKey": "0d98c5c3-f6ce-4b53-8b13-3f64793c6c2a#6f320da8-7ad6-4576-9ed9-9f008f467cf7",
"_accTime": 0, "_accTime": 0,
"_playCount": 0, "_playCount": 0,
"_frameCache": null, "_frameCache": null,
...@@ -1514,10 +1514,10 @@ ...@@ -1514,10 +1514,10 @@
"_playing": false, "_playing": false,
"_armatureCache": null, "_armatureCache": null,
"_N$dragonAsset": { "_N$dragonAsset": {
"__uuid__": "ff8e808c-0f2c-437d-93a2-e427b8036108" "__uuid__": "0d98c5c3-f6ce-4b53-8b13-3f64793c6c2a"
}, },
"_N$dragonAtlasAsset": { "_N$dragonAtlasAsset": {
"__uuid__": "e49a7f11-180e-464a-b737-4100c50c5293" "__uuid__": "6f320da8-7ad6-4576-9ed9-9f008f467cf7"
}, },
"_N$_defaultArmatureIndex": 0, "_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 0, "_N$_animationIndex": 0,
...@@ -1525,7 +1525,7 @@ ...@@ -1525,7 +1525,7 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "13p+CDbYxKh6Neq43ZxC7X" "_id": "24iVKgQhhEqoFPGYtXW6yO"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -1535,7 +1535,7 @@ ...@@ -1535,7 +1535,7 @@
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 30 "__id__": 30
...@@ -1637,7 +1637,7 @@ ...@@ -1637,7 +1637,7 @@
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 32 "__id__": 32
...@@ -1739,7 +1739,7 @@ ...@@ -1739,7 +1739,7 @@
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 34 "__id__": 34
...@@ -1841,7 +1841,7 @@ ...@@ -1841,7 +1841,7 @@
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 36 "__id__": 36
...@@ -1943,7 +1943,7 @@ ...@@ -1943,7 +1943,7 @@
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 38 "__id__": 38
...@@ -2045,7 +2045,7 @@ ...@@ -2045,7 +2045,7 @@
"__id__": 14 "__id__": 14
}, },
"_children": [], "_children": [],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 40 "__id__": 40
...@@ -3433,19 +3433,12 @@ ...@@ -3433,19 +3433,12 @@
"__id__": 2 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"ant": null, "rightAudio": {
"apple": null, "__uuid__": "17e37c00-52ee-45df-9795-d534124a9d06"
"bird": null, },
"car": null, "wrongAudio": {
"cat": null, "__uuid__": "73a669bb-5d2b-4085-a40c-3a5d4564e32c"
"cow": null, },
"duck": null,
"egg": null,
"farmer": null,
"fish": null,
"girl": null,
"hen": null,
"house": null,
"_id": "e687yyoRBIzZAOVRL8Sseh" "_id": "e687yyoRBIzZAOVRL8Sseh"
} }
] ]
\ No newline at end of file
import { onHomeworkFinish, RandomInt, playAudioByUrl } from "../script/util"; import { onHomeworkFinish, RandomInt, playAudioByUrl, loadDragonBones } from "../script/util";
import { defaultData } from "../script/defaultData"; import { defaultData } from "../script/defaultData";
import { assign, createMachine, interpret, actions, forwardTo } from "../script/xstate"; import { assign, createMachine, interpret, actions, forwardTo, matchesState } from "../script/xstate";
const { pure , send, raise } = actions; const { pure , send, raise, sendParent } = actions;
class AssetCacher { class AssetCacher {
constructor(data, progress, complete) { constructor(data, progress, complete) {
...@@ -75,7 +75,7 @@ cc.Class({ ...@@ -75,7 +75,7 @@ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
ant: { /*ant: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
...@@ -126,16 +126,23 @@ cc.Class({ ...@@ -126,16 +126,23 @@ cc.Class({
house: { house: {
default: null, default: null,
type: cc.Node, type: cc.Node,
},*/
rightAudio: {
default: null,
type: cc.AudioClip,
}, },
wrongAudio: {
default: null,
type: cc.AudioClip,
}, },
playAni(node, name, times = 1) { },
const cat = cc.find(`Canvas/frame-border/ground/${node}`); playAni(idx, name, times = 1) {
var dragonDisplay = cat.getComponent(dragonBones.ArmatureDisplay); // const cat = cc.find(`Canvas/frame-border/ground/${node}`);
const node = this._animaNodeList[idx]
var dragonDisplay = node.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation(name, times); const state = dragonDisplay.playAnimation(name, times);
return state; return state;
...@@ -150,10 +157,17 @@ cc.Class({ ...@@ -150,10 +157,17 @@ cc.Class({
_imageResList: null, _imageResList: null,
_audioResList: null, _audioResList: null,
_animaResList: null, _animaResList: null,
_animaNodeList : null,
_lastFingerPosition: null,
initSceneData() { initSceneData() {
this._imageResList = []; this._imageResList = [];
this._audioResList = []; this._audioResList = [];
this._animaResList = []; this._animaResList = [];
this._animaNodeList = [];
this._lastFingerPosition= {
pos: null,
dirty: false
};
}, },
_designSize: null, // 设计分辨率 _designSize: null, // 设计分辨率
...@@ -161,6 +175,7 @@ cc.Class({ ...@@ -161,6 +175,7 @@ cc.Class({
_mapScaleMin: null, // 场景中常用缩放(取大值) _mapScaleMin: null, // 场景中常用缩放(取大值)
_mapScaleMax: null, // 场景中常用缩放(取小值) _mapScaleMax: null, // 场景中常用缩放(取小值)
_cocosScale: null, // cocos 自缩放 (较少用到) _cocosScale: null, // cocos 自缩放 (较少用到)
initSize() { initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小 // 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
...@@ -199,11 +214,10 @@ cc.Class({ ...@@ -199,11 +214,10 @@ cc.Class({
hint: { hint: {
invoke: { invoke: {
src: (ctx, event) => { src: (ctx, event) => {
const rt = RandomInt(3000, 5000); console.log(`[hint] play question ${ctx.questionIndex}: ${ctx.questionPlayTimes } audio`);
console.log(`[hint] play question ${ctx.questionIndex}: ${ctx.questionPlayTimes } audio ${rt}`); ctx.questionPlayTimes += 1;
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
playAudioByUrl(this.data.playing_questions[ctx.questionIndex].hint_audio, () => { playAudioByUrl(this.data.hotZoneItemArr[ctx.questionIndex].audio_url, () => {
console.log('hint finish'); console.log('hint finish');
resolve() resolve()
}) })
...@@ -215,7 +229,7 @@ cc.Class({ ...@@ -215,7 +229,7 @@ cc.Class({
}, },
answer: { answer: {
after: { after: {
5000: [ 10000: [
{ {
target: '#QuestionsArray.next', target: '#QuestionsArray.next',
actions: raise('CHECK'), actions: raise('CHECK'),
...@@ -230,7 +244,7 @@ cc.Class({ ...@@ -230,7 +244,7 @@ cc.Class({
}, },
invoke: { invoke: {
src: (ctx) => { /*src: (ctx) => {
ctx.questionPlayTimes += 1; ctx.questionPlayTimes += 1;
const rt = RandomInt(4500, 5500) const rt = RandomInt(4500, 5500)
console.log('[answer] thinking and playing', rt, rt<5000 ? 'should 1111': ''); console.log('[answer] thinking and playing', rt, rt<5000 ? 'should 1111': '');
...@@ -247,23 +261,127 @@ cc.Class({ ...@@ -247,23 +261,127 @@ cc.Class({
}, rt) }, rt)
}) })
}, },
onDone: { onDone: {
target: '#QuestionsArray.next', target: '#QuestionsArray.next',
actions: raise('CHECK') actions: raise('CHECK')
}, },
onError: { onError: {
target: 'retry', target: 'retry',
actions: raise('CHECK') actions: raise('CHECK')
},*/
src: (context, event) => (callback, onReceive) => {
console.log('[answer] thinking and playing');
// This will send the 'INC' event to the parent every second
const id = setInterval(() => {
const region = this.data.hotZoneItemArr[context.questionIndex];
const result = this.checkInRegion(region.rectPercent);
console.log('checkInRegion', region.rectPercent, result);
if (result) {
callback('RIGHT')
// playAudioByUrl(this.data.begin_audio, () => {
// console.log('game begin audio finish');
// })
} else if (this._lastFingerPosition.dirty) {
callback('WRONG')
}
}, 1000);
// Perform cleanup
return () => clearInterval(id);
},
},
on: {
/*CHECK: {
actions: (context, evt) => {
const region = this.data.hotZoneItemArr[context.questionIndex];
const result = this.checkInRegion(region.rectPercent);
console.log('checkInRegion', region.rectPercent, result);
if (result) {
// forwardTo('RIGHT')
send({type: 'RIGHT' });
}
}
},*/
/*CHECK: [
{
actions: send('RIGHT'),
cond: (context, evt) => {
const region = this.data.hotZoneItemArr[context.questionIndex];
const result = this.checkInRegion(region.rectPercent);
console.log('checkInRegion', region.rectPercent, result);
if (result) {
// forwardTo('RIGHT')
send({type: 'RIGHT' });
}
}
},
{actions: raise('WRONG')},
],*/
/*RIGHT: {
target: '#QuestionsArray.next',
actions: raise('CHECK')
},
WRONG: {
target: 'retry',
actions: raise('CHECK')
}*/
RIGHT: {
target: 'right',
},
WRONG: {
target: 'wrong',
} }
} }
}, },
retry: {
right: {
invoke: {
src: (context, event) => {
this._lastFingerPosition.pos = null;
this._lastFingerPosition.dirty = false;
return new Promise((resolve, reject) => {
console.log('answer right');
playAudioByUrl(this.rightAudio, () => {
resolve()
})
});
},
onDone: {
target: '#QuestionsArray.next',
actions: raise('CHECK')
},
onError: {
target: '#QuestionsArray.next',
actions: raise('CHECK')
}
}
},
wrong:{
invoke: {
src: (context, event) => {
this._lastFingerPosition.pos = null;
this._lastFingerPosition.dirty = false;
return new Promise((resolve, reject) => {
console.log('answer wrong');
playAudioByUrl(this.wrongAudio, () => {
resolve()
})
});
},
onDone: {
target: 'retry',
actions: raise('CHECK')
},
onError: {
target: 'retry',
actions: raise('CHECK')
}
}
},
retry: {
on: { on: {
CHECK: [ CHECK: [
{ target: 'hint' }, { target: 'hint' },
{ {
...@@ -318,7 +436,7 @@ cc.Class({ ...@@ -318,7 +436,7 @@ cc.Class({
questionIndex: 0, questionIndex: 0,
questionPlayTimes: 0, questionPlayTimes: 0,
maxQuestionTryTimes: 2, maxQuestionTryTimes: 2,
questionsCount: this.data.playing_questions.length, questionsCount: this.data.hotZoneItemArr.length,
}, },
states: { states: {
begin: { begin: {
...@@ -326,6 +444,9 @@ cc.Class({ ...@@ -326,6 +444,9 @@ cc.Class({
invoke: { invoke: {
src: (ctx) => { src: (ctx) => {
console.log('game begin'); console.log('game begin');
if(window.air && window.air.openOsmoFingerRead) {
window.air.openOsmoFingerRead()
}
return new Promise((resolve,reject) => { return new Promise((resolve,reject) => {
playAudioByUrl(this.data.begin_audio, () => { playAudioByUrl(this.data.begin_audio, () => {
console.log('game begin audio finish'); console.log('game begin audio finish');
...@@ -358,9 +479,12 @@ cc.Class({ ...@@ -358,9 +479,12 @@ cc.Class({
entry: (ctx, event) => { entry: (ctx, event) => {
console.log('game end', ctx, event); console.log('game end', ctx, event);
cc.assetManager.loadRemote(this.data.playing_audio, (err, audioClip) => { if(window.air && window.air.closeOsmoFingerRead) {
cc.audioEngine.playMusic(audioClip, true, 0.8); window.air.closeOsmoFingerRead()
}); }
playAudioByUrl(this.data.end_audio, () => {
console.log('game finish');
})
// return new Promise((resolve,reject) => { // return new Promise((resolve,reject) => {
// setTimeout(() => { // setTimeout(() => {
// console.log('hint finish'); // console.log('hint finish');
...@@ -373,12 +497,13 @@ cc.Class({ ...@@ -373,12 +497,13 @@ cc.Class({
} }
}; };
const after = {}; const after = {};
for(const t of this.data.begin_time_point) { for(let i = 0 ;i < this.data.hotZoneItemArr.length; i++) {
const k = t.time * 1000; const t = this.data.hotZoneItemArr[i];
const k = +t.labelText * 1000;
after[k]= { after[k]= {
actions: () => { actions: () => {
console.log(k) console.log(k)
this.playAni(t.node, t.name) this.playAni(i, 'normal')
} }
} }
} }
...@@ -410,10 +535,74 @@ cc.Class({ ...@@ -410,10 +535,74 @@ cc.Class({
console.log('data:', data); console.log('data:', data);
this.data = data || this.getDefaultData(); this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data)) this.data = JSON.parse(JSON.stringify(this.data))
const baseRect = this.data.bgItem.rect;
this.data.hotZoneItemArr.forEach(block => {
block.rectPercent = {
x: block.rect.x / baseRect.width,
y: block.rect.y / baseRect.height,
width: block.rect.width / baseRect.width,
height: block.rect.height / baseRect.height,
}
});
console.log(this.data);
this.preloadItem() this.preloadItem()
}); });
window.air = window.air || {}
if (window.air) {
window.air.osmoFingerReadCallback = (pos) => {
if (this.gameMachineService) {
return;
}
// const st = this.gameMachineService.state.value.constructor.name == 'Object'
// && this.gameMachineService.state.value['playing']
// && this.gameMachineService.state.value['playing'].constructor.name == 'Object'
// && this.gameMachineService.state.value['playing']['play']
// && this.gameMachineService.state.value['playing']['play'] == 'answer'
// if (st) {
// }
const p = JSON.parse(pos);
this._lastFingerPosition = {
pos:{
x: p.x * 2,
y: p.y
},
dirty: true
}
return
let dirty = false;
const lp = this._lastFingerPosition;
const p2 = lp.pos;
if (!p2) {
lp.pos = {
x: p.x * 2,
y: p.y
};
lp.dirty = true;
return
}
const detlaX = Math.abs(p2.x - p.x);
const detlaY = Math.abs(p2.y - p.y);
lp.pos = {
x: p.x * 2,
y: p.y
};
if (detlaX < 0.05 && detlaY < 0.05) {
lp.dirty = false;
} else {
lp.dirty = true;
}
}
}
},
checkInRegion(r) {
const p = this._lastFingerPosition ? this._lastFingerPosition.pos || {x:0, y:0} : {x:0, y:0};
const w = p.x > r.x && p.x < (r.x + r.width);
const h = p.y > r.y && p.y < (r.y + r.height);
return w && h;
}, },
...@@ -447,8 +636,11 @@ cc.Class({ ...@@ -447,8 +636,11 @@ cc.Class({
addPreloadImage() { addPreloadImage() {
// this._imageResList.push({ url: this.data.pic_url}); this._imageResList.push({ url: this.data.bgItem.url});
// this._imageResList.push({ url: this.data.pic_url_2 }); // this._imageResList.push({ url: this.data.pic_url_2 });
for (const q of this.data.hotZoneItemArr) {
this._audioResList.push({ url: q.texPngData.url });
}
}, },
addPreloadAudio() { addPreloadAudio() {
...@@ -458,8 +650,8 @@ cc.Class({ ...@@ -458,8 +650,8 @@ cc.Class({
this._audioResList.push({ url: this.data.end_audio }); this._audioResList.push({ url: this.data.end_audio });
for (const q of this.data.playing_questions) { for (const q of this.data.hotZoneItemArr) {
this._audioResList.push({ url: q.hint_audio }); this._audioResList.push({ url: q.audio_url });
} }
}, },
...@@ -475,17 +667,35 @@ cc.Class({ ...@@ -475,17 +667,35 @@ cc.Class({
// console.log(f, t, item) // console.log(f, t, item)
}, (err, data) => { }, (err, data) => {
console.log(err, data); console.log(err, data);
for (const asset of data) { // for (const asset of data) {
if (asset.constructor.name === 'ImageBitmap') { // if (asset.constructor.name === 'ImageBitmap') {
const t = new cc.Texture2D() // const t = new cc.Texture2D()
t.initWithData(asset); // t.initWithData(asset);
} else if (asset.constructor.name === 'AudioBuffer') { // } else if (asset.constructor.name === 'AudioBuffer') {
const clip = new cc.AudioClip() // const clip = new cc.AudioClip()
clip._nativeAsset = asset; // clip._nativeAsset = asset;
} // }
// }
const ground = cc.find(`Canvas/frame-border/ground`);
for(const zone of this.data.hotZoneItemArr) {
const n = new cc.Node();
n.scale = 0.25;
const db = n.addComponent(dragonBones.ArmatureDisplay);
this._animaNodeList.push(n);
loadDragonBones(db, {
tex: zone.texPngData.url,
atlas: zone.texJsonData.url,
ske: zone.skeJsonData.url,
}).then(({width, height}) => {
// v.armatureName = 'armature
n.width = width;
n.height = height;
n.parent = ground
});
} }
this.loadEnd(); this.loadEnd();
if (window && window["air"]) { if (window && window["air"] && window["air"].hideAirClassLoading) {
window["air"].hideAirClassLoading(); window["air"].hideAirClassLoading();
} }
...@@ -500,6 +710,7 @@ cc.Class({ ...@@ -500,6 +710,7 @@ cc.Class({
this.initView(); this.initView();
// this.initListener(); // this.initListener();
this.createStateMachine(); this.createStateMachine();
}, },
_cantouch: null, _cantouch: null,
...@@ -541,54 +752,54 @@ cc.Class({ ...@@ -541,54 +752,54 @@ cc.Class({
const canvas = cc.find('Canvas'); const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7; const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => { // this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode; // const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width; // picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x; // picNode1.baseX = picNode1.x;
// canvas.addChild(picNode1); // canvas.addChild(picNode1);
this.pic1 = picNode1; // this.pic1 = picNode1;
const labelNode = new cc.Node(); // const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW; // labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label); // const label = labelNode.addComponent(cc.Label);
label.string = this.data.text; // label.string = this.data.text;
label.fontSize = 60; // label.fontSize = 60;
label.lineHeight = 60; // label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font; // label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
// picNode1.addChild(labelNode); // picNode1.addChild(labelNode);
}); // });
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => { // this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode; // const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width; // picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2); // canvas.addChild(picNode2);
picNode2.x = canvas.width; // picNode2.x = canvas.width;
picNode2.baseX = picNode2.x; // picNode2.baseX = picNode2.x;
this.pic2 = picNode2; // this.pic2 = picNode2;
const labelNode = new cc.Node(); // const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText); // const label = labelNode.addComponent(cc.RichText);
const size = 60 // const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font; // label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>` // label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size; // label.lineHeight = size;
picNode2.addChild(labelNode); // picNode2.addChild(labelNode);
}); // });
}, },
initIcon() { initIcon() {
const iconNode = this.getSprNode('icon'); // const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5; // iconNode.zIndex = 5;
iconNode.anchorX = 1; // iconNode.anchorX = 1;
iconNode.anchorY = 1; // iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas'); // iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10; // iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10; // iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => { // iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url); // this.playAudioByUrl(this.data.audio_url);
}) // })
}, },
curPage: null, curPage: null,
...@@ -637,33 +848,33 @@ cc.Class({ ...@@ -637,33 +848,33 @@ cc.Class({
}, },
leftMove() { leftMove() {
this._cantouch = false; // this._cantouch = false;
const len = this.pic1.parent.width; // const len = this.pic1.parent.width;
cc.tween(this.pic1) // cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' }) // .to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start(); // .start();
cc.tween(this.pic2) // cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' }) // .to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => { // .call(() => {
this._cantouch = true; // this._cantouch = true;
}) // })
.start(); // .start();
}, },
rightMove() { rightMove() {
this._cantouch = false; // this._cantouch = false;
const len = this.pic1.parent.width; // const len = this.pic1.parent.width;
cc.tween(this.pic1) // cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' }) // .to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start(); // .start();
cc.tween(this.pic2) // cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' }) // .to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => { // .call(() => {
this._cantouch = true; // this._cantouch = true;
}) // })
.start(); // .start();
}, },
// update (dt) {}, // update (dt) {},
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 2560, "width": 1280,
"height": 1920, "height": 960,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg": { "bg": {
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 937, "width": 469,
"height": 730, "height": 365,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"m1": { "m1": {
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 474, "width": 237,
"height": 610, "height": 305,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"m2": { "m2": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment