Question

I have a ball based on a component and I've thought that using the isShowing() method would do the trick but after my ball leaves the container, (Pong game) the isShowing() method still returns true.

So does the isShowing() method check if the component is still in the container's... bounds? Or just if it is visible and the container is also visible.

...and how do I check if the component has left the container other than doing... ball.getX()+width() < container.getWidth() (sadly only for the left side, but just an example)

Was it helpful?

Solution

Well, you do ball.getX()+width() < container.getWidth()...
That's the classical way.

Now, you can also use contains, for example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top