From e07909e403778587f0856a0f5e3381a933732bc4 Mon Sep 17 00:00:00 2001 From: ifengzp Date: Wed, 1 Apr 2020 22:11:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E9=99=90=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scene/Infinite_bg_scroll/Infinite_bg_scroll.ts | 6 ++++++ 1 file changed, 6 insertions(+) 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) {