GameCategoryListCell.js 1.88 KB
//明星列表ListCell
var Common = require('Common');
var FocusInfo = require('FocusInfo');
var ListCell = require('ListCell');
var Network = require('Network');

cc.Class({
    extends: ListCell,

    properties: {
        id: 0,
        apkName:"",         //包名
        bg: cc.Sprite,      //背景
        starName: cc.Label,     //名称
        pic: cc.Sprite,     //动漫图片
    },

    statics: {
        PFB_NAME: 'prefab/pfbGameCategoryListCell',
        CELL_NAME: 'StarListCell',
    },

    init: function (iCellIndex, bIsFocusEnable, compSceneCanvas) {
        //准备焦点坐标
        let fiCategoryBlock = this.node.addComponent(FocusInfo);
        fiCategoryBlock.init(
            null, false, null, null, 1.0
        );
        compSceneCanvas.addNodeToFocusTarget(0, this.node.name, this.node);
    },

    render(oData, iRecordIndex) {
        this.id = oData.id;
        this.starName.string = oData.title;
        this.apkName=oData.packageName;
        // // this.bg.spriteFrame.setRect(cc.rect(0, 0, 214, 214));
        var self = this;
        cc.loader.loadRes(oData.image[0].fileUrl, cc.Texture2D, function (err, texture) {
            self.pic.spriteFrame = new cc.SpriteFrame(texture);
        });
        // if (oData.image[0]) {
        //     var self = this;
        //     Network.loadImageInNativeRuntime(
        //         Common.TOPDRAW_IMAGE_SERVER + oData.image[0].fileUrl,
        //         function (texture) {
        //             self.pic.spriteFrame = new cc.SpriteFrame(texture);
        //         }, null, this
        //     );
        // }
        //准备焦点坐标oData.tvlink
        this.node.getComponent(FocusInfo).setTVLink("");
    },

    enableFocusInfo: function () {
        this.node.getComponent(FocusInfo).setEnable(true);
    },

    disableFocusInfo: function () {
        this.node.getComponent(FocusInfo).setEnable(false);
    },

});