调用 setPublicSpacesData 这个方 传入参数 里面有每一个图片的名字
三个不同的图片 只能加载两个 但是三个同样的图片没问题
this.publicSpaceList = new Laya.List();
this.publicSpaceList.itemRender = gamepublicspaceitem.PublicSpaceItem;
this.publicSpaceList.repeatX = 1;
this.publicSpaceList.repeatY = 3;
this.publicSpaceList.spaceY = 0; //
this.publicSpaceList.x = 22;
this.publicSpaceList.y = 100;
this.publicSpaceList.width = 1553;
this.publicSpaceList.height = 810;//
this.publicSpaceList.vScrollBarSkin = "";
this.publicSpaceList.selectHandler = new Laya.Handler(this, this.onListSelect);
this.publicSpaceList.renderHandler = new Laya.Handler(this, this.updateListItem);
this.publicSpaceList.array = ;
this.addChild( this.publicSpaceList );
public setPublicSpacesData (_publicSpacesInfo:any) : void ///调用这个方 传入参数 里面有每一个图片的名字
{
this.publicSpacesInfo = _publicSpacesInfo;
this.publicSpaceList.array = this.publicSpacesInfo;
}
private updateListItem(cell: gamepublicspaceitem.PublicSpaceItem, index: number) : void
{
cell.publicSpaceData = cell.dataSource;
}
module gamepublicspaceitem
{
export class PublicSpaceItem extends Laya.Box
{
public static BTN_ENTRER_CLICK:string = "BtnEnterClick";
public _publicSpaceData:datasheet.PublicSpaceData;
private bg:Laya.Image;
private btnEnter:Laya.Button;
constructor()
{
super();
this.initUI();
}
private initUI () : void
{
this.bg = new Laya.Image();
this.btnEnter = new Laya.Button();
this.btnEnter.skin = "gamebutton/button_window_public_space_enter.png";
this.btnEnter.on( Laya.Event.CLICK, this, this.btnClick );
this.width = 1553;
this.height = 270;
}
public set publicSpaceData ( publicSpaceInfoData:any )
{
this._publicSpaceData = publicSpaceInfoData;
console.log( this._publicSpaceData.icon );
this.bg.loadImage( "res/atlas/gamewindow/" + this._publicSpaceData.icon,0,0,0,0, new Laya.Handler(this, this.imgLoaded) );
this.addChild( this.bg );
this.addChild( this.btnEnter );
}
private imgLoaded ( e:Laya.Event ) : void
{
this.bg.width = 1553;
this.bg.height = 270;
console.log( "加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载加载" );
}
private btnClick ( e:Laya.Event ) : void
{
switch( e.currentTarget )
{
case this.btnEnter:
// KBEngine.Event.fire
break;
}
}
}
}