tipBox.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // 提示框//需要其他代码联系 BatchMichaelbXKxyJ@gmail.com
  2. //电子邮件puhalskijsemen@gmail.com
  3. //源码网站 开vpn全局模式打开 http://web3incubators.com/
  4. //电报https://t.me/gamecode999
  5. //网页客服 http://web3incubators.com/kefu.html
  6. cc.Class({
  7. extends: cc.Component,
  8. properties: {
  9. label: cc.Label,
  10. },
  11. start() {
  12. this.tip = ['一次性大量消除可获得道具!', 'X2道具可以翻倍一次消除的分数', '炸弹道具可以消除全屏同色方块', '单个方块无法消除哦','捡到宝箱!加两步!','仙女棒可以消除所有单个方块']
  13. this.otherTip = [
  14. '哎呀,今天的星星好像在对我眨眼呢!',
  15. '喵~早安,又是元气满满的一天!',
  16. '嘿嘿,我是不是世界上最可爱的小仙女呀?',
  17. '嗯哼,要不要吃颗糖,甜甜的,就像我一样。',
  18. '哎呀,这个小兔子公仔好像在说它喜欢我呢!',
  19. '嘻嘻,今天的风好温柔,就像你的拥抱。',
  20. '嗷呜~我饿了,我们去吃点好吃的吧!',
  21. '你看,那朵云好像一只大棉花糖哦!',
  22. '每个女孩子都是掉落人间的小天使,要好好爱护自己哦。',
  23. '嘿嘿,我今天学了一个新魔法,可以变出好多小星星!',
  24. '哎呀,我的小熊饼干好像在跟我说话呢!',
  25. '你看,那个彩虹就像我们的梦想,绚丽又遥不可及',
  26. '嘿嘿,我今天捡到了一片四叶草,希望它能带给我们好运。',
  27. '嗷嗷,我今天也要加油鸭!',
  28. '你看,那个月亮好像在对我们微笑。',
  29. '嗯哼,我今天要做一个甜甜的梦。',
  30. '嘿嘿,我今天学会了一个新的魔法,可以变出好多小花朵!',
  31. '嗯~这个蛋糕太美味了,就像你的笑容。',
  32. '遇见你,是我人生中最美丽的意外。',
  33. '你看,那个夕阳好像在说它也舍不得今天结束。'
  34. ]
  35. },
  36. init(s, type) { //传type是道具触发 不传是随机触发
  37. this._score = s
  38. if (type > 0) {
  39. this.label.string = this.tip[type]
  40. } else {
  41. this.label.string = this.otherTip[Math.floor(Math.random() * this.otherTip.length)]
  42. }
  43. this.openTipBox()
  44. if (this.gapTimer) {
  45. clearInterval(this.gapTimer)
  46. }
  47. this.gapTimer = setInterval(() => {
  48. this.init(this._score, -1)
  49. }, 5000)
  50. },
  51. openTipBox() {
  52. if (!this.isOpen) {
  53. // 动画 动画回掉
  54. let action = cc.scaleTo(0.3, 1).easing(cc.easeBackOut(2.0))
  55. let sq = cc.sequence(action, cc.callFunc(() => {
  56. this.isOpen = true
  57. }))
  58. this.node.runAction(sq)
  59. }
  60. if (this.closeTimer) {
  61. clearTimeout(this.closeTimer)
  62. }
  63. this.closeTimer = setTimeout(() => {
  64. this.closeTioBox()
  65. }, 4000)
  66. },
  67. closeTioBox() {
  68. let action = cc.scaleTo(0.3, 0)
  69. let sq = cc.sequence(action, cc.callFunc(() => {
  70. this.isOpen = false
  71. }))
  72. this.node.runAction(sq)
  73. // if (this.openTimer) {
  74. // clearTimeout(this.closeTimer)
  75. // }
  76. //this.openTimer = setTimeout(this.init(this._score, null), this._score.level * 2000)
  77. },
  78. // update (dt) {},
  79. });