| 28 | private _inputProcessor: InputProcessor; |
| 29 | |
| 30 | constructor() { |
| 31 | super(); |
| 32 | |
| 33 | this._inputProcessor = new InputProcessor(this); |
| 34 | |
| 35 | // Set this as stage root so children receive addedToStage events |
| 36 | // 将自己设置为舞台根,这样子对象才能收到 addedToStage 事件 |
| 37 | if (this.displayObject) { |
| 38 | this.displayObject.setStage(this.displayObject); |
| 39 | } |
| 40 | |
| 41 | // Bind to stage events |
| 42 | const stage = Stage.inst; |
| 43 | stage.on('mousedown', this.onStageMouseDown, this); |
| 44 | stage.on('mouseup', this.onStageMouseUp, this); |
| 45 | stage.on('mousemove', this.onStageMouseMove, this); |
| 46 | stage.on('wheel', this.onStageWheel, this); |
| 47 | stage.on('resize', this.onStageResize, this); |
| 48 | |
| 49 | // Set initial size |
| 50 | this.setSize(stage.designWidth, stage.designHeight); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get singleton instance |