Skip to content

Commit

Permalink
Docs update for optional collide arg 'ignore_self'
Browse files Browse the repository at this point in the history
  • Loading branch information
celeritydesign committed Oct 27, 2024
1 parent a304f84 commit 2b6f846
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/reST/ref/sprite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ Sprites are not thread safe. So lock them yourself if using threads.
.. function:: spritecollide

| :sl:`Find sprites in a group that intersect another sprite.`
| :sg:`spritecollide(sprite, group, dokill, collided = None) -> Sprite_list`
| :sg:`spritecollide(sprite, group, dokill, collided = None, ignore_self = False) -> Sprite_list`
Return a list containing all Sprites in a Group that intersect with another
Sprite. Intersection is determined by comparing the ``Sprite.rect``
Expand All @@ -659,6 +659,10 @@ Sprites are not thread safe. So lock them yourself if using threads.
sprites must have a "rect" value, which is a rectangle of the sprite area,
which will be used to calculate the collision.

The ignore_self argument is a bool. If set to True, the sprite will not
register a collision with itself, even if it is contained within the group
being tested.

collided callables:

::
Expand Down Expand Up @@ -825,21 +829,25 @@ Sprites are not thread safe. So lock them yourself if using threads.
.. function:: spritecollideany

| :sl:`Simple test if a sprite intersects anything in a group.`
| :sg:`spritecollideany(sprite, group, collided = None) -> Sprite` Collision with the returned sprite.
| :sg:`spritecollideany(sprite, group, collided = None) -> None` No collision
| :sg:`spritecollideany(sprite, group, collided = None, ignore_self = False) -> Sprite` Collision with the returned sprite.
| :sg:`spritecollideany(sprite, group, collided = None, ignore_self = False) -> None` No collision
If the sprite collides with any single sprite in the group, a single
sprite from the group is returned. On no collision None is returned.

If you don't need all the features of the ``pygame.sprite.spritecollide()`` function, this
function will be a bit quicker.
function will be a bit quicker..

The collided argument is a callback function used to calculate if two sprites are
colliding. It should take two sprites as values and return a bool value
indicating if they are colliding. If collided is not passed, then all
sprites must have a "rect" value, which is a rectangle of the sprite area,
which will be used to calculate the collision.

The ignore_self argument is a bool. If set to True, the sprite will not
register a collision with itself, even if it is contained within the group
being tested.

.. ## pygame.sprite.spritecollideany ##
.. ## ##
Expand Down

0 comments on commit 2b6f846

Please sign in to comment.