/// <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))); }
/// <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))); }
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 }
/// <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; }
/// <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(); }
/// <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(); }
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; }
/// <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 }
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); }
internal Touch(ScreenView screen, TouchLocation location) { this.screen = screen; this.Id = location.Id; this._position = this._previousPosition = location.Position; }
private static Vector GetPositionOnWorld(ScreenView screen, MouseState state) { return(Game.Instance.Camera.ScreenToWorld(GetPositionOnScreen(screen, state))); }
internal Mouse(ScreenView screen) { this.screen = screen; this.CurrentState = XnaMouse.GetState(); }