public void DrawButton(VirtualGamePadButtonSkin buttonSkin, TouchMap touchMap, float value, float elapsedTime) { if (buttonSkin.SensibleVisibility || touchMap.Id != -1) { buttonSkin.Opacity = buttonSkin.MaxOpacity; } else { buttonSkin.Opacity -= elapsedTime; if (buttonSkin.Opacity < buttonSkin.MinOpacity) { buttonSkin.Opacity = buttonSkin.MinOpacity; } } if (value > 0) { if (buttonSkin.PressedTexture != null && touchMap.TouchArea != Rectangle.Empty) { _virtualGamePadRenderer.Draw( buttonSkin.PressedTexture, touchMap.TouchArea, Color.White * buttonSkin.Opacity); } } else { if (buttonSkin.NormalTexture != null && touchMap.TouchArea != Rectangle.Empty) { _virtualGamePadRenderer.Draw( buttonSkin.NormalTexture, touchMap.TouchArea, Color.White * buttonSkin.Opacity); } } }
public void DrawButton(VirtualGamePadButtonSkin buttonSkin, TouchMap touchMap, float value, float elapsedTime) { if (buttonSkin.SensibleVisibility || touchMap.Id != -1) { buttonSkin.Opacity = buttonSkin.MaxOpacity; } else { buttonSkin.Opacity -= elapsedTime; if (buttonSkin.Opacity < buttonSkin.MinOpacity) buttonSkin.Opacity = buttonSkin.MinOpacity; } if (value > 0) { if (buttonSkin.PressedTexture != null && touchMap.TouchArea != Rectangle.Empty) { _virtualGamePadRenderer.Draw( buttonSkin.PressedTexture, touchMap.TouchArea, Color.White * buttonSkin.Opacity); } } else { if (buttonSkin.NormalTexture != null && touchMap.TouchArea != Rectangle.Empty) { _virtualGamePadRenderer.Draw( buttonSkin.NormalTexture, touchMap.TouchArea, Color.White * buttonSkin.Opacity); } } }
private void DrawStick(VirtualGamePadStickSkin stickSkin, TouchMap touchMap, float elapsedTime) { if (stickSkin.AreaTexture == null || touchMap.TouchArea == Rectangle.Empty) return; var areaTexture = stickSkin.AreaTexture; Vector2 areaPosition, thumbPosition = Vector2.Zero; if(touchMap.Static) { areaPosition = new Vector2(touchMap.TouchArea.X + touchMap.TouchArea.Width/2f, touchMap.TouchArea.Y + touchMap.TouchArea.Height/2f); } else { areaPosition = touchMap.CenterPosition - new Vector2(areaTexture.Width/2f, areaTexture.Height/2f); } if(stickSkin.ThumbStickTexture != null) { if (touchMap.Id != -1) { var direction = (touchMap.CenterPosition - touchMap.CurrentPosition) / stickSkin.MaxThumbStickDistance; if(direction.LengthSquared() > 1f) direction.Normalize(); thumbPosition = touchMap.CenterPosition - (direction * stickSkin.MaxThumbStickDistance) - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f); } else { thumbPosition = touchMap.CenterPosition - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f); } } if (stickSkin.SensibleVisibility || touchMap.Id != -1) { stickSkin.Opacity = stickSkin.MaxOpacity; } else { stickSkin.Opacity -= elapsedTime; if (stickSkin.Opacity < stickSkin.MinOpacity) stickSkin.Opacity = stickSkin.MinOpacity; } _virtualGamePadRenderer.Draw( areaTexture, areaPosition, Color.White * stickSkin.Opacity); if (stickSkin.ThumbStickTexture != null) { var thumbStickTexture = stickSkin.ThumbStickTexture; _virtualGamePadRenderer.Draw( thumbStickTexture, thumbPosition, Color.White * stickSkin.Opacity); } }
private void DrawStick(VirtualGamePadStickSkin stickSkin, TouchMap touchMap, float elapsedTime) { if (stickSkin.AreaTexture == null || touchMap.TouchArea == Rectangle.Empty) { return; } var areaTexture = stickSkin.AreaTexture; Vector2 areaPosition, thumbPosition = Vector2.Zero; if (touchMap.Static) { areaPosition = new Vector2(touchMap.TouchArea.X + touchMap.TouchArea.Width / 2f, touchMap.TouchArea.Y + touchMap.TouchArea.Height / 2f); } else { areaPosition = touchMap.CenterPosition - new Vector2(areaTexture.Width / 2f, areaTexture.Height / 2f); } if (stickSkin.ThumbStickTexture != null) { if (touchMap.Id != -1) { var direction = (touchMap.CenterPosition - touchMap.CurrentPosition) / stickSkin.MaxThumbStickDistance; if (direction.LengthSquared() > 1f) { direction.Normalize(); } thumbPosition = touchMap.CenterPosition - (direction * stickSkin.MaxThumbStickDistance) - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f); } else { thumbPosition = touchMap.CenterPosition - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f); } } if (stickSkin.SensibleVisibility || touchMap.Id != -1) { stickSkin.Opacity = stickSkin.MaxOpacity; } else { stickSkin.Opacity -= elapsedTime; if (stickSkin.Opacity < stickSkin.MinOpacity) { stickSkin.Opacity = stickSkin.MinOpacity; } } _virtualGamePadRenderer.Draw( areaTexture, areaPosition, Color.White * stickSkin.Opacity); if (stickSkin.ThumbStickTexture != null) { var thumbStickTexture = stickSkin.ThumbStickTexture; _virtualGamePadRenderer.Draw( thumbStickTexture, thumbPosition, Color.White * stickSkin.Opacity); } }