Commit 65f35e4c authored by rockyl's avatar rockyl

rebuild-lifecycle

parent c226d8b1
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
*/ */
import {Entity, createVector2D, Vector2D, math, getRenderContext} from "scilla"; import {Entity, createVector2D, Vector2D, math, } from "scilla";
import Transform from "../base/Transform"; import Transform from "../base/Transform";
import ScillaComponent from "../base/ScillaComponent"; import ScillaComponent from "../base/ScillaComponent";
...@@ -38,7 +38,7 @@ export default class CameraController extends ScillaComponent { ...@@ -38,7 +38,7 @@ export default class CameraController extends ScillaComponent {
get stageSize(){ get stageSize(){
if(!this._stageSize){ if(!this._stageSize){
this._stageSize = getRenderContext().getStageSize(); this._stageSize = this.entity.root.engine.renderContext.stageSize;
} }
return this._stageSize; return this._stageSize;
...@@ -77,6 +77,6 @@ export default class CameraController extends ScillaComponent { ...@@ -77,6 +77,6 @@ export default class CameraController extends ScillaComponent {
this.followPosition.setXY(width / 2, height / 2).subtract(this.targetPosition); this.followPosition.setXY(width / 2, height / 2).subtract(this.targetPosition);
position.copyFrom(math.lerpObj(position, this.followPosition, 0.1, Vector2D, ['x', 'y'])); position.copyFrom(math.lerpObj(position, this.followPosition, 0.1, ['x', 'y']));
} }
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* *
*/ */
import {getRenderContext, } from "scilla";
import ScillaComponent from "../base/ScillaComponent"; import ScillaComponent from "../base/ScillaComponent";
/** /**
...@@ -18,7 +17,7 @@ export default class FullStageSize extends ScillaComponent { ...@@ -18,7 +17,7 @@ export default class FullStageSize extends ScillaComponent {
get stageSize(){ get stageSize(){
if(!this._stageSize){ if(!this._stageSize){
this._stageSize = getRenderContext().getStageSize(); this._stageSize = this.entity.root.engine.renderContext.stageSize;
} }
return this._stageSize; return this._stageSize;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by rockyl on 2018/11/6. * Created by rockyl on 2018/11/6.
*/ */
import {createCanvas, getRenderContext, Bounds, Vector2D, math, decorators, EngineConfig} from "scilla"; import {createCanvas, Bounds, Vector2D, math, decorators, EngineConfig} from "scilla";
import ScillaComponent from "../base/ScillaComponent"; import ScillaComponent from "../base/ScillaComponent";
const {dirtyFieldTrigger} = decorators; const {dirtyFieldTrigger} = decorators;
...@@ -52,7 +52,7 @@ export default class Renderer extends ScillaComponent { ...@@ -52,7 +52,7 @@ export default class Renderer extends ScillaComponent {
protected _anchorOffset: Vector2D = new Vector2D(); protected _anchorOffset: Vector2D = new Vector2D();
//渲染上下文 //渲染上下文
protected _context = getRenderContext().getContext(); protected _context;
/** /**
* 扩展尺寸 * 扩展尺寸
...@@ -106,6 +106,7 @@ export default class Renderer extends ScillaComponent { ...@@ -106,6 +106,7 @@ export default class Renderer extends ScillaComponent {
onAwake() { onAwake() {
super.onAwake(); super.onAwake();
this._context = this.entity.root.engine.renderContext.context;
if (!this.transform) { if (!this.transform) {
console.warn('renderer need a transform component'); console.warn('renderer need a transform component');
} }
...@@ -205,6 +206,9 @@ export default class Renderer extends ScillaComponent { ...@@ -205,6 +206,9 @@ export default class Renderer extends ScillaComponent {
const {a, b, c, d, tx, ty} = transform.getMatrix(true, false, true); const {a, b, c, d, tx, ty} = transform.getMatrix(true, false, true);
const offX = ax * a + ay * c; const offX = ax * a + ay * c;
const offY = ax * b + ay * d; const offY = ax * b + ay * d;
if(!this._context){
console.log();
}
this._context.setTransform(a, b, c, d, tx - offX, ty - offY); this._context.setTransform(a, b, c, d, tx - offX, ty - offY);
} else { } else {
this._context.setTransform(1, 0, 0, 1, -ax, -ay); this._context.setTransform(1, 0, 0, 1, -ax, -ay);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment