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

Button Music On / Off Change SpriteFrame, when Pressed

$
0
0

@luke2125 wrote:

Hi,

Have a button, and trying to change image of Music ON -> Music OFF, however, sprite is not changing.....

cc.Class({
extends: cc.Component,

properties: {
//    musicoffsprite:cc.SpriteFrame
},

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

this.count = 0;
this.MusicOnOffPress();
},
MusicOnOffPress:function(){
this.node.on(cc.Node.EventType.TOUCH_START, function (event) {
var music = this.getComponent(cc.AudioSource);
music.pause();
this.count++;
**var sprite = this.getComponent(cc.Sprite);
sprite.spriteFrame = new cc.SpriteFrame("assets/Hud Texture/musicoffbuttongraphic.png");**
if(this.count>=2){
music.resume();
this.count = 0;
}},this);},

Any help will be appreciated it......God Bless...

Sincerely,

Sunday

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17079

Trending Articles



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