12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // 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: {
- imgOn:{
- default:null,
- type:cc.SpriteFrame
- },
- imgOff:{
- default: null,
- type: cc.SpriteFrame
- },
- // mbool:true
- },
- mbtn(mbool){
- let sprite = this.node.getComponent(cc.Sprite)
- console.log(sprite.name)
- // this.mbool = !this.mbool;
- if (mbool){
- sprite.spriteFrame = this.imgOn
- }else {
- sprite.spriteFrame = this.imgOff
- }
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- // update (dt) {},
- });
|