public void Center(Button button) { if (editorCamera != null && ParentScene.SelectedGameObjects.Count > 0) { editorCamera.Position.set(Basic2DObject.GetAveragePosition(ParentScene.SelectedGameObjects)); } }
public void DrawControls() { if (ParentScene.DrawCamera != null && ParentScene.SelectedGameObjects.Count > 0) { Vector2 Avg = Basic2DObject.GetAveragePosition(ParentScene.SelectedGameObjects); Texture2D tex = controlMode == ControlMode.Move ? MoveControl : controlMode == ControlMode.Rotate ? RotateControl : ScaleControl; Render.DrawSprite(tex, Avg, new Vector2(128) / ParentScene.DrawCamera.getZoom(), 0); } base.Draw(); }
public void RotateSelected(float Force, Vector2 Origin) { foreach (GameObject g in SelectedGameObjects) { if (g.GetType().IsSubclassOf(typeof(Basic2DObject))) { Basic2DObject b = (Basic2DObject)g; b.ApplyRotate(Force, Basic2DObject.GetAveragePosition(SelectedGameObjects), false); } } }
public override void Update(GameTime gameTime, Window Updater) { if (CurrentMode != LockMode.None) { if (MouseManager.mouseState.LeftButton == ButtonState.Pressed) { Vector2 AMT = MouseManager.MousePosition - MouseLockPosition; switch (controlMode) { case ControlMode.Move: ParentScene.MoveSelected(AMT); break; case ControlMode.Rotate: ParentScene.RotateSelected(AMT.X + AMT.Y, Basic2DObject.GetAveragePosition(ParentScene.SelectedGameObjects)); break; case ControlMode.Scale: ParentScene.ScaleSelected(Vector2.One + AMT / 300, Basic2DObject.GetAveragePosition(ParentScene.SelectedGameObjects)); break; } } else { if (controlMode == ControlMode.Move && ParentScene.UseGrid.get()) { ParentScene.SnapSelected(); } Game1.self.IsMouseVisible = true; CurrentMode = LockMode.None; } Mouse.SetPosition((int)MouseLockPosition.X, (int)MouseLockPosition.Y); } base.Update(gameTime, Updater); }