Commit d701a351 authored by liujiaxin's avatar liujiaxin

22

parent e7ba62fb
This diff is collapsed.
...@@ -69,6 +69,10 @@ cc.Class({ ...@@ -69,6 +69,10 @@ cc.Class({
default: null, default: null,
type: cc.AudioClip, type: cc.AudioClip,
}, },
logoCat: {
default: null,
type: cc.Node
}
}, },
...@@ -80,6 +84,11 @@ cc.Class({ ...@@ -80,6 +84,11 @@ cc.Class({
var dragonDisplay = node.getComponent(dragonBones.ArmatureDisplay); var dragonDisplay = node.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation(name, times); const state = dragonDisplay.playAnimation(name, times);
// dragonDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event) => {
// //TODO 这里写触发事件
// //event.name为事件名称
// console.log(event.name)
// }, this);
// animationDisplay.addEventListener(dragonBones.EventObject.COMPLETE, completeCallback); // animationDisplay.addEventListener(dragonBones.EventObject.COMPLETE, completeCallback);
return state; return state;
}, },
...@@ -240,6 +249,12 @@ cc.Class({ ...@@ -240,6 +249,12 @@ cc.Class({
an.active = true; an.active = true;
const dragonDisplay = an.getComponent(dragonBones.ArmatureDisplay); const dragonDisplay = an.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('normal', 0); dragonDisplay.playAnimation('normal', 0);
const ddLogoCat = this.logoCat.getComponent(dragonBones.ArmatureDisplay)
ddLogoCat.playAnimation('right', 1)
ddLogoCat.once(dragonBones.EventObject.COMPLETE, function() {
this.logoCat.getComponent(dragonBones.ArmatureDisplay).playAnimation('normal', 0)
}, this)
playAudioByUrl(this.rightAudio, () => { playAudioByUrl(this.rightAudio, () => {
resolve() resolve()
}) })
...@@ -263,6 +278,11 @@ cc.Class({ ...@@ -263,6 +278,11 @@ cc.Class({
this._lastFingerPosition.dirty = false; this._lastFingerPosition.dirty = false;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log('answer wrong', context.questionPlayTimes , context.maxQuestionTryTimes); console.log('answer wrong', context.questionPlayTimes , context.maxQuestionTryTimes);
const ddLogoCat = this.logoCat.getComponent(dragonBones.ArmatureDisplay)
ddLogoCat.playAnimation('wrong', 1)
ddLogoCat.once(dragonBones.EventObject.COMPLETE, function() {
this.logoCat.getComponent(dragonBones.ArmatureDisplay).playAnimation('normal', 0)
}, this)
playAudioByUrl(this.wrongAudio, () => { playAudioByUrl(this.wrongAudio, () => {
if (context.questionPlayTimes >= context.maxQuestionTryTimes) { if (context.questionPlayTimes >= context.maxQuestionTryTimes) {
const an = context.questions[context.questionIndex].node; const an = context.questions[context.questionIndex].node;
...@@ -339,6 +359,8 @@ cc.Class({ ...@@ -339,6 +359,8 @@ cc.Class({
if(window.courseware && window.courseware.openOsmoFingerRead) { if(window.courseware && window.courseware.openOsmoFingerRead) {
window.courseware.openOsmoFingerRead() window.courseware.openOsmoFingerRead()
} }
var dragonDisplay = this.logoCat.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation('begin', 0);
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');
...@@ -353,6 +375,8 @@ cc.Class({ ...@@ -353,6 +375,8 @@ cc.Class({
playing: { playing: {
entry: (ctx) => { entry: (ctx) => {
console.log('entry play stage'); console.log('entry play stage');
var dragonDisplay = this.logoCat.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation('normal', 0);
cc.assetManager.loadRemote(this.data.playing_audio, (err, audioClip) => { cc.assetManager.loadRemote(this.data.playing_audio, (err, audioClip) => {
cc.audioEngine.playMusic(audioClip, true, 0.8); cc.audioEngine.playMusic(audioClip, true, 0.8);
}); });
...@@ -371,9 +395,10 @@ cc.Class({ ...@@ -371,9 +395,10 @@ cc.Class({
...QuestionsArrayStatus ...QuestionsArrayStatus
}, },
end: { end: {
entry: (ctx, event) => { entry: (ctx, event) => {
console.log('game end', ctx, event); console.log('game end', ctx, event);
var dragonDisplay = this.logoCat.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation('end', 0);
if(window.courseware && window.courseware.closeOsmoFingerRead) { if(window.courseware && window.courseware.closeOsmoFingerRead) {
window.courseware.closeOsmoFingerRead() window.courseware.closeOsmoFingerRead()
} }
...@@ -402,6 +427,12 @@ cc.Class({ ...@@ -402,6 +427,12 @@ cc.Class({
// cc.tween(t).to(.8, {scale: .3}).to(.8, {scale: .25}).start(); // cc.tween(t).to(.8, {scale: .3}).to(.8, {scale: .25}).start();
const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay); const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('enlarge', 1); dragonDisplay.playAnimation('enlarge', 1);
dragonDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event) => {
//TODO 这里写触发事件
//event.name为事件名称
event.armature.animation.play('normal', 0);
console.log(event.animationState.name)
}, this);
} }
} }
} }
...@@ -537,19 +568,28 @@ cc.Class({ ...@@ -537,19 +568,28 @@ cc.Class({
}, (err, data) => { }, (err, data) => {
console.log(err, data); console.log(err, data);
const ground = cc.find(`Canvas/frame-border/ground`); const ground = cc.find(`Canvas/frame-border/ground`);
const groundBg = cc.find(`Canvas/frame-border/ground/bg`);
groundBg.active = false;
const baseRect = this.data.bgItem.rect; const baseRect = this.data.bgItem.rect;
getSpriteFrimeByUrl(this.data.bgItem.url, (sf) => { getSpriteFrimeByUrl(this.data.bgItem.url, (sf) => {
const gs = ground.getComponent(cc.Sprite); const gs = groundBg.getComponent(cc.Sprite);
gs.spriteFrame = sf; gs.spriteFrame = sf;
groundBg.active = true;
}); });
let dbCount = 0;
let finishDbCount = 0
for(const block of this.data.hotZoneItemArr) {
if (block.gIdx == '0' || block.gIdx == '1') {
dbCount++;
}
}
for(const block of this.data.hotZoneItemArr) { for(const block of this.data.hotZoneItemArr) {
if (block.gIdx == '2') { if (block.gIdx == '2') {
const s1 = ((ground.width / block.imgSizeW) + (ground.height / block.imgSizeH)) / 2 const s1 = ((ground.width / block.imgSizeW) + (ground.height / block.imgSizeH)) / 2
const node = new cc.Node(); const node = new cc.Node();
node.parent = ground; node.parent = groundBg;
const spr = node.addComponent(cc.Sprite); const spr = node.addComponent(cc.Sprite);
getSpriteFrimeByUrl(block.pic_url, (sf) => { getSpriteFrimeByUrl(block.pic_url, (sf) => {
spr.spriteFrame = sf; spr.spriteFrame = sf;
...@@ -561,7 +601,8 @@ cc.Class({ ...@@ -561,7 +601,8 @@ cc.Class({
const n = new cc.Node(); const n = new cc.Node();
n.scale = 0.25; n.scale = 0.25;
const db = n.addComponent(dragonBones.ArmatureDisplay); const db = n.addComponent(dragonBones.ArmatureDisplay);
n.parent = ground;
n.active = false;
loadDragonBones(db, { loadDragonBones(db, {
tex: block.texPngData.url, tex: block.texPngData.url,
atlas: block.texJsonData.url, atlas: block.texJsonData.url,
...@@ -569,8 +610,13 @@ cc.Class({ ...@@ -569,8 +610,13 @@ cc.Class({
}).then(({width, height}) => { }).then(({width, height}) => {
n.width = width; n.width = width;
n.height = height; n.height = height;
n.parent = ground; n.active = true;
db.playAnimation('normal', 0); db.playAnimation('normal', 0);
finishDbCount++;
console.log(finishDbCount, dbCount)
if (finishDbCount == dbCount) {
this.loadEnd();
}
}); });
if (block.gIdx == '0') { if (block.gIdx == '0') {
const rectInfo = { const rectInfo = {
...@@ -600,7 +646,7 @@ cc.Class({ ...@@ -600,7 +646,7 @@ cc.Class({
// console.log(this.data); // console.log(this.data);
console.log('resource perload finish'); console.log('resource perload finish');
this.loadEnd();
if (window && window["air"] && window["air"].hideAirClassLoading) { if (window && window["air"] && window["air"].hideAirClassLoading) {
window["air"].hideAirClassLoading(); window["air"].hideAirClassLoading();
} }
......
This diff is collapsed.
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