实现 scrollingSprite
This commit is contained in:
@@ -2874,10 +2874,17 @@ var es;
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
ScrollingSpriteRenderer.prototype.update = function () {
|
ScrollingSpriteRenderer.prototype.update = function () {
|
||||||
|
if (!this.sprite)
|
||||||
|
return;
|
||||||
this._scrollX += this.scrollSpeedX * es.Time.deltaTime;
|
this._scrollX += this.scrollSpeedX * es.Time.deltaTime;
|
||||||
this._scrollY += this.scroolSpeedY * es.Time.deltaTime;
|
this._scrollY += this.scroolSpeedY * es.Time.deltaTime;
|
||||||
this._sourceRect.x = this._scrollX;
|
var newRectangle = this.displayObject.scrollRect;
|
||||||
this._sourceRect.y = this._scrollY;
|
if (!this.displayObject.scrollRect) {
|
||||||
|
newRectangle = new egret.Rectangle();
|
||||||
|
}
|
||||||
|
newRectangle.x = this._scrollX;
|
||||||
|
newRectangle.y = this._scrollY;
|
||||||
|
this.displayObject.scrollRect = newRectangle;
|
||||||
};
|
};
|
||||||
return ScrollingSpriteRenderer;
|
return ScrollingSpriteRenderer;
|
||||||
}(es.TiledSpriteRenderer));
|
}(es.TiledSpriteRenderer));
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -19,13 +19,13 @@ module scene {
|
|||||||
bg.addComponent(new es.BoxCollider());
|
bg.addComponent(new es.BoxCollider());
|
||||||
bg.position = new es.Vector2(Math.random() * 200, Math.random() * 200);
|
bg.position = new es.Vector2(Math.random() * 200, Math.random() * 200);
|
||||||
|
|
||||||
for (let i = 0; i < 20; i++) {
|
// for (let i = 0; i < 20; i++) {
|
||||||
let sprite = new es.Sprite(RES.getRes("checkbox_select_disabled_png"));
|
// let sprite = new es.Sprite(RES.getRes("checkbox_select_disabled_png"));
|
||||||
let player2 = this.createEntity("player2");
|
// let player2 = this.createEntity("player2");
|
||||||
player2.addComponent(new es.SpriteRenderer()).setSprite(sprite);
|
// player2.addComponent(new es.SpriteRenderer()).setSprite(sprite);
|
||||||
player2.position = new es.Vector2(Math.random() * 1000, Math.random() * 1000);
|
// player2.position = new es.Vector2(Math.random() * 1000, Math.random() * 1000);
|
||||||
player2.addComponent(new es.BoxCollider());
|
// player2.addComponent(new es.BoxCollider());
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.camera.follow(bg, es.CameraStyle.lockOn);
|
this.camera.follow(bg, es.CameraStyle.lockOn);
|
||||||
|
|
||||||
|
|||||||
@@ -2874,10 +2874,17 @@ var es;
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
ScrollingSpriteRenderer.prototype.update = function () {
|
ScrollingSpriteRenderer.prototype.update = function () {
|
||||||
|
if (!this.sprite)
|
||||||
|
return;
|
||||||
this._scrollX += this.scrollSpeedX * es.Time.deltaTime;
|
this._scrollX += this.scrollSpeedX * es.Time.deltaTime;
|
||||||
this._scrollY += this.scroolSpeedY * es.Time.deltaTime;
|
this._scrollY += this.scroolSpeedY * es.Time.deltaTime;
|
||||||
this._sourceRect.x = this._scrollX;
|
var newRectangle = this.displayObject.scrollRect;
|
||||||
this._sourceRect.y = this._scrollY;
|
if (!this.displayObject.scrollRect) {
|
||||||
|
newRectangle = new egret.Rectangle();
|
||||||
|
}
|
||||||
|
newRectangle.x = this._scrollX;
|
||||||
|
newRectangle.y = this._scrollY;
|
||||||
|
this.displayObject.scrollRect = newRectangle;
|
||||||
};
|
};
|
||||||
return ScrollingSpriteRenderer;
|
return ScrollingSpriteRenderer;
|
||||||
}(es.TiledSpriteRenderer));
|
}(es.TiledSpriteRenderer));
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -29,10 +29,18 @@ module es {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public update() {
|
public update() {
|
||||||
|
if (!this.sprite)
|
||||||
|
return;
|
||||||
|
|
||||||
this._scrollX += this.scrollSpeedX * Time.deltaTime;
|
this._scrollX += this.scrollSpeedX * Time.deltaTime;
|
||||||
this._scrollY += this.scroolSpeedY * Time.deltaTime;
|
this._scrollY += this.scroolSpeedY * Time.deltaTime;
|
||||||
this._sourceRect.x = this._scrollX;
|
let newRectangle: egret.Rectangle = this.displayObject.scrollRect;
|
||||||
this._sourceRect.y = this._scrollY;
|
if (!this.displayObject.scrollRect){
|
||||||
|
newRectangle = new egret.Rectangle();
|
||||||
|
}
|
||||||
|
newRectangle.x = this._scrollX;
|
||||||
|
newRectangle.y = this._scrollY;
|
||||||
|
this.displayObject.scrollRect = newRectangle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user