Commit 5de85225 authored by liujiaxin's avatar liujiaxin

feat: init

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