Results 1 to 9 of 9
- 05-28-2011, 10:53 AM #1
Member
- Join Date
- May 2011
- Posts
- 12
- Rep Power
- 0
help with intersects() and contains()
My code compiles is fine except that the intersects method (I have also tried it as a contains method) does not act or something.
Here it is:
Java Code:if(comCart.getPosition().intersects(dropCreate.getPosition())){ dropCreate.getPosition().x = 544; dropCreate.getPosition().y = 0; stillNeed.gotIn(); }
Java Code:public Rectangle getPosition() { return pos; }
- 05-28-2011, 11:48 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 12
What result do you get when you print the return of the intersect method shown in that if?
- 05-28-2011, 11:59 AM #3
Member
- Join Date
- May 2011
- Posts
- 12
- Rep Power
- 0
that return statement of pos? it just gives me access to the pos Rectangle I have in that class. I don't fully understand what you are trying to say but nothing prints this is a game not text based. it had Jpanels and JFrames etc.
- 05-28-2011, 12:04 PM #4
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 12
You still show a conditional in your first snippet, and I am assuming it returns something, try printing the return value of the statement being used as the condition to the first snippet. This will help you debug the problem.
- 05-28-2011, 12:12 PM #5
Member
- Join Date
- May 2011
- Posts
- 12
- Rep Power
- 0
Can you please write an example of what you mean? Sorry i can easily miss what people mean with this type of stuff a lot
- 05-28-2011, 12:32 PM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 12
Java Code:System.out.println(comCart.getPosition().intersects(dropCreate.getPosition()));
- 05-28-2011, 12:38 PM #7
Member
- Join Date
- May 2011
- Posts
- 12
- Rep Power
- 0
yea put that in. No println happened in dos. for some reason the objects are not interacting, sorta guessed that in the first place.
- 05-28-2011, 12:47 PM #8
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 12
Without any code it's hard to tell you anything, most people will only really guess with what little code you have supplied. As of right now I have no idea when the code snippet is called, if it's called, etc.
- 05-28-2011, 12:54 PM #9
Member
- Join Date
- May 2011
- Posts
- 35
- Rep Power
- 0
Bookmarks