MusicNode.js 6.11 KB
Newer Older
huoshizhe's avatar
huoshizhe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
27
        star: {
huoshizhe's avatar
huoshizhe committed
28 29 30
            default: null,
            type: cc.AudioClip
        },
31
        按住: {
huoshizhe's avatar
huoshizhe committed
32 33 34
            default: null,
            type: cc.AudioClip
        },
35
        按钮: {
huoshizhe's avatar
huoshizhe committed
36 37 38
            default: null,
            type: cc.AudioClip
        },
39
        撒花: {
huoshizhe's avatar
huoshizhe committed
40 41 42
            default: null,
            type: cc.AudioClip
        },
43
        放大: {
huoshizhe's avatar
huoshizhe committed
44 45 46
            default: null,
            type: cc.AudioClip
        },
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245

        letterA: {
            default: null,
            type: cc.AudioClip
        },
        letterB: {
            default: null,
            type: cc.AudioClip
        },
        letterC: {
            default: null,
            type: cc.AudioClip
        },
        letterD: {
            default: null,
            type: cc.AudioClip
        },
        letterE: {
            default: null,
            type: cc.AudioClip
        },
        letterF: {
            default: null,
            type: cc.AudioClip
        },
        letterG: {
            default: null,
            type: cc.AudioClip
        },
        letterH: {
            default: null,
            type: cc.AudioClip
        },
        letterI: {
            default: null,
            type: cc.AudioClip
        },
        letterJ: {
            default: null,
            type: cc.AudioClip
        },
        letterK: {
            default: null,
            type: cc.AudioClip
        },
        letterL: {
            default: null,
            type: cc.AudioClip
        },
        letterM: {
            default: null,
            type: cc.AudioClip
        },
        letterN: {
            default: null,
            type: cc.AudioClip
        },
        letterO: {
            default: null,
            type: cc.AudioClip
        },
        letterP: {
            default: null,
            type: cc.AudioClip
        },
        letterQ: {
            default: null,
            type: cc.AudioClip
        },
        letterR: {
            default: null,
            type: cc.AudioClip
        },
        letterS: {
            default: null,
            type: cc.AudioClip
        },
        letterT: {
            default: null,
            type: cc.AudioClip
        },
        letterU: {
            default: null,
            type: cc.AudioClip
        },
        letterV: {
            default: null,
            type: cc.AudioClip
        },
        letterW: {
            default: null,
            type: cc.AudioClip
        },
        letterX: {
            default: null,
            type: cc.AudioClip
        },
        letterY: {
            default: null,
            type: cc.AudioClip
        },
        letterZ: {
            default: null,
            type: cc.AudioClip
        },

        wordA: {
            default: null,
            type: cc.AudioClip
        },
        wordB: {
            default: null,
            type: cc.AudioClip
        },
        wordC: {
            default: null,
            type: cc.AudioClip
        },
        wordD: {
            default: null,
            type: cc.AudioClip
        },
        wordE: {
            default: null,
            type: cc.AudioClip
        },
        wordF: {
            default: null,
            type: cc.AudioClip
        },
        wordG: {
            default: null,
            type: cc.AudioClip
        },
        wordH: {
            default: null,
            type: cc.AudioClip
        },
        wordI: {
            default: null,
            type: cc.AudioClip
        },
        wordJ: {
            default: null,
            type: cc.AudioClip
        },
        wordK: {
            default: null,
            type: cc.AudioClip
        },
        wordL: {
            default: null,
            type: cc.AudioClip
        },
        wordM: {
            default: null,
            type: cc.AudioClip
        },
        wordN: {
            default: null,
            type: cc.AudioClip
        },
        wordO: {
            default: null,
            type: cc.AudioClip
        },
        wordP: {
            default: null,
            type: cc.AudioClip
        },
        wordQ: {
            default: null,
            type: cc.AudioClip
        },
        wordR: {
            default: null,
            type: cc.AudioClip
        },
        wordS: {
            default: null,
            type: cc.AudioClip
        },
        wordT: {
            default: null,
            type: cc.AudioClip
        },
        wordU: {
            default: null,
            type: cc.AudioClip
        },
        wordV: {
            default: null,
            type: cc.AudioClip
        },
        wordW: {
            default: null,
            type: cc.AudioClip
        },
        wordX: {
huoshizhe's avatar
huoshizhe committed
246 247 248
            default: null,
            type: cc.AudioClip
        },
249
        wordY: {
huoshizhe's avatar
huoshizhe committed
250 251 252
            default: null,
            type: cc.AudioClip
        },
253
        wordZ: {
huoshizhe's avatar
huoshizhe committed
254 255 256 257 258 259 260 261 262 263 264 265 266 267
            default: null,
            type: cc.AudioClip
        },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start() {

    },

    playEffect(name, loop = false, volume = 1) {
268 269 270 271
        return new Promise((resolve, reject) => {
            const audioID = cc.audioEngine.play(this[name], loop, volume);
            cc.audioEngine.setFinishCallback(audioID, resolve);
        })
huoshizhe's avatar
huoshizhe committed
272 273 274
    }
    // update (dt) {},
});