results.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { http } from '../http';
  3. import { config } from '../config';
  4. import { audioManager } from '../manager/audioManager';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('results')
  7. export class results extends Component {
  8. @property(Node) btn_restart:Node = null
  9. @property(Node) lab_scores:Node = null
  10. private call_back = null
  11. start() {
  12. this.btn_restart.on(Node.EventType.TOUCH_END,()=>{
  13. if(this.call_back!=null){
  14. this.call_back()
  15. this.close()
  16. }
  17. })
  18. }
  19. private close(){
  20. this.node.active = false;
  21. }
  22. public show(scores:number,call){
  23. http.post(config.API.sync_integral,{"integral":scores},(err,data)=>{
  24. if(!err){
  25. console.log("data",data)
  26. // http.get(config.STATIC_API.regions,(e,d)=>{
  27. // console.log("regions",d)
  28. // })
  29. // http.get(config.STATIC_API.rankings(0),(err,data)=>{
  30. // console.log("rankings",data)
  31. // })
  32. }
  33. })
  34. audioManager.Instance().playSound(config.AUDIO.win)
  35. this.node.active = true
  36. this.lab_scores.getComponent(Label).string = "积分:"+ scores+""
  37. this.call_back = call
  38. }
  39. }