新增prototypespriteRenderer
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
module es {
|
||||
export class PrototypeSpriteRenderer extends SpriteRenderer {
|
||||
public get width(): number {
|
||||
return this._width;
|
||||
}
|
||||
|
||||
public get height(): number {
|
||||
return this._height;
|
||||
}
|
||||
|
||||
public get bounds(): Rectangle {
|
||||
if (this._areBoundsDirty){
|
||||
this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale,
|
||||
this.entity.transform.rotation, this._width, this._height);
|
||||
this._areBoundsDirty = false;
|
||||
}
|
||||
|
||||
return this._bounds;
|
||||
}
|
||||
|
||||
public skewTopX: number = 0;
|
||||
public skewBottomX: number = 0;
|
||||
public skewLeftY: number = 0;
|
||||
public skewRightY: number = 0;
|
||||
|
||||
public _width: number = 0;
|
||||
public _height: number = 0;
|
||||
|
||||
constructor(width: number = 50, height: number = 50){
|
||||
super(Graphics.Instance.pixelTexture);
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
}
|
||||
|
||||
public setWidth(width: number): PrototypeSpriteRenderer {
|
||||
this._width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public setHeight(height: number): PrototypeSpriteRenderer {
|
||||
this._height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public setSkew(skewTopX: number, skewBottomX: number, skewLeftY: number, skewRightY: number): PrototypeSpriteRenderer{
|
||||
this.skewTopX = skewTopX;
|
||||
this.skewBottomX = skewBottomX;
|
||||
this.skewLeftY = skewLeftY;
|
||||
this.skewRightY = skewRightY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public onAddedToEntity() {
|
||||
this.originNormalized = Vector2Ext.halfVector();
|
||||
}
|
||||
|
||||
public render(camera: es.Camera) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,6 +228,7 @@ module es {
|
||||
}
|
||||
|
||||
protected initialize() {
|
||||
Graphics.Instance = new Graphics();
|
||||
}
|
||||
|
||||
protected async update() {
|
||||
|
||||
20
source/src/Graphics/Graphics.ts
Normal file
20
source/src/Graphics/Graphics.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
module es {
|
||||
export class Graphics {
|
||||
public static Instance: Graphics;
|
||||
/**
|
||||
* 用于绘制矩形、线条、圆等的精灵。
|
||||
* 将在启动时生成,但你可以用你的图集中的精灵代替,以减少纹理交换。应该是一个1x1的白色像素
|
||||
*/
|
||||
public pixelTexture: Sprite;
|
||||
|
||||
constructor(){
|
||||
let arrayBuffer = new ArrayBuffer(1);
|
||||
arrayBuffer[0] = 0xffffff;
|
||||
egret.BitmapData.create("arraybuffer", arrayBuffer, bitmapData => {
|
||||
let tex = new egret.Texture();
|
||||
tex.bitmapData = bitmapData;
|
||||
this.pixelTexture = new Sprite(tex);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@ module es {
|
||||
return this.cross(Vector2.subtract(center, a), Vector2.subtract(c, center)) < 0;
|
||||
}
|
||||
|
||||
public static halfVector(): Vector2 {
|
||||
return new Vector2(0.5, 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算二维伪叉乘点(Perp(u), v)
|
||||
* @param u
|
||||
|
||||
Reference in New Issue
Block a user