Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to get the values of Rectangle Square?  (Read 749 times)

0 Members and 1 Guest are viewing this topic.

AndreeU17

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
How to get the values of Rectangle Square?
« on: May 17, 2014, 02:54:39 am »
So I've set some constructor that set the position and size of a Rectangle.

Now I want to do some statement testing, to check whether the rectangle ends up in a position were it isn't suppose to be.

So how can I do this? I know I can use the getPosition() to get the position of the rectangle, but how can I test that on an if statement? I want to test that the X position doesn't go over a certain X value as we'll as the Y, how can I do that? Just a small example will help, nothing big, most likely I'll understand but I'll remember once I see it

EDIT:
To get the x value of getPosition would I do this?
getPosition().x and getPosition().y
Or am I doing something wrong? Can't test since I'm away from a computer and away from an IDE

EDIT AGAIN
After some troubleshooting I figured out my problem!

I need to do as I said, getPosition().x > ....

Here how I did it
if(pongBall.BallShape.getPosition().y > windowY)
{
    // do some code
}
« Last Edit: May 17, 2014, 08:41:09 am by AndreeU17 »

 

anything