Commit 875826c3 authored by jeff's avatar jeff

更新1111111

parent 83de2984
......@@ -603,7 +603,7 @@ export class Label extends MySprite {
private _text: string;
// fontSize:String = '40px';
fontName = 'Verdana';
fontName = 'font';
textAlign = 'left';
fontSize = 40;
fontColor = '#000000';
......
<div class="p-image-children-editor">
<h5 style="margin-left: 2.5%;margin-top: 10px; "> 预览: </h5>
<div class="p-image-children-editor " style="font-family: font;">
<div class="preview-box" #wrap>
<canvas id="canvas" #canvas></canvas>
</div>
......@@ -94,9 +91,9 @@
</div>
<div *ngIf="customTypeGroupArr[it.gIdx]?.action" style="display: flex;align-items: center; margin-top: 5px">
<app-custom-action style="margin: auto" [item]="it ? it['actionData_' + it.gIdx] : {}"
<app-custom-action style="margin: auto" [item]="it ? it['actionData_'] : {}"
[type]="customTypeGroupArr[it.gIdx].action.type" [option]="customTypeGroupArr[it.gIdx].action.option"
(save)="onSaveCustomAction($event, it)" [audio] ='customTypeGroupArr[it.gIdx].action.audio'>
(save)="onSaveCustomAction($event, it)" [audio]='customTypeGroupArr[it.gIdx].action.audio'>
></app-custom-action>
</div>
......
......@@ -19,6 +19,7 @@ import TWEEN from '@tweenjs/tween.js';
import { getMinScale } from '../../play/Unit';
import { tar } from 'compressing';
import { NzMessageService } from 'ng-zorro-antd';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
@Component({
......@@ -169,13 +170,9 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
}
// 背景音频
@Input()
bgAudioUrl: string = ''
onBgAudioUploadSuucess(e) {
console.log(e)
this.bgAudioUrl = e.url
this.bgItem.bgAudioUrl = e.url
}
onBackgroundUploadSuccess(e) {
......@@ -316,11 +313,10 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
item['id'] = saveData.id;
item['pic'] = saveData.pic_url
// item['skeJsonData'] = saveData.skeJsonData;
// item['texJsonData'] = saveData.texJsonData;
// item['texPngData'] = saveData.texPngData;
// item['actionData_' + item.gIdx] = saveData['actionData_' + item.gIdx];
item['actionData_'] = saveData['actionData_'];
}
console.log('item.x:~~ ', item.x);
......@@ -416,7 +412,6 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
this.setActionFont(textLabel, saveData['actionData_']);
textLabel.refreshSize();
}
textLabel.x = item.x;
textLabel.y = item.y;
......@@ -572,6 +567,9 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
console.log('in customRadioChange', e);
item.gIdx = -1;
item.textLabel.text = ' '
item.textLabel.width = 100
setTimeout(() => {
item.gIdx = e;
this.refreshCustomItem(item);
......@@ -645,7 +643,10 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
this.initData();
this.initCtx();
//要加载字体
setTimeout(() => {
this.initItem();
}, 100);
}
initItem() {
......@@ -1134,12 +1135,10 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
// skeJsonData: hotZoneArr[i].skeJsonData,
// texJsonData: hotZoneArr[i].texJsonData,
// texPngData: hotZoneArr[i].texPngData,
gIdx: hotZoneArr[i].gIdx,
useHand: hotZoneArr[i].useHand,
useBorder: hotZoneArr[i].useBorder
gIdx: hotZoneArr[i].gIdx
};
hotZoneItem['actionData_' ] = hotZoneArr[i]['actionData_']
hotZoneItem['actionData_'] = hotZoneArr[i]['actionData_']
if (this.hotZoneFontObj) {
......
{
"name": "publish",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"ngx-color-picker": {
"version": "11.0.0",
"resolved": "https://registry.nlark.com/ngx-color-picker/download/ngx-color-picker-11.0.0.tgz",
"integrity": "sha1-weVGhQWVO8V5vyEBShNYCIIOp1M=",
"requires": {
"tslib": "^2.0.0"
}
},
"tslib": {
"version": "2.2.0",
"resolved": "https://registry.npm.taobao.org/tslib/download/tslib-2.2.0.tgz",
"integrity": "sha1-+yxHWXfjXiQTEe3iaTzuHsZpj1w="
}
}
}
......@@ -104,7 +104,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 64.51,
"width": 103.13,
"height": 50.4
},
"_anchorPoint": {
......@@ -156,8 +156,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "test",
"_N$string": "test",
"_string": "test111",
"_N$string": "test111",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
......
......@@ -16,18 +16,25 @@
"_name": "node",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
"_children": [
{
"__id__": 2
},
{
"__id__": 3
"__id__": 6
},
{
"__id__": 10
}
],
"_active": true,
"_components": [
{
"__id__": 13
}
],
"_prefab": {
"__id__": 4
"__id__": 14
},
"_opacity": 255,
"_color": {
......@@ -44,8 +51,75 @@
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 1
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "New Sprite(Splash)",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 100,
"g": 99,
"b": 137,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 48,
"height": 44
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
......@@ -81,8 +155,145 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": -4,
"_right": -4,
"_top": -4,
"_bottom": -4,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 100,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "85e73971-9396-4c2a-9fac-2b187fd99c48"
},
"fileId": "3fpP7V8bRL9I4tBqsQ4W/R",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Sprite(Splash)",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
},
{
"__id__": 8
}
],
"_prefab": {
"__id__": 9
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 197,
"g": 244,
"b": 187,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_materials": [
{
......@@ -92,8 +303,140 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061"
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 100,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "85e73971-9396-4c2a-9fac-2b187fd99c48"
},
"fileId": "e0zPyfqplEKZlyC2lXi40G",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Node",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 11
}
],
"_prefab": {
"__id__": 12
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
......@@ -108,6 +451,17 @@
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "85e73971-9396-4c2a-9fac-2b187fd99c48"
},
"fileId": "25GAuqDahFz4vaRdWo8jdV",
"sync": false
},
{
"__type__": "577b3ZhuUNJtLzUNX3CEf1G",
"_name": "",
......
......@@ -236,7 +236,7 @@
"ctor": "Float64Array",
"array": [
78.809,
-3.5,
0,
0,
0,
0,
......
cc.Class({
extends: cc.Component,
properties: {
playBtn: cc.Node,
label: cc.Label,
tiao: cc.Node
},
onload() {
this._clip = null
this._play = false
this._audioId = null
this._totoalTime = null
this._nowTime = null
},
onEnable() {
cc.systemEvent.on('stopBgMusic', this.onEvent, this)
},
onDisable() {
cc.systemEvent.off('stopBgMusic', this.onEvent, this)
},
init(url) {
this.stopAudio()
this.playBtn.children[0].active = false
this.playBtn.children[1].active = true
cc.assetManager.loadRemote(url, (err, audioClip) => {
if (err) return
this.clip = audioClip
this._totoalTime = audioClip.duration
this.label.string = '0:00/' + this.transTime(this._totoalTime)
this.tiao.children[0].getComponent(cc.Sprite).fillRange = 0
this.tiao.children[1].x =12
})
},
onPlay() {
this._play = !this._play
this.playBtn.children[0].active = this._play
this.playBtn.children[1].active = !this._play
if (this._play) {
if (this._audioId != null) {
cc.audioEngine.resume(this._audioId)
} else {
this._audioId = cc.audioEngine.play(this.clip, false, 0.8);
cc.audioEngine.setFinishCallback(this._audioId, this.stopAudio.bind(this));
this._nowTime = 0
}
cc.systemEvent.emit('stopWordsMusic')
this.schedule(this.onTimeLoop)
} else {
this.stopAudio()
}
},
/** 定时回调 */
onTimeLoop(dt) {
this._nowTime += dt
this.label.string = this.transTime(this._nowTime) + '/' + this.transTime(this._totoalTime)
if (this._nowTime > this._totoalTime) this._nowTime = this._totoalTime
let scale = this._nowTime / this._totoalTime
this.tiao.children[0].getComponent(cc.Sprite).fillRange = scale
this.tiao.children[1].x = 12 + 364 * scale
},
onEvent() {
if (!this._play) return
this.onStopAudio()
},
onStopAudio() {
if (this._nowTime < this._totoalTime) {
cc.audioEngine.pause(this._audioId)
this._play = false
this.playBtn.children[0].active = false
this.playBtn.children[1].active = true
this.unscheduleAllCallbacks()
} else {
this.stopAudio()
}
},
stopAudio() {
if (this._audioId != null) {
cc.audioEngine.stop(this._audioId)
this._audioId = null
this.unscheduleAllCallbacks()
this._play = false
this.playBtn.children[0].active = false
this.playBtn.children[1].active = true
this.tiao.children[0].getComponent(cc.Sprite).fillRange = 1
this.tiao.children[1].x = 12 + 364 * 1
}
},
/** 秒转分钟 */
transTime(time) {
let temp = Math.floor(time / 60)
time = (time - 60 * temp).toFixed(0)
if (time < 10) time = '0' + time
return temp + ':' + time
}
});
{
"ver": "1.0.8",
"uuid": "a5d5c97d-70df-4203-9b44-2c83877fab88",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ cc.Class({
data: null,
onLoad() {
this._show = false
},
onEnable() {
......@@ -25,21 +25,32 @@ cc.Class({
},
initWithData(data, scale) {
let action = data['actionData_']
if (!action) {
this.node.active = false
return
} else {
this.node.action = true
}
this.data = data
let rect = this.data.rect
this.node.x = rect.x * scale
this.node.y = -rect.y * scale
this.node.width = rect.width
this.node.height = rect.height
this.node.scale = data.fontScale ? data.fontScale * scale : scale
let action = data['actionData_']
this.label.string = action.text ? action.text : ''
this.node.x = (rect.x + rect.width / 2) * scale
this.node.y = (-rect.y - rect.height / 2) * scale
this.label.node.active = false
let option = action.changeOption
this.label.node.color = option[0][1] ? cc.color(option[0][1]) : cc.color(0, 0, 0)
let num = Number(option[1][1]) * scale * data.fontScale
this.label.fontSize = num
this.label.lineHeight = num
this.label.string = action.text ? action.text : ''
this.node.width = rect.width * scale
this.node.height = rect.height * scale
},
onTouchStart() {
if (this._show) return
this._show = true
this.label.node.active = true
cc.audioEngine.play(this.tipClip)
},
......@@ -47,5 +58,6 @@ cc.Class({
/** 改变答案显示状态 */
onChangeState(show) {
this.label.node.active = show
this._show =show
}
});
......@@ -6,14 +6,24 @@ cc.Class({
properties: {
},
initWithData(data,scale) {
let sprite = this.getComponent(cc.Sprite)
tools.getSpriteFrimeByUrl(data.pic_url,(sp)=>{
initWithData(data, scale) {
let sprite = this.node.children[2].getComponent(cc.Sprite)
tools.getSpriteFrimeByUrl(data.pic_url, (sp) => {
sprite.spriteFrame = sp
let rect = data.rect
this.node.setPosition(rect.x*scale,-rect.y*scale)
this.node.width = rect.width*scale
this.node.height = rect.height*scale
this.node.setPosition((rect.x + rect.width / 2) * scale, (-rect.y - rect.height / 2) * scale)
let height = rect.height * scale
let width = rect.width * scale
sprite.node.width = width
sprite.node.height = height
this.node.height = height
this.node.width = width
let node = this.node.children[0]
node.height = height + 8
node.width = width + 8
node = this.node.children[1]
node.height = height
node.width = width
})
}
});
This diff is collapsed.
......@@ -20,8 +20,13 @@ cc.Class({
type: cc.Node,
default: null
},
checkNode: {
type: cc.Node,
default: null
},
bgAudioNode: cc.Node,
btnClip: cc.AudioClip
btnClip: cc.AudioClip,
tipClip: cc.AudioClip
},
// 生命周期 onLoad
......@@ -85,6 +90,7 @@ cc.Class({
this.picNode.opacity = 0
this.leftNode.active = false
this.rightNode.active = false
this.answerState = false
},
onEnable() {
......@@ -101,7 +107,7 @@ cc.Class({
},
getDefaultData() {
const dataJson = ' [{"hotZoneItemArr":[{"id":"1620886548676","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/aa0d852ef05d9d8de158f10b4a727376.jpg","itemType":"text","fontScale":0.7859375,"imgScale":0.5236111111111111,"mapScale":0.7859375,"gIdx":"0","actionData_":{"type":"text","changeOption":[["fontColor","#000000"],["fontSize","100"]],"text":"I WANT Fly","audio_url":"http://staging-teach.cdn.ireadabc.com/bd0502e664d0d279ccbec4e22b60f051.mp3"},"rect":{"width":438.31,"height":78.59,"x":115.96,"y":149.2}}],"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/b90a006ba41723ec11970051e92f43e0.png","rect":{"x":167.89,"y":0,"width":670.22,"height":377}}}]'
const dataJson = ' [{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/b90a006ba41723ec11970051e92f43e0.png","rect":{"x":125.28,"y":0,"width":508.44,"height":286},"bgAudioUrl":"http://staging-teach.cdn.ireadabc.com/c8a7dd49a778b0b6dd509aac0ef437ff.mp3"},"hotZoneItemArr":[{"id":"1620909579034","index":0,"itemType":"text","fontScale":0.59296875,"imgScale":1,"mapScale":0.59296875,"gIdx":"0","actionData_":{"type":"text","changeOption":[["fontColor","#000000"],["fontSize","60"]],"text":"aaaaaaaaaaaaaa","audio_url":"http://staging-teach.cdn.ireadabc.com/c8a7dd49a778b0b6dd509aac0ef437ff.mp3"},"rect":{"width":292.76,"height":35.58,"x":12.63,"y":26.79}},{"id":"1620915585437","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/31bde9b15582618fa5db4ac7cbc275b4.gif","itemType":"pic","fontScale":0.59296875,"imgScale":0.14977973568281938,"mapScale":0.59296875,"gIdx":"2","actionData_":{"type":"text","changeOption":[["fontColor","#000000"],["fontSize","100"]],"text":"bbbbbbbbbbb"},"rect":{"x":328.41,"y":11,"width":161.61,"height":68}},{"id":"1620920750092","index":2,"itemType":"text","fontScale":0.59296875,"imgScale":1,"mapScale":0.59296875,"gIdx":"0","actionData_":{"type":"text","changeOption":[["fontColor","#000000"],["fontSize","100"]],"text":"嗯?","audio_url":"http://staging-teach.cdn.ireadabc.com/7df4cc83a6c76dc6f0a526d07e6f1987.mp3"},"rect":{"width":118.58,"height":59.3,"x":203.93,"y":129.35}}]},{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/b90a006ba41723ec11970051e92f43e0.png","bgAudioUrl":"http://staging-teach.cdn.ireadabc.com/8f73a6b73a217d25ca4f4a2e234c1513.mp3","rect":{"x":222.44,"y":0,"width":903.11,"height":508}},"hotZoneItemArr":[{"id":"1620920863432","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/335dea1b83498b0c7c05be637dc13dad.jpeg","itemType":"text","fontScale":1.053125,"imgScale":0.22391857506361323,"mapScale":1.053125,"gIdx":"0","actionData_":{"type":"text","changeOption":[["fontColor","#FF0000"],["fontSize","100"]],"text":"This is a test"},"rect":{"width":558.89,"height":105.31,"x":13.12,"y":6.34}},{"id":"1620920877342","index":1,"itemType":"text","fontScale":1.053125,"imgScale":1,"mapScale":1.053125,"gIdx":"1","actionData_":{"type":"text","changeOption":[["fontColor","#0000FF"],["fontSize","100"]],"text":"you are so good"},"rect":{"width":734.29,"height":105.31,"x":106.43,"y":151.34}},{"id":"1620922839187","index":2,"itemType":"text","fontScale":1.053125,"imgScale":1,"mapScale":1.053125,"gIdx":"0","actionData_":{"type":"text","changeOption":[["fontColor","#000000"],["fontSize","100"]],"text":"_______________"},"rect":{"width":728.12,"height":105.31,"x":109.5,"y":170.34}}]}]'
const data = JSON.parse(dataJson);
return data;
},
......@@ -261,7 +267,11 @@ cc.Class({
.start();
},
stopAudio() {
cc.systemEvent.emit('stopMusic')
cc.systemEvent.emit('stopBgMusic')
cc.systemEvent.emit('stopWordsMusic')
this.answerState = false
this.checkNode.children[0].active = false
this.checkNode.children[1].active = true
},
// ------------------------------------------------
......@@ -271,17 +281,26 @@ cc.Class({
console.log('数据错误')
return
}
if (data.bgAudioUrl && data.bgAudioUrl != '') {
picNode.getComponent('picNode').initWithData(data)
let url = data.bgItem.bgAudioUrl
if (url && url != '') {
this.bgAudioNode.active = true
this.bgAudioNode.getComponent('audioItem').init(url)
} else {
this.bgAudioNode.active = false
}
picNode.getComponent('picNode').initWithData(data)
},
answerState: null,
/** 点击切换答案显示 */
onCheckall() {
cc.audioEngine.playEffect(this.btnClip)
cc.audioEngine.playEffect(this.tipClip)
this.answerState = !this.answerState
this.checkNode.children[0].active = this.answerState
this.checkNode.children[1].active = !this.answerState
cc.systemEvent.emit('changeAnswerState', this.answerState)
}
// ------------------------------------------
});
const tools = require("../script/tools");
var playingItem = null
cc.Class({
extends: cc.Component,
......@@ -13,42 +13,52 @@ cc.Class({
audio_url: null,
onEnable() {
cc.systemEvent.on('stopWordsMusic', this.stopAudio, this)
},
onDisable() {
cc.systemEvent.off('stopWordsMusic', this.stopAudio, this)
},
initWithData(data, scale) {
let action = data['actionData_']
if (!action) {
this.node.active = false
return
} else {
this.node.action = true
}
this.data = data
let rect = this.data.rect
this.node.x = (rect.x + rect.width / 2) * scale
this.node.y = (-rect.y - rect.height / 2) * scale
let action = data['actionData_']
this.node.width = rect.width * scale
this.node.height = rect.height * scale
let node = this.label.node
let option = action.changeOption
node.color = option[0][1] ? cc.color(option[0][1]) : cc.color(0, 0, 0)
node.scale = data.fontScale ? data.fontScale*scale : scale
let num = Number(option[1][1]) * scale * data.fontScale
this.label.fontSize = num
this.label.lineHeight = num
this.label.string = action.text ? action.text : ''
this.node.width = node.width * node.scale
this.node.height = node.height * node.height
this.audioId = null
this.audio_url = action.audio_url
if (this.audio_url) {
let node = this.playAnim.node
node.scale = 1 / this.node.scale
node.setPosition(this.label.node.width + node.width / 2 + 15, -this.node.height / 2)
this.playAnim.node.active = true
node.setPosition(this.node.width / 2 + node.width / 2 + 15, (-this.node.height + node.height) / 2)
node.active = true
} else {
this.playAnim.node.active = false
}
},
onTouchStart() {
if (this.audioId) return
if (this.audioId != null) return
if (this.audio_url && this.audio_url != '') {
this.playAudio(this.audio_url)
this.playAnim.play('play')
cc.systemEvent.emit('stopBgMusic')
}
},
......@@ -56,9 +66,10 @@ cc.Class({
playAudio(url) {
cc.assetManager.loadRemote(url, (err, audioClip) => {
if (err) return
cc.systemEvent.once('stopMusic', this.stopAudio, this)
if(playingItem) playingItem.stopAudio()
this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this));
playingItem = this
});
},
......@@ -67,7 +78,6 @@ cc.Class({
cc.audioEngine.stop(this.audioId)
this.audioId = null
this.playAnim.play('stop')
cc.systemEvent.off('stopMusic', this.stopAudio, this)
}
},
/** 音频id */
......
......@@ -32,8 +32,8 @@ export default class NewClass extends cc.Component {
this.node.removeAllChildren()
// let one = new cc.Node()
// one.removeFromParent()
// this.node
let one = new cc.Label()
one
// cc.audioEngine.setFinishCallback()
}
......
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