def invert(self):
"""
Inverts this Collision in place to yield the Collision for the case that the two Sprites are switched.
"""
# flip the sprites
tmp = self.sprite1
self.sprite1 = self.sprite2
self.sprite2 = tmp
# invert the normal and separate (leave distance negative, leave magnitude positive)
self.normal_x = -self.normal_x
self.normal_y = -self.normal_y
self.separate = [-self.separate[0], -self.separate[1]]
# the direction veloc
self.direction_veloc = -self.direction_veloc
return self
## OBSOLETE CLASS
#class PlatformerCollision(Collision):
# """
# A collision object that can be used by PlatformerPhysics to handle Collisions.
# """
#
# def __init__(self):
# super().__init__()
# self.impact = 0.0 # the impulse of the collision on some mass (used for pushing heavy objects)
# # OBSOLETE: these should all be no longer needed
# # self.slope = False # whether this is a collision with a sloped TileSprite of a TiledTileLayer
# (will also be False if obj1 collides with the Tile's rect, but obj1 is still in air (slope))
# # self.slope_y_pull = 0 # amount of y that Sprite has to move up (negative) or down (positive) because of the collision (with a slope)
# #self.slope_up_down = 0 # 0=no slope, -1=down slope, 1 = up slope
评论列表
文章目录