virtual public void Draw(FairyBatch batch) { ValidateMatrix(false); if (_paintingMode != 0) { if (graphics != null && paintingGraphics.texture != null) { batch.PushRenderTarget(paintingGraphics.texture, Vector2.Transform(Vector2.Zero, _localToWorldMatrix) + new Vector2(_paintingMargin.left, _paintingMargin.top)); batch.Draw(graphics, _alpha, _grayed, BlendMode.Normal, ref _localToWorldMatrix, null); batch.PopRenderTarget(); } if (!(this is Container)) { batch.Draw(paintingGraphics, 1, false, _blendMode, ref _localToWorldMatrix, _filter); } } else { if (graphics != null) { batch.Draw(graphics, _alpha, _grayed, _blendMode, ref _localToWorldMatrix, _filter); } } }
/// <summary> /// /// </summary> public Stage(Game game, IInputHandler handler) { _inst = this; _wic = handler; Stage.game = game; if (handler == null) { game.Window.TextInput += WindowOnTextInput; } soundVolume = 1; _batch = new FairyBatch(); _soundEnabled = true; _touchInfo = new TouchInfo(); _touchInfo.touchId = 0; _lastKeyDownTime = new Dictionary <Keys, float>(); _rollOutChain = new List <DisplayObject>(); _rollOverChain = new List <DisplayObject>(); _focusRemovedDelegate = OnFocusRemoved; }
/// <summary> /// /// </summary> public Stage(Game game) { _inst = this; Stage.game = game; #if Windows handler = new IMEHandler(game); handler.onResultReceived += Handler_onResultReceived; #elif DesktopGL game.Window.TextInput += WindowOnTextInput; #endif soundVolume = 1; _batch = new FairyBatch(); _soundEnabled = true; _touchInfo = new TouchInfo(); _touchInfo.touchId = 0; _lastKeyDownTime = new Dictionary <Keys, float>(); _rollOutChain = new List <DisplayObject>(); _rollOverChain = new List <DisplayObject>(); _focusRemovedDelegate = OnFocusRemoved; }
override public void Draw(FairyBatch batch) { base.Draw(batch); if (_paintingMode != 0 && paintingGraphics.texture != null) { batch.PushRenderTarget(paintingGraphics.texture, Vector2.Transform(Vector2.Zero, _localToWorldMatrix) + new Vector2(_paintingMargin.left, _paintingMargin.top)); } if (_clipRect != null) { //在这里可以直接使用 _localToWorldMatrix, 因为已经更新 Rectangle clipRect = (Rectangle)_clipRect; Matrix mat = Matrix.Identity; ToolSet.TransformRect(ref clipRect, ref _localToWorldMatrix, ref mat); batch.EnterClipping(clipRect); } float savedAlpha = batch.alpha; batch.alpha *= this.alpha; bool savedGrayed = batch.grayed; batch.grayed = batch.grayed || this.grayed; int cnt = _children.Count; for (int i = 0; i < cnt; i++) { DisplayObject child = _children[i]; if (child.visible) { child.Draw(batch); } } if (_clipRect != null) { batch.LeaveClipping(); } if (_paintingMode != 0 && paintingGraphics.texture != null) { batch.PopRenderTarget(); batch.Draw(paintingGraphics, 1, false, _blendMode, ref _localToWorldMatrix, _filter); } batch.alpha = savedAlpha; batch.grayed = savedGrayed; }
public void Apply(FairyBatch batch) { if (_pass == null) { Effect effect = batch.defaultEffect; _pass = effect.Techniques["ColorFilter"].Passes[0]; _params = new EffectParameter[] { effect.Parameters["ColorMatrix0"], effect.Parameters["ColorMatrix1"], effect.Parameters["ColorMatrix2"], effect.Parameters["ColorMatrix3"], effect.Parameters["ColorMatrix4"] }; } _params[0].SetValue(new Vector4(_matrix[0], _matrix[1], _matrix[2], _matrix[3])); _params[1].SetValue(new Vector4(_matrix[5], _matrix[6], _matrix[7], _matrix[8])); _params[2].SetValue(new Vector4(_matrix[10], _matrix[11], _matrix[12], _matrix[13])); _params[3].SetValue(new Vector4(_matrix[15], _matrix[16], _matrix[17], _matrix[18])); _params[4].SetValue(new Vector4(_matrix[4], _matrix[9], _matrix[14], _matrix[19])); _pass.Apply(); }