Beispiel #1
0
        protected internal virtual void ViewportChanged(Scale scale, int viewWidth, int viewHeight)
        {
            Display d = game.Display();

            LSystem.viewSize.SetSize((int)(viewWidth / LSystem.GetScaleWidth()), (int)(viewHeight / LSystem.GetScaleHeight()));
            if (viewMatrix != null)
            {
                LSystem.viewSize.GetMatrix().Mul(viewMatrix);
            }
            this.scale            = scale;
            this.viewPixelWidth   = viewWidth;
            this.viewPixelHeight  = viewHeight;
            this.viewSizeM.width  = game.setting.Scaling() ? LSystem.InvXScaled(viewPixelWidth) : scale.InvScaled(viewPixelWidth);
            this.viewSizeM.height = game.setting.Scaling() ? LSystem.InvXScaled(viewPixelHeight) : scale.InvScaled(viewPixelHeight);
            if (d != null)
            {
                d.Resize(LSystem.viewSize.GetWidth(), LSystem.viewSize.GetHeight());
            }
        }
Beispiel #2
0
        public Vector2f ConvertXY(float x, float y)
        {
            float newX = ((x - GetX()) / (LSystem.GetScaleWidth()));
            float newY = ((y - GetY()) / (LSystem.GetScaleHeight()));

            if (isInstance && _currentScreen.IsTxUpdate())
            {
                float oldW = GetWidth();
                float oldH = GetHeight();
                float newW = GetWidth() * GetScaleX();
                float newH = GetHeight() * GetScaleY();
                float offX = oldW / 2f - newW / 2f;
                float offY = oldH / 2f - newH / 2f;
                float nx   = (newX - offX);
                float ny   = (newY - offY);
                int   r    = (int)GetRotation();
                switch (r)
                {
                case -90:
                    offX = oldH / 2f - newW / 2f;
                    offY = oldW / 2f - newH / 2f;
                    nx   = (newX - offY);
                    ny   = (newY - offX);
                    _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY()).RotateSelf(-90);
                    _tmpLocaltion.Set(-(_tmpLocaltion.x - GetWidth()), MathUtils.Abs(_tmpLocaltion.y));
                    break;

                case 0:
                case 360:
                    _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY());
                    break;

                case 90:
                    offX = oldH / 2f - newW / 2f;
                    offY = oldW / 2f - newH / 2f;
                    nx   = (newX - offY);
                    ny   = (newY - offX);
                    _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY()).RotateSelf(90);
                    _tmpLocaltion.Set(-_tmpLocaltion.x, MathUtils.Abs(_tmpLocaltion.y - GetHeight()));
                    break;

                case -180:
                case 180:
                    _tmpLocaltion.Set(nx / GetScaleX(), ny / GetScaleY()).RotateSelf(GetRotation()).AddSelf(GetWidth(),
                                                                                                            GetHeight());
                    break;

                default:     // 原则上不处理非水平角度的触点
                    _tmpLocaltion.Set(newX, newY);
                    break;
                }
            }
            else
            {
                _tmpLocaltion.Set(newX, newY);
            }
            if (IsFlipX() || IsFlipY())
            {
                HelperUtils.Local2Global(IsFlipX(), IsFlipY(), GetWidth() / 2, GetHeight() / 2, _tmpLocaltion.x,
                                         _tmpLocaltion.y, _tmpLocaltion);
                return(_tmpLocaltion);
            }
            return(_tmpLocaltion);
        }
Beispiel #3
0
 public override float Xscale()
 {
     return(_graphics.game.setting.Scaling() ? LSystem.GetScaleWidth() : _graphics.scale.factor);
 }
Beispiel #4
0
 public static float InvYScaled(float length)
 {
     return(length / LSystem.GetScaleWidth());
 }