Registering When An Image is Overlapping With A Set Rectangle?
RocketBlaster05 last edited by
I'm making a minigame for my app and I just wanted to clear up some things before I begin...
I will have two rectangles, each will be on separate sides of the screen, left and right. I will have an image that spawns in at the top center of the screen and slowly falls down. I will use tilt controls in order to make the object in the center move left and right.
In order to register when the center image overlaps with a rectangle, how would I go about doing this? I would prefer if the entire image had to overlap with the rectangle before it was considered to have overlapped it.
ccc last edited by
>>> import ui >>> a = ui.Rect(10, 10, 100, 100) >>> b = ui.Rect(10, 10, 100, 100) >>> c = ui.Rect(11, 10, 101, 100) >>> a == b True >>> a == c False
JonB last edited by
I think what you want is
contains_rect, which you would apply to the bbox of the SpriteNodes.
IIRC you may be able to use
if other_rect in this_rect:
From the docs:
Return True if the given point lies within the bounds of the rectangle, False otherwise.
Return True if the given rectangle lies entirely within the bounds of this rectangle, False otherwise.
Return True if this rectangle intersects with the other rectangle, False otherwise.