UpdateScore.ts 554 B

1234567891011121314151617181920212223
  1. import { _decorator, Component, Node,Label } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('UpdateScore')
  4. export class UpdateScore extends Component {
  5. public static instance:UpdateScore=null;
  6. private totalScore:number=0;
  7. start() {
  8. UpdateScore.instance=this;
  9. this.node.getComponent(Label).string='0';
  10. }
  11. update(deltaTime: number) {
  12. }
  13. public Update_Score(score:number){
  14. this.totalScore+=score;
  15. this.node.getComponent(Label).string=this.totalScore.toString();
  16. }
  17. }