Tittle.ts 710 Bytes
Newer Older
xytk's avatar
xytk committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    titleTextLabel: cc.Label = null;

    @property(cc.AudioSource)
    audioSource:cc.AudioSource = null;

    // onLoad () {}

    start () {
        this.audioSource.node.on(cc.Node.EventType.TOUCH_START,this.playSe,this);
xytk's avatar
xytk committed
17
        // cc.view.getFrameSize()
xytk's avatar
xytk committed
18 19 20 21 22 23 24 25 26
    }
    /**
     * 设置标题文本
     * @param text 
     */
    setTittleText(text:string){
        this.titleTextLabel.string = text?text:"";
    }
    
xytk's avatar
xytk committed
27 28 29 30
    setAudioClip(ac:cc.AudioClip){
        this.audioSource.clip = ac;
    }

xytk's avatar
xytk committed
31 32 33 34 35 36
    playSe(){
        this.audioSource.play();
    }

    // update (dt) {}
}