修复无限滚动问题

This commit is contained in:
ifengzp 2020-04-01 22:11:08 +08:00
parent 22fdbaaa18
commit e07909e403

View File

@ -8,6 +8,12 @@ export default class Infinite_bg_scroll extends cc.Component {
bg2: cc.Node = null; bg2: cc.Node = null;
speed: number = 500; speed: number = 500;
onLoad() {
const viewSize = cc.view.getVisibleSize();
this.bg2.getComponent(cc.Widget).left = viewSize.width
this.bg2.getComponent(cc.Widget).right = -viewSize.width
}
update(dt) { update(dt) {
const temp = dt * this.speed; const temp = dt * this.speed;
if (this.bg2.x - temp <= 0) { if (this.bg2.x - temp <= 0) {