MusicImgChange.js 953 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Learn cc.Class:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/class.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. cc.Class({
  8. extends: cc.Component,
  9. properties: {
  10. imgOn:{
  11. default:null,
  12. type:cc.SpriteFrame
  13. },
  14. imgOff:{
  15. default: null,
  16. type: cc.SpriteFrame
  17. },
  18. // mbool:true
  19. },
  20. mbtn(mbool){
  21. let sprite = this.node.getComponent(cc.Sprite)
  22. console.log(sprite.name)
  23. // this.mbool = !this.mbool;
  24. if (mbool){
  25. sprite.spriteFrame = this.imgOn
  26. }else {
  27. sprite.spriteFrame = this.imgOff
  28. }
  29. },
  30. // LIFE-CYCLE CALLBACKS:
  31. // onLoad () {},
  32. start () {
  33. },
  34. // update (dt) {},
  35. });