Jump to content

DrawRectangle


nordi

Recommended Posts

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 by nordi
Link to comment
Share on other sites

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

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

LordOfTheBongs

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

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 by nordi
Link to comment
Share on other sites

just write event handler name after -=

 

like this:

if (Keys.Enter == e.Key){     this.PerFrameDrawing -= camera_rectangle;}
Edited by ans_ashkan
Link to comment
Share on other sites

LordOfTheBongs

 

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.