java-andengine中的自定义ScrollView
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-andengine中的自定义ScrollView,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2516字,纯文字阅读大概需要4分钟。
内容图文
![java-andengine中的自定义ScrollView](/upload/InfoBanner/zyjiaocheng/691/60443e6980924bf7b0c3899eee905e2a.jpg)
如何制作可移动所有侧面的自定义ScrollView.以及如何在andengine中找到ScrollView的位置?
提前致谢.
解决方法:
我写了一个小的ShapeScrollContainer.java类,该类正在进行中,但是可以正常使用,欢迎您使用,
https://skydrive.live.com/redir?resid=EB5E1E510A150D4D!105
它允许用户在容器区域内滚动,添加到ShapeScrollContainer中的内容将自动进行相应移动.如果将内容移到ShapeScrollContainer的边界之外,则会将内容项的可见性设置为false(如稍后所述,您也可以使其在接近这些边界时淡出内容).
我提供了完整的Java文档,其中包含每种方法的说明.本质上,它扩展了Rectangle并实现了IScrollDetectorListener,IClickDetectorListener接口.只需将其添加到场景中,就像添加另一个Shape,
ShapeScrollContainer ScrollableArea = new ShapeScrollContainer(x, y, width, height, new IShapeScrollContainerTouchListener()
{
@Override
public void OnContentClicked(Shape pShape) {
// TODO Auto-generated method stub
}
});
mScene.registerTouchArea(ScrollableArea);
mScene.attachChild(ScrollableArea);
如果您添加到ShapeScrollContainer的项目被用户单击,则将调用OnContentClicked接口方法. pShape参数将是指向被单击的Shape的指针. ShapeScrollContainer会移动内容而不是移动相机,因此尚未添加到容器中的任何其他精灵将不受影响.
然后只需调用ShapeScrollContainer.Add()方法即可添加您的Sprites,动画/平铺Sprite,Rectangles等.例如,一个ChangeableText,
final ChangeableText mMessage = new ChangeableText(x, y, mFont, "Scroll Me", HorizontalAlign.LEFT, 14);
mMessage.setVisible(true);
mMessage.setZIndex(10);
mMessage.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
mScene.attachChild(mMessage);
ScrollableArea.Add(mMessage);
添加完所有内容后,ShapeScrollContainer将具有多种方法来满足您的需求,
//Whether you want to allow user to scroll vertical/horizontal
ScrollableArea.SetScrollableDirections(false, true);
//Only allow the user to scroll in a direction to available content
//(no more content in that direction - the user will be prevented from scrolling)
ScrollableArea.SetScrollLock(true);
//By how much over the last content in any direction the user is allowed to scroll (% of height/width)
ScrollableArea.SetAlphaPadding(10.0f, 0);
//Allow ShapeScrollContainer to increase alpha of contents and by what distance it starts inside
//the ShapeScrollContainer itself. (Fades content as it approaches the edges due to user scrolling)
ScrollableArea.SetScrollLockPadding(50.0f,0.0f);
//Whether scroll bars will be visible, (horizontal/vertical)
ScrollableArea.SetScrollBarVisibitlity(true,true)
//...
//A lot more methods to refine the ScrollableArea appearence and behaviour - see java doc
希望这是有用的.
内容总结
以上是互联网集市为您收集整理的java-andengine中的自定义ScrollView全部内容,希望文章能够帮你解决java-andengine中的自定义ScrollView所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。