弄2个背景。代码如下。
cc.Class({ extends: cc.Component, properties: { bg1:cc.Node, bg2:cc.Node }, onLoad() { cc.log("wx:xiaomao0055"); cc.log("qq:14496453"); this.bg1.y=0; this.bg2.y = this.bg1.y+this.bg1.height; }, start() { }, update (dt) { this.bg1.y = this.bg1.y-10; this.bg2.y = this.bg2.y-10; if(this.bg1.y<= -this.bg1.height){ this.bg1.y=this.bg2.y+this.bg1.height; } if(this.bg2.y<= -this.bg1.height){ this.bg2.y=this.bg1.y+this.bg1.height; } console.log(this.bg1.y) }, });
站长微信:xiaomao0055
站长QQ:14496453