| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- cc.Class({
- extends: cc.Component,
- properties: {
- stateArray: {
- default: [],
- type: cc.SpriteFrame,
- serializable: true,
- },
- changeSprite: {
- default: null,
- type: cc.Sprite,
- serializable: true,
- },
- //工作状态
- workingStatus: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- },
- // start(){
- // this.onChangeSpriteFunction(2);
- // },
- onChangeSpriteFunction(consume) {
- if (consume <= 0 || consume >= 50) {
- this.workingStatus.active = false;
- } else if (!this.workingStatus.active) {
- this.workingStatus.active = true
- }
- let index = 50 - consume;
- // let index = consume%3;
- // cc.log(Math.floor(this._Strength % 3));
- if (index >= 15 && index <= 25)
- this.changeSprite.spriteFrame = this.stateArray[1];
- else if (index > 25)
- this.changeSprite.spriteFrame = this.stateArray[2];
- },
- onResetSprite() {
- this.changeSprite.spriteFrame = this.stateArray[0];
- }
- });
|