コード例 #1
0
ファイル: TouchPanel.cs プロジェクト: Jypeli-JYU/Jypeli
 /// <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)));
 }
コード例 #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)));
 }
コード例 #3
0
ファイル: Mouse.cs プロジェクト: Anttifer/Jypeli
        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
        }
コード例 #4
0
ファイル: Graphics.cs プロジェクト: Anttifer/Jypeli
        /// <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;
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #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;
 }
コード例 #8
0
ファイル: Mouse.cs プロジェクト: Anttifer/Jypeli
        /// <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
        }
コード例 #9
0
ファイル: TouchPanel.cs プロジェクト: Anttifer/Jypeli
        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);
        }
コード例 #10
0
 internal Touch(ScreenView screen, TouchLocation location)
 {
     this.screen    = screen;
     this.Id        = location.Id;
     this._position = this._previousPosition = location.Position;
 }
コード例 #11
0
ファイル: Mouse.cs プロジェクト: Anttifer/Jypeli
 private static Vector GetPositionOnWorld(ScreenView screen, MouseState state)
 {
     return(Game.Instance.Camera.ScreenToWorld(GetPositionOnScreen(screen, state)));
 }
コード例 #12
0
ファイル: Mouse.cs プロジェクト: Anttifer/Jypeli
 internal Mouse(ScreenView screen)
 {
     this.screen       = screen;
     this.CurrentState = XnaMouse.GetState();
 }