自定义渲染器和主题的问题

自定义渲染器和主题的问题

[ENGLISH]Problem With custon List ItemRenderer and theme

[原文]http://forum.starling-framework.org/topic/problem-with-custom-list-itemrenderer-and-theme


开始


要做自定义列表项渲染主题,

比如,用MetalWorksMobile主题,TileList例子

现在,我想自定义背景,和自定义标签

override protected function initialize():void
{
	const collection:ListCollection = new ListCollection(
	[
		{ label2: "Videos", texture: this._iconAtlas.getTexture("projector"), event: SHOW_VIEW_VIDEO},
		{ label2: "Search", texture: this._iconAtlas.getTexture("search"), event: SHOW_VIEW_SEARCH },
		{ label2: "Options", texture: this._iconAtlas.getTexture("setting"), event: SHOW_VIEW_OPTIONS },
		{ label2: "Help", texture: this._iconAtlas.getTexture("help"), event: SHOW_VIEW_HELP },
		{ label2: "About very long", texture: this._iconAtlas.getTexture("about"), event: SHOW_VIEW_ABOUT },
 
	]);
 
	const listLayout:TiledRowsLayout = new TiledRowsLayout();
	listLayout.paging = TiledRowsLayout.PAGING_HORIZONTAL;
	listLayout.useSquareTiles = false;
	listLayout.tileHorizontalAlign = TiledRowsLayout.TILE_HORIZONTAL_ALIGN_CENTER;
	listLayout.horizontalAlign = TiledRowsLayout.HORIZONTAL_ALIGN_CENTER;
 
	_list = new List();
	_list.backgroundSkin = new Quad(100, 100, 0xCCCCCC);
	_list.dataProvider = collection;
	_list.layout = listLayout;
 
	_list.itemRendererFactory = tileListItemRendererFactory;
	this.addChild(_list);
}			
 
protected function tileListItemRendererFactory():IListItemRenderer
{
	const renderer:DefaultListItemRenderer = new DefaultListItemRenderer();
	renderer.labelField = "label2";
	renderer.iconTextureField = "texture";
	renderer.iconPosition = Button.ICON_POSITION_TOP;
	renderer.horizontalAlign = Button.HORIZONTAL_ALIGN_CENTER;
	renderer.defaultLabelProperties.textFormat = new BitmapFontTextFormat(_font, NaN, 0xff0000);
 
	var defSkin:Image = new Image(_iconAtlas.getTexture("projector"));
	renderer.defaultSkin = defSkin;
	renderer.defaultSelectedSkin = defSkin;
 
	renderer.defaultLabelProperties.textFormat = new BitmapFontTextFormat(_font, NaN, 0xff0000);
	return renderer;
}



明天继续


不带主题的TileList.是OK的...

一加上MetalWorksMobile主题,label不是红色,背景是MetalWorksMobile的背景,label不是水平居中......

这个方法用来创建自定义主题....

这样写,就不对:


好习惯

所有png文件放在一个文件,用TexturePackerGUI打包

新版地址:..\CodeAndWeb\TexturePacker\bin

自定义位图字体

http://forum.starling-framework.org/topic/use-a-custom-bitmap-font-in-a-list-with-a-theme-1#post-23858





                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值