Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17089

Cc.AudioSource Bug?

$
0
0

@luke2125 wrote:

Hi,

I've added a cc.AudioSource component with the corresponding .wav file for a button sound and below is my code:


cc.Class({
extends: cc.Component,

// properties: {

// },

// use this for initialization
onLoad: function () {

this.MenuButtonPress();

},
MenuButtonPress:function(){
this.node.on(cc.Node.EventType.TOUCH_START, function (event) {
**var buttonsound = this.getComponent(cc.AudioSource);
buttonsound.play();**
cc.director.loadScene('menu');
},this);},

// called every frame, uncomment this function to activate update callback
// update: function (dt) {

// },

});

Now the thing is that when I press the button it sounds, but when I go to another menu within the game, and go back and press the menu button again, it gives me that buttonsound is null? Am I setting up this wrong? Would appreciate feedback......Thanks and God Bless....

Sincerely,

Sunday

Posts: 6

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>