Sign.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. /**item */
  5. preSignItem: cc.Prefab,
  6. btsp: cc.SpriteFrame,
  7. },
  8. // LIFE-CYCLE CALLBACKS:
  9. onLoad() {
  10. let dayText = ['一', '二', '三', '四', '五', '六', '七'];
  11. for (let i = 0; i < 7; i++) {
  12. let tPrefab = cc.instantiate(this.preSignItem);
  13. tPrefab.parent = this.node;
  14. //设置item位置
  15. let x0 = -198;
  16. let y0 = 167;
  17. let col = i % 3;
  18. if (i == 6) {
  19. col = 1;
  20. }
  21. let row = Math.floor(i / 3);
  22. let x = x0 + col * 198;
  23. let y = y0 - row * (167 + 51);
  24. tPrefab.setPosition(x, y);
  25. //更新信息
  26. let dayNum = tPrefab.getChildByName('dayNum').getComponent(cc.Label);
  27. dayNum.string = '第' + dayText[i] + '天';
  28. /**领取 */
  29. let btnReceive = tPrefab.getChildByName('btnReceive');
  30. btnReceive.active = false;
  31. /**待领取 */
  32. let toReceive = tPrefab.getChildByName('toReceive');
  33. toReceive.active = true;
  34. /**已领取 */
  35. let received = tPrefab.getChildByName('received');
  36. received.active = false;
  37. if (i == 0) {
  38. received.active = true;
  39. toReceive.active = false;
  40. }
  41. else if (i == 1) {
  42. btnReceive.active = true;
  43. toReceive.active = false;
  44. }
  45. }
  46. },
  47. });