如图
可加微信15811337109
如图
可加微信15811337109
什么叫立体滚动
好像改zIndex 和scale应该可以实现吧,
这种效果?
使用椭圆公式达到你要的效果。椭圆公式应该是中学课本上的 你查一下就知道啦。
这个不就是unity 里面出来的??其实就是他们一个数组
修改zIndex 和scale就可以实现了,以前用cocos2d-x就做过这个功能
我猜就是你这个
是哒是哒~
加我微信~
这个叫什么列表?
这不是轮播图吗,原生都能写,控制层级以及缩放大小,你这再加个灰态就好了
楼主有弄出来不 可否讲解一下~
我说下思路吧。
1.使用 scrollview
2.编写 updateView 函数绑定在 scrollview 的 scrolling 事件上
3.每当 scrolling 的时候,遍历所有 item,根据椭圆函数设置每个 item 的大小
4.中间被展示的高亮,其余不亮,可以在 srollview 放一个AABB 盒,判断每个 item 的 AABB 和这个rect 是否相交
大致这样吧
updateScrollView() {
let items = this.scrollView.content.children;
items.map(item => {
let viewPos = this.getPositionInView(item);
let scaleX = this.getScaleRate(Math.abs(viewPos.x), 1);
let scaleY = this.getScaleRate(Math.abs(viewPos.x), 1);
item.setScale(scaleX, scaleY);
let isShow = this.isOnShow(item);
if (isShow) {
let itemIndex = items.indexOf(item);
this.checkCanPlay(itemIndex);
item.getChildByName('shadow').opacity = 0;
this.currentItem = item;
} else {
item.getChildByName('shadow').opacity = 45
}
});
},
getPositionInView(item) {
let worldPos = item.parent.convertToWorldSpaceAR(item.position);
return this.scrollView.node.convertToNodeSpaceAR(worldPos);
},
getScaleRate(posX, rate) {
return -rate * posX / 2000 + 1;
},
isOnShow(item) {
return this.middleItemRect.intersects(item.getBoundingBoxToWorld())
},
供你参考
搞定了 多谢咯
这个事pageview做的吧,你这个应该一次只能翻一页,我以前做过一次,修改了引擎,一次翻多页了可以
mark