| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- cc.Class({
- extends: cc.Component,
- properties: {
- /**item */
- preSignItem: cc.Prefab,
- btsp: cc.SpriteFrame,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad() {
- let dayText = ['一', '二', '三', '四', '五', '六', '七'];
- for (let i = 0; i < 7; i++) {
- let tPrefab = cc.instantiate(this.preSignItem);
- tPrefab.parent = this.node;
- //设置item位置
- let x0 = -198;
- let y0 = 167;
- let col = i % 3;
- if (i == 6) {
- col = 1;
- }
- let row = Math.floor(i / 3);
- let x = x0 + col * 198;
- let y = y0 - row * (167 + 51);
- tPrefab.setPosition(x, y);
- //更新信息
- let dayNum = tPrefab.getChildByName('dayNum').getComponent(cc.Label);
- dayNum.string = '第' + dayText[i] + '天';
- /**领取 */
- let btnReceive = tPrefab.getChildByName('btnReceive');
- btnReceive.active = false;
- /**待领取 */
- let toReceive = tPrefab.getChildByName('toReceive');
- toReceive.active = true;
- /**已领取 */
- let received = tPrefab.getChildByName('received');
- received.active = false;
- if (i == 0) {
- received.active = true;
- toReceive.active = false;
- }
- else if (i == 1) {
- btnReceive.active = true;
- toReceive.active = false;
- }
- }
- },
- });
|