Commit d701a351 authored by liujiaxin's avatar liujiaxin

22

parent e7ba62fb
This diff is collapsed.
......@@ -69,6 +69,10 @@ cc.Class({
default: null,
type: cc.AudioClip,
},
logoCat: {
default: null,
type: cc.Node
}
},
......@@ -80,6 +84,11 @@ cc.Class({
var dragonDisplay = node.getComponent(dragonBones.ArmatureDisplay);
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);
return state;
},
......@@ -240,6 +249,12 @@ cc.Class({
an.active = true;
const dragonDisplay = an.getComponent(dragonBones.ArmatureDisplay);
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, () => {
resolve()
})
......@@ -263,6 +278,11 @@ cc.Class({
this._lastFingerPosition.dirty = false;
return new Promise((resolve, reject) => {
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, () => {
if (context.questionPlayTimes >= context.maxQuestionTryTimes) {
const an = context.questions[context.questionIndex].node;
......@@ -339,6 +359,8 @@ cc.Class({
if(window.courseware && window.courseware.openOsmoFingerRead) {
window.courseware.openOsmoFingerRead()
}
var dragonDisplay = this.logoCat.getComponent(dragonBones.ArmatureDisplay);
const state = dragonDisplay.playAnimation('begin', 0);
return new Promise((resolve,reject) => {
playAudioByUrl(this.data.begin_audio, () => {
console.log('game begin audio finish');
......@@ -353,6 +375,8 @@ cc.Class({
playing: {
entry: (ctx) => {
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.audioEngine.playMusic(audioClip, true, 0.8);
});
......@@ -371,9 +395,10 @@ cc.Class({
...QuestionsArrayStatus
},
end: {
entry: (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) {
window.courseware.closeOsmoFingerRead()
}
......@@ -402,6 +427,12 @@ cc.Class({
// cc.tween(t).to(.8, {scale: .3}).to(.8, {scale: .25}).start();
const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
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({
}, (err, data) => {
console.log(err, data);
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;
getSpriteFrimeByUrl(this.data.bgItem.url, (sf) => {
const gs = ground.getComponent(cc.Sprite);
const gs = groundBg.getComponent(cc.Sprite);
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) {
if (block.gIdx == '2') {
const s1 = ((ground.width / block.imgSizeW) + (ground.height / block.imgSizeH)) / 2
const node = new cc.Node();
node.parent = ground;
node.parent = groundBg;
const spr = node.addComponent(cc.Sprite);
getSpriteFrimeByUrl(block.pic_url, (sf) => {
spr.spriteFrame = sf;
......@@ -561,7 +601,8 @@ cc.Class({
const n = new cc.Node();
n.scale = 0.25;
const db = n.addComponent(dragonBones.ArmatureDisplay);
n.parent = ground;
n.active = false;
loadDragonBones(db, {
tex: block.texPngData.url,
atlas: block.texJsonData.url,
......@@ -569,8 +610,13 @@ cc.Class({
}).then(({width, height}) => {
n.width = width;
n.height = height;
n.parent = ground;
n.active = true;
db.playAnimation('normal', 0);
finishDbCount++;
console.log(finishDbCount, dbCount)
if (finishDbCount == dbCount) {
this.loadEnd();
}
});
if (block.gIdx == '0') {
const rectInfo = {
......@@ -600,7 +646,7 @@ cc.Class({
// console.log(this.data);
console.log('resource perload finish');
this.loadEnd();
if (window && window["air"] && 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