首页 > 其他 > 详细

Egret之egret.ScrollView

时间:2018-06-21 17:13:19      阅读:501      评论:0      收藏:0      [点我收藏+]
由于在微信小游戏中,无法使用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;

Egret之egret.ScrollView

原文:http://blog.51cto.com/aonaufly/2131345

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!