Commit 58c59310 authored by Tt's avatar Tt

增加适配和音效

parent f0243074
{
"ver": "2.0.1",
"uuid": "30a70929-6e5d-4275-8fb9-004ab4b891b7",
"downloadMode": 0,
"duration": 2.56,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "85d9b4ae-4b48-4a38-a4a5-d8e9aca2acee",
"downloadMode": 0,
"duration": 1.123265,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
...@@ -343,20 +343,32 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -343,20 +343,32 @@ export default class SceneComponent extends MyCocosSceneComponent {
let eatAni = pg.view.find(this.elephant, "eat"); let eatAni = pg.view.find(this.elephant, "eat");
walkAni.active = true; walkAni.active = true;
eatAni.active = false; eatAni.active = false;
pg.view.playDBAnimation(walkAni, "walking", 0); let db = pg.view.playDBAnimation(walkAni, "walking", 0);
this.removeHungryAudio(db);
cc.Tween.stopAllByTarget(this.elephant); cc.Tween.stopAllByTarget(this.elephant);
walkAni.scaleX = 1; walkAni.scaleX = 1;
let moveX = 400;
let moveY = 0;
let winSize = cc.winSize;
if (winSize.width / winSize.height < 16 / 9) {
moveY = -(16 / 9 - winSize.width / winSize.height) * 750 / 2;
}
if (!this.elephant.active) {
this.elephant.active = true;
this.elephant.x = 0;
this.elephant.y = moveY + Math.random() * 100;
}
cc.tween(this.elephant) cc.tween(this.elephant)
.to(4, { x: 400, y: Math.random() * 100 }) .to(4, { x: moveX, y: moveY + Math.random() * 100 })
.call(() => { .call(() => {
walkAni.scaleX = -1; walkAni.scaleX = -1;
}) })
.to(4, { x: 0, y: Math.random() * 100 }) .to(4, { x: 0, y: moveY + Math.random() * 100 })
.to(4, { x: -400, y: Math.random() * 100 }) .to(4, { x: -moveX, y: moveY + Math.random() * 100 })
.call(() => { .call(() => {
walkAni.scaleX = 1; walkAni.scaleX = 1;
}) })
.to(4, { x: 0, y: Math.random() * 100 }) .to(4, { x: 0, y: moveY + Math.random() * 100 })
.call(() => { .call(() => {
this.elephentState(0); this.elephentState(0);
}) })
...@@ -367,7 +379,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -367,7 +379,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
let eatAni = pg.view.find(this.elephant, "eat"); let eatAni = pg.view.find(this.elephant, "eat");
walkAni.active = true; walkAni.active = true;
eatAni.active = false; eatAni.active = false;
pg.view.playDBAnimation(walkAni, "happy", 0); let db = pg.view.playDBAnimation(walkAni, "happy", 0);
this.removeHungryAudio(db);
cc.Tween.stopAllByTarget(this.elephant); cc.Tween.stopAllByTarget(this.elephant);
walkAni.scaleX = 1; walkAni.scaleX = 1;
} }
...@@ -376,7 +389,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -376,7 +389,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let eatAni = pg.view.find(this.elephant, "eat"); let eatAni = pg.view.find(this.elephant, "eat");
walkAni.active = true; walkAni.active = true;
eatAni.active = false; eatAni.active = false;
pg.view.playDBAnimation(walkAni, "hungry", 0); this.playLocalAudio("hungry");
let db: dragonBones.ArmatureDisplay = pg.view.playDBAnimation(walkAni, "hungry", 0);
this.removeHungryAudio(db);
this.addHungryAudio(db);
cc.Tween.stopAllByTarget(this.elephant); cc.Tween.stopAllByTarget(this.elephant);
walkAni.scaleX = 1; walkAni.scaleX = 1;
} }
...@@ -387,9 +403,20 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -387,9 +403,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
eatAni.active = true; eatAni.active = true;
pg.view.playDBAnimation(eatAni, "eating", 0); pg.view.playDBAnimation(eatAni, "eating", 0);
cc.Tween.stopAllByTarget(this.elephant); cc.Tween.stopAllByTarget(this.elephant);
this.playLocalAudio("eating");
setTimeout(() => { setTimeout(() => {
this.elephentState(0); this.elephentState(0);
}, 4000); }, 3500);
}
addHungryAudio(db: dragonBones.ArmatureDisplay) {
db.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.playHungryAudio, this)
}
removeHungryAudio(db: dragonBones.ArmatureDisplay) {
db.removeEventListener(dragonBones.EventObject.LOOP_COMPLETE, this.playHungryAudio, this)
}
playHungryAudio() {
this.playLocalAudio("hungry");
} }
......
...@@ -320,7 +320,7 @@ let pg = { ...@@ -320,7 +320,7 @@ let pg = {
return new Promise((resolve) => { return new Promise((resolve) => {
return setTimeout(() => { return setTimeout(() => {
return resolve({ status: 200 }); return resolve({ status: 200 });
}, 100 + Math.random() * 300); }, 60);
let xhr = cc.loader.getXMLHttpRequest(); let xhr = cc.loader.getXMLHttpRequest();
xhr.timeout = 5000; xhr.timeout = 5000;
xhr.responseType = "text"; xhr.responseType = "text";
......
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