nordi Posted March 22, 2014 Share Posted March 22, 2014 (edited) Hey So i would like to draw a rectangle at the bottom of the screen, (height: 25, and width: 100%). Now my question, is how do i know which value to set for the X and Y, so the rectangle is at the bottom of the screen ? Thanks. Edited August 16, 2014 by nordi Link to comment Share on other sites More sharing options...
nordi Posted March 22, 2014 Author Share Posted March 22, 2014 I managed to find: Game.Resolution.Width for the Width, but still no clue for the X and Y ... Link to comment Share on other sites More sharing options...
julionib Posted March 22, 2014 Share Posted March 22, 2014 if im not wrong X must be half screen width, Y must be the screen height - half rectangle height the X and Y are the center of the rectangle Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted March 22, 2014 Share Posted March 22, 2014 x and y is for the position on screen, u should calculate x and y, width and height of the rectangle from Game.Resolution in order to position and size the same relative to different resolutions. the range of x and y is... (0, 0) is top left of the screen and (Resolution Width, Resolution Height) is bottom right corner of screen Link to comment Share on other sites More sharing options...
nordi Posted March 23, 2014 Author Share Posted March 23, 2014 (edited) x and y is for the position on screen, u should calculate x and y, width and height of the rectangle from Game.Resolution in order to position and size the same relative to different resolutions. the range of x and y is... (0, 0) is top left of the screen and (Resolution Width, Resolution Height) is bottom right corner of screen Thanks, I got it working, but how can I remove the rectangle when I press enter ? I tried: but it's not working ! Edited August 16, 2014 by nordi Link to comment Share on other sites More sharing options...
ans_ashkan Posted March 24, 2014 Share Posted March 24, 2014 (edited) just write event handler name after -= like this: if (Keys.Enter == e.Key){ this.PerFrameDrawing -= camera_rectangle;} Edited March 24, 2014 by ans_ashkan Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted March 24, 2014 Share Posted March 24, 2014 x and y is for the position on screen, u should calculate x and y, width and height of the rectangle from Game.Resolution in order to position and size the same relative to different resolutions. the range of x and y is... (0, 0) is top left of the screen and (Resolution Width, Resolution Height) is bottom right corner of screen Thanks, I got it working, but how can I remove the rectangle when I press enter ? I tried: if (Keys.Enter == e.Key) { this.PerFrameDrawing -= new GraphicsEventHandler(camera_rectangle); } but it's not working ! yeah that is ok though i like to use a bool value to tell my script when an event is hooked so i dont try to unhook when it isnt even hooked, though i dont think it is an issue if u attempt to unhook an event that has not been hooked... i just dont like to allow my script to do that also the way ans_ashkan wrote i prefer... the c# compiler will know the correct eventhandler object to use and it reads better i think u probably have some bug in your script that makes u think that the keydown is not working Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now