Account.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const {ccclass, property} = cc._decorator;
  2. /**结算面板 */
  3. @ccclass
  4. export default class Account extends cc.Component {
  5. private icon_win:cc.Node;
  6. private icon_fail:cc.Node;
  7. private scoreLabel:cc.Label;
  8. private btn_continue:cc.Node;
  9. private btn_restart:cc.Node;
  10. private btn_rank:cc.Node;
  11. private btn_share:cc.Node;
  12. /**动态分数值 */
  13. private raisingScore:number = 0;
  14. public onLoad():void{
  15. this.icon_win = this.node.getChildByName('win');
  16. this.icon_fail = this.node.getChildByName('fail');
  17. this.scoreLabel = this.node.getChildByName('score').getChildByName('label').getComponent(cc.Label);
  18. this.btn_continue = this.node.getChildByName('continue');
  19. this.btn_restart = this.node.getChildByName('restart');
  20. this.btn_rank = this.node.getChildByName('rank');
  21. this.btn_share = this.node.getChildByName('share');
  22. this.btn_restart.on(cc.Node.EventType.TOUCH_END,this.restart,this);
  23. this.btn_continue.on(cc.Node.EventType.TOUCH_END,this.continue,this);
  24. this.btn_rank.on(cc.Node.EventType.TOUCH_END,this.showRank,this);
  25. this.btn_share.on(cc.Node.EventType.TOUCH_END,this.share,this);
  26. }
  27. public update():void{
  28. this.scoreLabel.string = Math.floor(this.raisingScore).toString();
  29. }
  30. public showResult(win:boolean):void{
  31. win?this.icon_win.active=true:this.icon_fail.active=true;
  32. }
  33. public showScore(score:number):void{
  34. let tween = new cc.Tween();
  35. tween.target(this);
  36. tween.to(1,{raisingScore:score},null);
  37. tween.start();
  38. }
  39. private restart():void{
  40. cc.audioEngine.playEffect(cc.loader.getRes('audio/btn',cc.AudioClip),false);
  41. window.gameMgr.background.removeAllChildren(true);
  42. window.gameMgr.startGame();
  43. }
  44. private continue():void{
  45. cc.audioEngine.playEffect(cc.loader.getRes('audio/btn',cc.AudioClip),false);
  46. alert('此功能尚未开放');
  47. }
  48. private showRank():void{
  49. cc.audioEngine.playEffect(cc.loader.getRes('audio/btn',cc.AudioClip),false);
  50. alert('此功能尚未开放');
  51. }
  52. private share():void{
  53. cc.audioEngine.playEffect(cc.loader.getRes('audio/btn',cc.AudioClip),false);
  54. alert('此功能尚未开放');
  55. }
  56. }