diff --git a/assets/Scene/Infinite_bg_scroll/Infinite_bg_scroll.ts b/assets/Scene/Infinite_bg_scroll/Infinite_bg_scroll.ts index edf18d6..bffb951 100644 --- a/assets/Scene/Infinite_bg_scroll/Infinite_bg_scroll.ts +++ b/assets/Scene/Infinite_bg_scroll/Infinite_bg_scroll.ts @@ -8,6 +8,12 @@ export default class Infinite_bg_scroll extends cc.Component { bg2: cc.Node = null; 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) { const temp = dt * this.speed; if (this.bg2.x - temp <= 0) {