全部回复(1)

  • rbbb 楼主 1 楼

    补充一下代码: import { _decorator, Component, Node } from 'cc'; const { ccclass, property } = _decorator; @ccclass('BG') export class BG extends Component { @property(Node) BG01: Node = null; @property(Node) BG02: Node = null; @property speed: number = 100; start() { } update(deltaTime: number) { let position1 = this.BG01.position; this.BG01.setPosition(position1.x, position1.y - this.speed * deltaTime, position1.z); let position2 = this.BG02.position; this.BG02.setPosition(position2.x, position2.y - this.speed * deltaTime, position2.z); let p1 = this.BG01.position; let p2 = this.BG02.position; if (this.BG01.position.y <= -852) { this.BG01.setPosition(p2.x, p2.y + 852, p2.z); } if (this.BG02.position.y <= -852) { this.BG02.setPosition(p1.x, p1.y + 852, p1.z); } } }

发表回复

登录后可以回复