实现 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

@@ -2874,10 +2874,17 @@ var es;
configurable: true
});
ScrollingSpriteRenderer.prototype.update = function () {
if (!this.sprite)
return;
this._scrollX += this.scrollSpeedX * es.Time.deltaTime;
this._scrollY += this.scroolSpeedY * es.Time.deltaTime;
this._sourceRect.x = this._scrollX;
this._sourceRect.y = this._scrollY;
var newRectangle = this.displayObject.scrollRect;
if (!this.displayObject.scrollRect) {
newRectangle = new egret.Rectangle();
}
newRectangle.x = this._scrollX;
newRectangle.y = this._scrollY;
this.displayObject.scrollRect = newRectangle;
};
return ScrollingSpriteRenderer;
}(es.TiledSpriteRenderer));