Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Just visuals
- //None collider or selectable behaviour
- class FolderSelection : Entity
- {
- float orX; //Origin of the rectangle in X
- float orY; //Origin of the rectangle in Y
- int width = 0; //width of the rectangle
- int height = 0; //height of the rectangle
- Color rectColor; //Color to fill
- Color outColor; //outline color
- public FolderSelection()
- {
- }
- public override void Update()
- {
- base.Update();
- //Define origin according to mouse position when click
- if (Input.MouseButtonPressed(0))
- {
- orX = Input.MouseX;
- orY = Input.MouseY;
- width = 0;
- height = 0;
- }
- //Define width and height
- if (Input.MouseButtonDown(0))
- {
- width = (int)(Input.MouseX - orX);
- height = (int)(Input.MouseY - orY);
- }
- //Color and alpha to fill the rectangle
- rectColor = Color.Blue;
- rectColor.A = 0.1f;
- //Color and alpha to fill the outline
- outColor = Color.Blue;
- outColor.A = 0.2f;
- }
- public override void Render()
- {
- base.Render();
- //Render the rectangle when mouse button is down
- if (Input.MouseButtonDown(0))
- Draw.Rectangle(orX, orY, width, height, rectColor, outColor, 2);
- }
- }
Add Comment
Please, Sign In to add comment