Commit dad70bdf authored by Tt's avatar Tt

左中

parent 4beae6b1
This diff is collapsed.
This diff is collapsed.
import pg from "./pg";
const { ccclass, property } = cc._decorator;
@ccclass
export default class dg_xiaodi extends cc.Component {
@property(cc.Node)
aniRole: cc.Node = null;
@property moveX: number = 500;
private defaultX: number;
onLoad() {
this.defaultX = this.aniRole.x;
}
private audioIdEnter: any;
playEnter(audioUrl) {
return new Promise((resolve, reject) => {
this.node.active = true;
let startX = this.defaultX + this.moveX;
this.aniRole.x = startX;
cc.tween(this.aniRole)
.call(() => {
pg.view.playDBAnimation(this.aniRole, 'run');
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
})
.to(0.5, { x: 0 })
.call(() => {
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
pg.view.playDBAnimation(this.aniRole, 'talk');
pg.audio.playAudioByUrl(audioUrl, () => {
this.audioIdEnter = null;
cc.tween(this.aniRole)
.call(() => {
pg.view.playDBAnimation(this.aniRole, 'run');
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
})
.to(0.5, { x: -1800 })
.call(() => {
this.scheduleOnce(() => {
resolve('');
}, 0.5)
})
.start();
}, audioId => {
this.audioIdEnter = audioId;
})
})
.start();
});
}
playEnterEnd() {
this.node.active = false;
if (this.audioIdEnter) {
cc.audioEngine.stopEffect(this.audioIdEnter)
}
}
private audioIdOver: any;
playOver(audioUrl) {
this.node.active = true;
let startX = this.defaultX + this.moveX;
this.aniRole.x = startX;
cc.tween(this.aniRole)
.call(() => {
pg.view.playDBAnimation(this.aniRole, 'run');
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
})
.to(0.3, { x: this.defaultX })
.call(() => {
if (this.moveX < 0) {
this.aniRole.scaleX = -this.aniRole.scaleX;
}
pg.view.playDBAnimation(this.aniRole, 'talk');
pg.audio.playAudioByUrl(audioUrl, () => {
this.audioIdOver = null;
pg.view.playDBAnimation(this.aniRole, 'normal');
}, audioId => {
this.audioIdOver = audioId;
})
})
.start();
}
playOverEnd() {
this.node.active = false;
if (this.audioIdOver) {
cc.audioEngine.stopEffect(this.audioIdOver)
}
}
start() {
}
update(dt) {
}
}
{
"ver": "1.0.8",
"uuid": "4c50260e-13ba-4b6a-8001-fa53f011a8bc",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "temp/vscode-dist", "outDir": "temp/vscode-dist",
"allowJs": true,
"forceConsistentCasingInFileNames": true "forceConsistentCasingInFileNames": true
}, },
"exclude": [ "exclude": [
......
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