Egret之egret.ScrollView

由于在微信小游戏中,无法使用eui框架(即无法使用eui.Scroller) . 还好egret框架内提供了egret.ScrollView可以完美替代.

一 : 申明及初始化

private _scrollview : egret.ScrollView = null; this._scrollview = new egret.ScrollView();

二:选择显示容器

this._scrollview.setContent( this._list_con );

二-1 : private _list_con : egret.DisplayObjectContainer = null;

三:设置位置及SIZE

this._scrollview.x = ( ( this._UI_SZ.x - this._content_bg.width ) >> 1 ) + 13; this._scrollview.y = 101.5; this._scrollview.width = this._content_size.x; this._scrollview.height = this._content_size.y;

四:设置滚动方案

this._scrollview.verticalScrollPolicy = "on"; this._scrollview.horizontalScrollPolicy = "off";

四-1 : 此代码为在竖直方向上滚动 , 在水平方向上不滚动

五:加入到显示容器

this.addChild( this._scrollview );

六:手动设置滚动的距离

this._scrollview.scrollTop = 0;

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。