实现 scrollingSprite

This commit is contained in:
YHH
2020-08-07 09:21:55 +08:00
parent c611e31f7e
commit 359d7ae223
6 changed files with 37 additions and 15 deletions

View File

@@ -29,10 +29,18 @@ module es {
}
public update() {
if (!this.sprite)
return;
this._scrollX += this.scrollSpeedX * Time.deltaTime;
this._scrollY += this.scroolSpeedY * Time.deltaTime;
this._sourceRect.x = this._scrollX;
this._sourceRect.y = this._scrollY;
let newRectangle: egret.Rectangle = this.displayObject.scrollRect;
if (!this.displayObject.scrollRect){
newRectangle = new egret.Rectangle();
}
newRectangle.x = this._scrollX;
newRectangle.y = this._scrollY;
this.displayObject.scrollRect = newRectangle;
}
}
}