Files
esengine/source/src/ECS/Components/Mesh.ts

32 lines
704 B
TypeScript
Raw Normal View History

2020-07-01 16:55:10 +08:00
///<reference path="./RenderableComponent.ts" />
class Mesh extends RenderableComponent {
private _mesh: egret.Mesh;
2020-06-10 08:57:17 +08:00
2020-07-01 16:55:10 +08:00
constructor(){
super();
2020-06-10 08:57:17 +08:00
2020-07-01 16:55:10 +08:00
this._mesh = new egret.Mesh();
2020-06-10 08:57:17 +08:00
}
2020-07-01 16:55:10 +08:00
public setTexture(texture: egret.Texture): Mesh{
this._mesh.texture = texture;
2020-06-10 08:57:17 +08:00
return this;
}
2020-07-01 16:55:10 +08:00
public onAddedToEntity(){
this.addChild(this._mesh);
}
2020-06-10 08:57:17 +08:00
2020-07-01 16:55:10 +08:00
public onRemovedFromEntity(){
this.removeChild(this._mesh);
2020-06-10 08:57:17 +08:00
}
2020-07-01 16:55:10 +08:00
public render(camera: Camera){
this.x = this.entity.position.x - camera.position.x + camera.origin.x;
this.y = this.entity.position.y - camera.position.y + camera.origin.y;
}
2020-06-10 08:57:17 +08:00
2020-07-01 16:55:10 +08:00
public reset() {
2020-06-10 08:57:17 +08:00
}
}