咸鱼的反击
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

88 lines
2.4 KiB

import EventMgr from "../../FrameWork/Event/EventMgr";
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import Common5 from "../../Platform/th/Common5";
import UserManager from "../Manager/UserManager";
const {ccclass, property} = cc._decorator;
@ccclass
export default class YuanBao extends cc.Component {
@property(cc.Node)
yuanBaoNumStr: cc.Node = null;
@property(cc.Node)
changeLabel: cc.Node = null;
chaopiaoIcon: cc.Node = null
yuanBao2Str:cc.Node = null
yuanBao2ChangeLabel:cc.Node = null
endAnim = true
onLoad () {
}
start () {
this.chaopiaoIcon = this.node.getChildByName('jinbi').getChildByName('钞票')
this.showMoney(false);
EventMgr.onEvent_custom(ryw_Event.updateMoney,(money,isAnim)=>{
//console.log('updateMoney++++++++')
this.showMoney(isAnim);
if(money == 0){
return
}
if(isNaN(money)){
}else{
let label = cc.instantiate(this.changeLabel)
label.active = true
label.parent = this.changeLabel.parent
if(money>0){
label.getComponent(cc.Label).string = "+"+Common5.getNumberChangeHanzi(money,'1',1)
}else if(money<0){
label.getComponent(cc.Label).string = Common5.getNumberChangeHanzi(money,'1',1)+''
}
cc.tween(label)
.delay(0.2)
.by(1,{y:20,opacity:0})
.call(()=>{
label.removeFromParent()
})
.start()
}
},this)
}
showMoney(money){
let aaa = Common5.getNumberChangeHanzi(UserManager.getCurMoney(),'2')
aaa = aaa as string
this.yuanBaoNumStr.getComponent(cc.Label).string = aaa;
if(this.endAnim && money>0){
this.endAnim = false
this.yuanBaoNumStr.scale = 1.2
cc.tween(this.yuanBaoNumStr)
.to(0.15, {scale:1.3})
.to(0.15, {scale:1})
.call(()=>{
this.endAnim = true
})
.start()
if(this.chaopiaoIcon){
cc.tween(this.chaopiaoIcon)
.to(0.15, {scale:1.3})
.to(0.15, {scale:1})
.start()
}
}
}
}