Commit 189d60a0 authored by xytk's avatar xytk

提交代码

parent 0338fa3c
...@@ -43,8 +43,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -43,8 +43,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
"texJsonData": { "url": "" }, "texJsonData": { "url": "" },
"texPngData": { "url": "" }, "texPngData": { "url": "" },
}, },
dragonBone_armatureName:"",
dragonBone_animationName:"",
dragonBone_audio_url:"", dragonBone_audio_url:"",
pic_A_url:"", pic_A_url:"",
pic_A_audio_url:"", pic_A_audio_url:"",
......
{
"ver": "1.1.2",
"uuid": "c79bd6df-0fc5-4b00-89d0-9c452ebde47f",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "doc",
"_objFlags": 0,
"_native": "",
"_duration": 0.06666666666666667,
"sample": 60,
"speed": 0.3,
"wrapMode": 2,
"curveData": {
"comps": {
"cc.Sprite": {
"spriteFrame": [
{
"frame": 0,
"value": {
"__uuid__": "df13ca56-0b84-446c-b23d-6a087788a3bb"
}
},
{
"frame": 0.016666666666666666,
"value": {
"__uuid__": "5798d041-ec18-4f1e-a4e4-b816dea7dd2b"
}
},
{
"frame": 0.03333333333333333,
"value": {
"__uuid__": "6ac58355-4763-43f4-87d1-2f27c8b0e199"
}
},
{
"frame": 0.05,
"value": {
"__uuid__": "2b16185e-b041-4777-9361-8d6f4ed80f42"
}
}
]
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "e23bd72e-c7cc-4fa5-bcb4-4ca945251f6d",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "d52a14c8-c75b-4239-8062-1f91425a3886",
"downloadMode": 0,
"duration": 1.854694,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "261261f6-352b-4a08-9c39-b33dc3fe9b9a",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "e1bc056e-f2a2-4e58-a899-8c80096a60b5",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "76b0791a-dc4e-4bc3-b4e5-1883457eea81",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "d803f9f6-040e-4bfa-8405-6ef85d4bc5af",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "ba5cb94f-a8af-4b01-b548-414f4a31cea2",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "9de7e940-49b7-4208-a6fd-efbfd529cfa6",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "d28d7b0a-dd52-4efb-8065-0a39dec57b26",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Node)
doc: cc.Node = null;
@property(cc.Node)
text: cc.Node = null;
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.doc.on(cc.Node.EventType.TOUCH_START,()=>{
this.doc.active = false;
this.text.active = true;
let tween = cc.tween().to(1,{y:0},{easing:"cubicInOut"})
cc.tween(this.text).then(tween).start();
})
this.text.on(cc.Node.EventType.TOUCH_START,()=>{
let as = this.text.getComponent<cc.AudioSource>(cc.AudioSource);
as.play();
})
}
setAudioClip(ac:cc.AudioClip){
this.text.getComponent<cc.AudioSource>(cc.AudioSource).clip = ac;
}
// start () {}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "f06fd6a2-1b37-4c7a-bcb8-3737fce79ae8",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const {ccclass, property} = cc._decorator; const {ccclass, property} = cc._decorator;
import {asyncPlayDragonBoneAnimation} from "./utils"
@ccclass @ccclass
export default class NewClass extends cc.Component { export default class NewClass extends cc.Component {
@property(cc.AudioSource)
dragonBoneAudioSource:cc.AudioSource = null;
@property(cc.AudioSource)
picAAudioSource:cc.AudioSource = null;
@property(cc.AudioSource)
picCAudioSource:cc.AudioSource = null;
// onLoad () {} // onLoad () {}
...@@ -12,10 +18,32 @@ export default class NewClass extends cc.Component { ...@@ -12,10 +18,32 @@ export default class NewClass extends cc.Component {
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.flyIn(); this.flyIn();
},0.5); },0.5);
this.dragonBoneAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{
this.dragonBoneAudioSource.play();
})
this.picAAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{
this.picAAudioSource.play();
})
this.picCAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{
this.picCAudioSource.play();
})
} }
// update (dt) {} // update (dt) {}
setAudioClip(ac:cc.AudioClip,type:number){
if(type == 0){
this.dragonBoneAudioSource.clip = ac;
}else if(type == 1){
this.picAAudioSource.clip = ac;
}else if(type == 2){
this.picCAudioSource.clip = ac;
}
}
/** /**
* 飞入 * 飞入
*/ */
......
// Learn cc.Class: import Tittle from "./Tittle"
// - https://docs.cocos.com/creator/manual/en/scripting/class.html import Middle from "./Middle"
// Learn Attribute: import Bottom from "./Bottom"
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({ cc.Class({
...@@ -12,9 +8,13 @@ cc.Class({ ...@@ -12,9 +8,13 @@ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
loadInAudioSource:cc.AudioSource,
dragonBonesNode:cc.Node, dragonBonesNode:cc.Node,
pic_a_sprite:cc.Sprite, pic_a_sprite:cc.Sprite,
pic_c_sprite:cc.Sprite pic_c_sprite:cc.Sprite,
tittleJs:Tittle,
middleJs:Middle,
bottomJs:Bottom
}, },
...@@ -22,6 +22,7 @@ cc.Class({ ...@@ -22,6 +22,7 @@ cc.Class({
onLoad() { onLoad() {
this.initSceneData(); this.initSceneData();
this.initSize(); this.initSize();
this.loadInAudioSource.play();
}, },
_imageResList: null, _imageResList: null,
...@@ -81,7 +82,7 @@ cc.Class({ ...@@ -81,7 +82,7 @@ cc.Class({
playDragonAnimation(){ playDragonAnimation(){
let ad = this.dragonBonesNode.getComponent(dragonBones.ArmatureDisplay); let ad = this.dragonBonesNode.getComponent(dragonBones.ArmatureDisplay);
if(ad){ if(ad){
ad.playAnimation(this.data.dragonBone_animationName, -1); ad.playAnimation("normal", -1);
} }
}, },
...@@ -91,7 +92,7 @@ cc.Class({ ...@@ -91,7 +92,7 @@ cc.Class({
}, },
getDefaultData() { getDefaultData() {
const dataJson = '{"bt_text":"11111","bt_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","dragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/363ea3636888e4f70037d69794956daa.json","name":"sb_boy_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ecc48e23d55b1af8eb40d997dc573791.json","name":"sb_boy_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","name":"sb_boy_tex.png"}},"dragonBone_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_A_url":"http://staging-teach.cdn.ireadabc.com/ed0e074ce7c52a469cc78c13a58eb09d.png","pic_C_url":"http://staging-teach.cdn.ireadabc.com/b2423375f6f8bfc4e24568c36b23947d.png","bottom_text":"底部的文本","bottom_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_A_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_C_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","dragonBone_animationName":"unit1_boy_jump","dragonBone_armatureName":"Armature"}' const dataJson = '{"bt_text":"11111","bt_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","dragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/14ca834d522122b031a2e18be5129251.json","name":"sb_boy_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ecc48e23d55b1af8eb40d997dc573791.json","name":"sb_boy_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","name":"sb_boy_tex.png"}},"dragonBone_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_A_url":"http://staging-teach.cdn.ireadabc.com/ed0e074ce7c52a469cc78c13a58eb09d.png","pic_C_url":"http://staging-teach.cdn.ireadabc.com/b2423375f6f8bfc4e24568c36b23947d.png","bottom_text":"底部的文本","bottom_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_A_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_C_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","dragonBone_animationName":"unit1_boy_jump","dragonBone_armatureName":"Armature"}'
const data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
...@@ -119,7 +120,9 @@ cc.Class({ ...@@ -119,7 +120,9 @@ cc.Class({
}, },
addPreloadAnima() { addPreloadAnima() {
this._animaResList.push({url: this.data.dragonBone.skeJsonData.url});
this._animaResList.push({url: this.data.dragonBone.texJsonData.url});
this._animaResList.push({url: this.data.dragonBone.texPngData.url});
}, },
preload() { preload() {
...@@ -155,33 +158,31 @@ cc.Class({ ...@@ -155,33 +158,31 @@ cc.Class({
audioBtn: null, audioBtn: null,
initAudio() { initAudio() {
const audioNode = cc.find('Canvas/res/audio'); this.getAudioByUrl(this.data.bt_audio_url,(ac)=>{
this.tittleJs.setAudioClip(ac);
const getAudioByResName = (resName) => { });
return audioNode.getChildByName(resName).getComponent(cc.AudioSource); this.getAudioByUrl(this.data.bottom_audio_url,(ac)=>{
} this.bottomJs.setAudioClip(ac);
});
this.audioBtn = getAudioByResName('btn'); this.getAudioByUrl(this.data.dragonBone_audio_url,(ac)=>{
this.middleJs.setAudioClip(ac,0);
});
this.getAudioByUrl(this.data.pic_A_audio_url,(ac)=>{
this.middleJs.setAudioClip(ac,1);
});
this.getAudioByUrl(this.data.pic_C_audio_url,(ac)=>{
this.middleJs.setAudioClip(ac,2);
});
}, },
initView() { initView() {
this.initBg(); this.initBg();
// this.initPic(); this.initPic();
//this.initBtn(); //this.initBtn();
this.initIcon(); this.initIcon();
this.loadDragonBones(); this.loadDragonBones();
this.getSpriteFrimeByUrl(this.data.pic_A_url,(spriteFrame)=>{
this.pic_a_sprite.spriteFrame = spriteFrame;
});
this.getSpriteFrimeByUrl(this.data.pic_C_url,(spriteFrame)=>{
this.pic_c_sprite.spriteFrame = spriteFrame;
});
}, },
loadDragonBones(){ loadDragonBones(){
var animNode = this.dragonBonesNode; var animNode = this.dragonBonesNode;
...@@ -203,8 +204,12 @@ cc.Class({ ...@@ -203,8 +204,12 @@ cc.Class({
dragonDisplay.dragonAtlasAsset = atlas; dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset; dragonDisplay.dragonAsset = asset;
let dbj = JSON.parse(dragonBonesJson);
let armatureNames = dbj.armature.map(data => data.name);
if(armatureNames.length>0){
dragonDisplay.armatureName = armatureNames[0];
dragonDisplay.armatureName = item.dragonBone_armatureName; }
// dragonDisplay.playAnimation(item.dragonBone_animationName, 0); // dragonDisplay.playAnimation(item.dragonBone_animationName, 0);
}); });
}); });
...@@ -220,129 +225,23 @@ cc.Class({ ...@@ -220,129 +225,23 @@ cc.Class({
pic1: null, pic1: null,
pic2: null, pic2: null,
initPic() { initPic() {
const canvas = cc.find('Canvas'); this.getSpriteFrimeByUrl(this.data.pic_A_url,(spriteFrame)=>{
const maxW = canvas.width * 0.7; this.pic_a_sprite.spriteFrame = spriteFrame;
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.getSpriteFrimeByUrl(this.data.pic_C_url,(spriteFrame)=>{
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => { this.pic_c_sprite.spriteFrame = spriteFrame;
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() { 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);
})
},
curPage: null, curPage: null,
initBtn() { initBtn() { },
this.curPage = 0; leftMove() {},
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
cc.audioEngine.play(this.audioBtn.clip, false, 0.8)
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
cc.audioEngine.play(this.audioBtn.clip, false, 0.5)
})
},
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();
},
rightMove() { 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();
}, },
// update (dt) {}, // update (dt) {},
...@@ -375,6 +274,16 @@ cc.Class({ ...@@ -375,6 +274,16 @@ cc.Class({
}) })
}, },
getAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
if (cb) {
cb(audioClip);
}
});
}
},
playAudioByUrl(audio_url, cb = null) { playAudioByUrl(audio_url, cb = null) {
if (audio_url) { if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => { cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
......
...@@ -10,8 +10,6 @@ export default class NewClass extends cc.Component { ...@@ -10,8 +10,6 @@ export default class NewClass extends cc.Component {
@property(cc.AudioSource) @property(cc.AudioSource)
audioSource:cc.AudioSource = null; audioSource:cc.AudioSource = null;
// LIFE-CYCLE CALLBACKS:
// onLoad () {} // onLoad () {}
start () { start () {
...@@ -25,6 +23,10 @@ export default class NewClass extends cc.Component { ...@@ -25,6 +23,10 @@ export default class NewClass extends cc.Component {
this.titleTextLabel.string = text?text:""; this.titleTextLabel.string = text?text:"";
} }
setAudioClip(ac:cc.AudioClip){
this.audioSource.clip = ac;
}
playSe(){ playSe(){
this.audioSource.play(); this.audioSource.play();
} }
......
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