修复scrollingSprite无法向左移动问题

This commit is contained in:
YHH
2020-08-08 14:11:25 +08:00
parent 7d0bcbcb32
commit 3492bbdf5e
6 changed files with 15 additions and 13 deletions

View File

@@ -2949,8 +2949,8 @@ var es;
this._scrollY += this.scroolSpeedY * es.Time.deltaTime;
this._sourceRect.x = this._scrollX;
this._sourceRect.y = this._scrollY;
this._sourceRect.width = this._scrollWidth + this._scrollX;
this._sourceRect.height = this._scrollHeight + this._scrollY;
this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX);
this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY);
};
return ScrollingSpriteRenderer;
}(es.TiledSpriteRenderer));

File diff suppressed because one or more lines are too long

View File

@@ -14,8 +14,10 @@ module scene {
this.createEntityAsync("bg").then(bg => {
bg.addComponent(new component.PlayerController());
bg.addComponent(new es.Mover());
bg.addComponent(new es.SpriteRenderer(sprite));
bg.addComponent(new es.BoxCollider());
let spriteRenderer = bg.addComponent(new es.ScrollingSpriteRenderer(sprite));
spriteRenderer.setRenderLayer(4);
spriteRenderer.scrollX = -30;
// bg.addComponent(new es.BoxCollider());
this.camera.follow(bg, es.CameraStyle.lockOn);
});
@@ -25,9 +27,9 @@ module scene {
for (let i = 0; i < 20; i++) {
let sprite = new es.Sprite(RES.getRes("checkbox_select_disabled_png"));
let player2 = this.createEntity("player2");
player2.addComponent(new es.SpriteRenderer()).setSprite(sprite);
player2.position = new es.Vector2(Math.random() * 1000, Math.random() * 1000);
player2.addComponent(new es.BoxCollider());
player2.addComponent(new es.SpriteRenderer()).setSprite(sprite).setRenderLayer(i);
player2.position = new es.Vector2(30 * i, 30 * i);
// player2.addComponent(new es.BoxCollider());
}

View File

@@ -2949,8 +2949,8 @@ var es;
this._scrollY += this.scroolSpeedY * es.Time.deltaTime;
this._sourceRect.x = this._scrollX;
this._sourceRect.y = this._scrollY;
this._sourceRect.width = this._scrollWidth + this._scrollX;
this._sourceRect.height = this._scrollHeight + this._scrollY;
this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX);
this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY);
};
return ScrollingSpriteRenderer;
}(es.TiledSpriteRenderer));

File diff suppressed because one or more lines are too long

View File

@@ -60,8 +60,8 @@ module es {
this._sourceRect.x = this._scrollX;
this._sourceRect.y = this._scrollY;
this._sourceRect.width = this._scrollWidth + this._scrollX;
this._sourceRect.height = this._scrollHeight + this._scrollY;
this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX);
this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY);
}
}
}