Ejemplo n.º 1
0
 /// <summary>
 /// Kosketetaako oliota.
 /// </summary>
 private static bool IsBeingTouched(ScreenView screen, Vector touchOnScreen, GameObject obj)
 {
     if (obj == null || obj.Layer == null || obj.IsDestroyed)
     {
         return(false);
     }
     return(obj.IsInside(Game.Instance.Camera.ScreenToWorld(touchOnScreen, obj.Layer)));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Onko hiiren kursori annetun olion päällä.
 /// </summary>
 private static bool IsCursorOn(ScreenView screen, MouseState state, GameObject obj)
 {
     if (obj == null || obj.Layer == null || obj.IsDestroyed)
     {
         return(false);
     }
     return(obj.IsInside(Game.Instance.Camera.ScreenToWorld(new Vector(state.PosX, state.PosY), obj.Layer)));
 }
Ejemplo n.º 3
0
        private void SetPosition(Vector pos)
        {
#if !WINRT && !WINDOWS_PHONE
            // Not supported on WinRT... only sets xna coords
            Vector screenpos = pos.Transform(screen.GetScreenInverse());
            XnaV2  center    = ScreenView.ToXnaCoords(screenpos, screen.ViewportSize, Vector.Zero);
            XnaMouse.SetPosition((int)center.X, (int)center.Y);
#endif
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Alustaa grafiikat. Suorita vasta kun ikkuna on lopullisessa koossaan.
        /// </summary>
        private void InitGraphics()
        {
            Viewport viewPort = GraphicsDevice.Viewport;

            Screen = new ScreenView(GraphicsDevice);
            Jypeli.Graphics.Initialize();

            Camera         = new Camera();
            SmoothTextures = true;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Piirtää tekstiä ruudulle
        /// </summary>
        /// <param name="text">Teksti</param>
        /// <param name="transformation">Transformaatio</param>
        /// <param name="font">Fontti</param>
        /// <param name="color">Tekstin väri</param>
        public static void DrawText(string text, ref Matrix transformation, Font font, Color color)
        {
            Vector textSize = (Vector)font.XnaFont.MeasureString(text);
            Matrix m        = ScreenView.ToXnaCoords(ref transformation, Game.Screen.Size, textSize);

            SpriteBatch spriteBatch = Graphics.SpriteBatch;

            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.LinearClamp, currentStencilState, RasterizerState.CullCounterClockwise, null, m);
            spriteBatch.DrawString(font.XnaFont, text, Vector2.Zero, color.AsXnaColor());
            spriteBatch.End();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Piirtää tekstiä ruudulle
        /// </summary>
        /// <param name="text">Teksti</param>
        /// <param name="position">Paikka</param>
        /// <param name="font">Fontti</param>
        /// <param name="color">Tekstin väri</param>
        public static void DrawText(string text, Vector position, Font font, Color color)
        {
            Vector2 textSize = font.XnaFont.MeasureString(text);
            Vector2 xnaPos   = ScreenView.ToXnaCoords(position, Game.Screen.Size, (Vector)textSize);

            SpriteBatch spriteBatch = Graphics.SpriteBatch;

            spriteBatch.Begin();
            spriteBatch.DrawString(font.XnaFont, text, xnaPos, color.AsXnaColor());
            spriteBatch.End();
        }
Ejemplo n.º 7
0
 internal Mouse(ScreenView screen, IInputContext input)
 {
     this.screen        = screen;
     this.CurrentState  = default;
     this.internalState = default;
     this.mouse         = input.Mice[0]; // TODO: Mitä tapahtuu jos koneessa on useampi hiiri kiinni?
     mouse.Scroll      += MouseScroll;
     mouse.MouseDown   += MouseDown;
     mouse.MouseUp     += MouseUp;
     mouse.MouseMove   += MouseMove;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Onko hiiren kursori annetun olion päällä.
        /// </summary>
        private static bool IsCursorOn(ScreenView screen, MouseState state, GameObject obj)
        {
#if WINDOWS_PHONE
            return(false);
#else
            if (obj == null || obj.Layer == null || obj.IsDestroyed)
            {
                return(false);
            }
            return(obj.IsInside(Game.Instance.Camera.ScreenToWorld(GetPositionOnScreen(screen, state), obj.Layer)));
#endif
        }
Ejemplo n.º 9
0
        internal TouchPanel(ScreenView screen)
        {
            this.screen = screen;

            try
            {
                this.caps = XnaTouchPanel.GetCapabilities();
            }
            catch (TypeLoadException)
            {
                this.caps = new TouchPanelCapabilities();
            }

            this.touches    = new List <Touch>(caps.MaximumTouchCount);
            this.newTouches = new List <Touch>(caps.MaximumTouchCount);
        }
Ejemplo n.º 10
0
 internal Touch(ScreenView screen, TouchLocation location)
 {
     this.screen    = screen;
     this.Id        = location.Id;
     this._position = this._previousPosition = location.Position;
 }
Ejemplo n.º 11
0
 private static Vector GetPositionOnWorld(ScreenView screen, MouseState state)
 {
     return(Game.Instance.Camera.ScreenToWorld(GetPositionOnScreen(screen, state)));
 }
Ejemplo n.º 12
0
 internal Mouse(ScreenView screen)
 {
     this.screen       = screen;
     this.CurrentState = XnaMouse.GetState();
 }