public override void Mouse(MouseState state, MouseState oldState) { var pos = CCDrawManager.ScreenToWorld(state.X, state.Y); Vector2 position = new Vector2(pos.X, pos.Y); if (state.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released) { for (int i = 0; i < _polygons.Count; ++i) { if (_polygons[i] == null) { continue; } if (_polygons[i].PointInPolygon(ref position) == 1) { _selected = _polygons[i]; break; } } } if (state.LeftButton == ButtonState.Released && oldState.LeftButton == ButtonState.Pressed) { _selected = null; } MouseMove(state, oldState); base.Mouse(state, oldState); }
public override void Mouse(MouseState state, MouseState oldState) { var pos = CCDrawManager.ScreenToWorld(state.X, state.Y); Vector2 position = new Vector2(pos.X, pos.Y); if (state.RightButton == ButtonState.Pressed) { DrawCircleOnMap(position, -1); _terrain.RegenerateTerrain(); DebugView.BeginCustomDraw(); DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Blue * 0.5f); DebugView.EndCustomDraw(); } if (state.LeftButton == ButtonState.Pressed) { DrawCircleOnMap(position, 1); _terrain.RegenerateTerrain(); DebugView.BeginCustomDraw(); DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f); DebugView.EndCustomDraw(); } if (state.MiddleButton == ButtonState.Pressed) { Body circle = BodyFactory.CreateCircle(World, 1, 1); circle.BodyType = BodyType.Dynamic; circle.Position = position; } }
public override void Mouse(MouseState state, MouseState oldState) { var pos = CCDrawManager.ScreenToWorld(state.X, state.Y); _mousePos = new Vector2(pos.X, pos.Y); if (state.LeftButton == ButtonState.Pressed) { Explode(); } }
public virtual void Mouse(MouseState state, MouseState oldState) { var p = CCDrawManager.ScreenToWorld(state.X, state.Y); Vector2 position = new Vector2(p.X, p.Y); if (state.LeftButton == ButtonState.Released && oldState.LeftButton == ButtonState.Pressed) { MouseUp(); } else if (state.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released) { MouseDown(position); } MouseMove(position); }
public override void Mouse(MouseState state, MouseState oldState) { //base.Mouse(state, oldState); var pos = CCDrawManager.ScreenToWorld(state.X, state.Y); Vector2 MouseWorld = new Vector2(pos.X, pos.Y); //SimpleWind.Position = MouseWorld; _simpleWind.Direction = MouseWorld - _simpleWind.Position; _simpleWind.Strength = _strength; if (state.LeftButton == ButtonState.Pressed && oldState.LeftButton == ButtonState.Released) { _simpleWind.Position = MouseWorld; _simpleWind.Direction = MouseWorld + new Vector2(0, 1); Microsoft.Xna.Framework.Input.Mouse.SetPosition(state.X, state.Y + 10); } }