1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * 主属性节点
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class MainAtterItem extends cc.Component {
- @property(cc.Label)
- mValue: cc.Label = null;
- @property(cc.Node)
- mContrast: cc.Node = null;//对比
- @property(cc.Label)
- mPCT: cc.Label = null;//百分比
- @property(cc.Sprite)
- mUpDown: cc.Sprite = null;
- @property(cc.SpriteFrame)
- mUp: cc.SpriteFrame = null;
- @property(cc.SpriteFrame)
- mDown: cc.SpriteFrame = null;
-
- public setValue(v1){
- this.mContrast.active = false;
- this.mValue.string = ''+v1
- this.mValue.node.color = cc.color(75,43,0)
- }
- public setContrase(v1:number,v2:number){
- this.mContrast.active = true
- this.mValue.string = ''+v1
- let color = cc.color();
- if(v1 >= v2){
- color.r = 75
- color.g = 43
- color.b = 0
- this.mValue.node.color = color
- this.mUpDown.spriteFrame = this.mUp
- }else{
- color.r = 255
- color.g = 24
- color.b = 24
- this.mValue.node.color = color
- this.mUpDown.spriteFrame = this.mDown
- }
- this.mPCT.string = Math.floor((v1-v2)*100/v1)+'%'
- this.mPCT.node.color = color
- }
- }
|