| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /** 可生产产品列表 */
- import TableView from "../../../game/component/TableView";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class PlantPanel extends cc.Component {
- @property({ type: TableView, displayName: '滚动视图' })
- private tableView: TableView = null;
- private list_data = null;
- @property({ type: cc.Node, tooltip: '文字动画' }) node_ani: cc.Node = null;
- start() {
- gData.plantData.init_itemIndex = -1;
- gData.plantData.init_lock = -1;
- this.initScollView();
- }
- getItemDataByID(id) {
- let len = this.list_data.length;
- for (var i = 0; i < len; i++) {
- if (this.list_data[i].picture == id) {
- return i;
- }
- }
- return 0;
- }
- update(dt)
- {
- if(gData.plantData.init_ani)
- {
- gData.plantData.init_ani = false;
- if (gData.gameData.playerProp.userFarmTaskInfo) {
- let com = gData.gameData.playerProp.userFarmTaskInfo.completeCount;
- let count = gData.gameData.playerProp.userFarmTaskInfo.taskCount;
- let addAni = cc.instantiate(this.node_ani);
- addAni.parent = this.node_ani.parent;
- addAni.getComponent(cc.Label).string = `百元红包:${com}/${count}`;
- cc.tween(addAni).delay(0.7).call(()=>{
- addAni.opacity = 255;
- }).by(0.8, {y : 100}).to(0.4, {opacity : 0}).call(()=>{
- addAni.destroy();
- }).start();
- }
- }
- }
- /**
- * 初始化滚动视图
- */
- private initScollView() {
- this.list_data = gData.plantData.productArr;
- this.tableView.node.emit('srollview-init', this.list_data)
- }
- onDestroy() {
- // this.tableView.clearItem();
- }
- }
|