【LIST无法拖动】参照官方实例做的

尝试删除了滤镜等多种方式,任然无法点击LIST的区域拖动
已邀请:

HIPPOPMANANDRAPGIRL

赞同来自:

求救, 大佬门

HIPPOPMANANDRAPGIRL

赞同来自:

在线等,乡亲们。list代码就就在启动页的UI类

HIPPOPMANANDRAPGIRL

赞同来自:

 private setup(json :any): void {
        var list = new List();
        list.itemRender = Item;
        list.repeatX = 3;
        list.repeatY = 3;
        list.x = 50;
        list.y = 100;
        list.spaceX = -50;
        list.spaceY = 30;
        let paihangbang = new Text();
        paihangbang.fontSize = 30;
        paihangbang.text = "已获得关卡";
        paihangbang.x = (list.width - paihangbang.fontSize * 3) / 2;
        console.info(list.x + "---"+list.y + "---"+paihangbang.x + "---"+paihangbang.y + "---")
        paihangbang.y -= (paihangbang.fontSize + 20);
        paihangbang.color="#ffffff";
         
        list.addChild(paihangbang);
        
        // 使用但隐藏滚动条
        list.vScrollBarSkin = "";
        list.selectEnable = true;
        list.selectHandler = new Handler(this, this.onSelect);
        list.renderHandler = new Handler(this, this.updateItem);
        
        // 设置数据项为对应图片的路径
        var data: Array<String> = [];
        //解析二进制已获得关卡队列,先取有效位书 
        let s = json.my_guanqia.substr(0,this.default_guanqia.length);
        data = this.find_StringAllIndex(s);
        this.box_arr= data;
        list.array = data;
        
        this.list = list;
        Laya.stage.addChild(list);
        this.hitArea = new Laya.HitArea();
        this.hitArea.hit.drawRect(list.x, list.y -100,list.width, list.height, "#000000");
        //限制鼠标点击区域
        
        
    }
    find_StringAllIndex(str :String):String[]{
        let pos_arr =[];
        for(let i=0;i < str.length;i++){
            let e = str.charAt(i);
            if (e=="1"){
               let  ii= i+1;
                pos_arr.push(ii+"");
            }
        }
        return pos_arr;
    }
    private updateItem(cell: Item): void {
        cell.setImg(cell.dataSource); 
    }
    private onSelect(index: number): void {
        console.log("当前选择的索引:" + index);
        console.log("目的是哪一关" + this.box_arr[index]);
        //被点击的节点
        this.guaqia = this.box_arr[index];
        let ge = new GameIEntity();
        let ui =  ge.getvalue(this.guaqia);
        (ui as GameUI1).userid_ = this.userid_;
        (ui as GameUI1).username_ = this.username_;
        (ui as GameUI1).nickname_ = this.nickname_;
        this.list.removeSelf();
        this.list.destroy();
        this.removeSelf();
        this.destroy();
        Laya.stage.addChild(ui); 
    }
    jumpScene()
    {   
        let ge = new GameIEntity();
        let ui =  ge.getvalue(this.guaqia);
        (ui as GameUI1).userid_ = this.userid_;
        (ui as GameUI1).username_ = this.username_;
        (ui as GameUI1).nickname_ = this.nickname_;
        this.removeSelf();
        this.destroy();
        Laya.stage.addChild(ui);
    }
    removeChild_list(){
        this.hitArea = new Laya.HitArea();
        this.hitArea.hit.drawRect(0, 0, Laya.stage.width, Laya.stage.height, "#000000");
        Laya.SoundManager.playSound("sound/hitbutton.wav");
        this.list.removeSelf();
        this.list.destroy(); 
    }
 
    
}
import Box = Laya.Box;
import Image = Laya.Image;
import Text = Laya.Text;
class Item extends Box {
    public static WID: number = 400;
    public static HEI: number =40;
    private text_guanqia: Text;
    private text_guanqia_info: Text; 
    private img: Image;
    constructor(){
        super();
        this.size(Item.WID, Item.HEI);
        this.img = new Image();
        this.img.width = 200;
        this.img.height = 200;
        this.height = 230;
        this.text_guanqia =new Text();
        this.text_guanqia.x = 100;
        this.text_guanqia.y = 205;
        this.text_guanqia.fontSize = 25;
        this.text_guanqia.color="#ffffff";
        this.text_guanqia_info =new Text();
        this.text_guanqia_info.x = 205;
        this.text_guanqia_info.width= 150;
        this.text_guanqia_info.fontSize = 15;
        this.text_guanqia_info.wordWrap = true;
        this.text_guanqia_info.align ="left";
        this.text_guanqia_info.color="#ffffff";
        this.addChild(this.img);
        this.addChild(this.text_guanqia);
        this.addChild(this.text_guanqia_info);
       
    } 
    public setImg(src: any): void {
        let tmp = Number(src) ;
        this.img.skin ="./puzzlePic/guanqiaMap/pic-"+ tmp+".png";
        this.text_guanqia.text = "pic-"+ tmp;
        let gf = new GuanqiaEntity();
        //guanqia1:{id:"1",publish_date:"20210101",level:"1",author:"官方发布",info:"我可以-四子"};
        //获取关卡信息后格式化
        let t= gf.getGuanqiaInfo(tmp);
        this.text_guanqia_info.text = gf.format_GuanqiaInfo(t);
        this.name =  "pic-"+ tmp;
        var glowFilter: Laya.GlowFilter = new Laya.GlowFilter("#08f6e3", 7, 0, 0);
        (this as Laya.Sprite).filters = [glowFilter];
    }

Laya_XS

赞同来自:

麻烦提交可以运行的demo case,你提交的例子现在是报错,你可以提交简单的demo case工程,然后把问题描述清楚。

要回复问题请先

商务合作
商务合作