Middle.ts 1.33 KB
Newer Older
xytk's avatar
xytk committed
1 2

const {ccclass, property} = cc._decorator;
xytk's avatar
xytk committed
3
import {asyncPlayDragonBoneAnimation} from "./utils"
xytk's avatar
xytk committed
4 5 6
@ccclass
export default class NewClass extends cc.Component {

xytk's avatar
xytk committed
7 8 9 10 11 12
    @property(cc.AudioSource)
    dragonBoneAudioSource:cc.AudioSource = null;
    @property(cc.AudioSource)
    picAAudioSource:cc.AudioSource = null;
    @property(cc.AudioSource)
    picCAudioSource:cc.AudioSource = null;
xytk's avatar
xytk committed
13 14 15 16 17 18 19 20


    // onLoad () {}

    start () {
        this.scheduleOnce(()=>{
            this.flyIn();
        },0.5);
xytk's avatar
xytk committed
21 22 23 24 25 26 27 28 29 30 31

        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();
        })

xytk's avatar
xytk committed
32 33 34 35
    }

    // update (dt) {}

xytk's avatar
xytk committed
36 37 38 39 40 41 42 43 44 45 46

    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;
        }
    }

xytk's avatar
xytk committed
47 48 49 50 51 52 53 54 55 56 57
    /**
     * 飞入
     */
    flyIn(){
        let tween = cc.tween().to(1,{y:0},{easing:"quadOut"});
        cc.tween(this.node).then(tween).start();
    }



}