@@ -84,17 +84,19 @@ def setXy(self, x, y):
8484 # Set X and Y
8585 self .x = x
8686 self .y = y
87+ pivotX = self .x - self .sprite .get_rect ().width / 2 + scratch .WIDTH / 2 + self .target .costumes [self .target .currentCostume ].rotationCenterX
88+ pivotY = self .y - self .sprite .get_rect ().height / 2 + scratch .HEIGHT / 2 + self .target .costumes [self .target .currentCostume ].rotationCenterY
89+ print ((pivotX , pivotY ))
8790 print ("aici" )
8891 # print(_("debug-prefix"), _("new-sprite-position", x=x, y=y, name=self.name), file=sys.stderr)
8992 #rect = self.sprite.get_rect(topleft=(self.x - self.target.costumes[self.target.currentCostume].rotationCenterX, self.y - self.target.costumes[self.target.currentCostume].rotationCenterY))
9093 offset = pygame .Vector2 (self .target .costumes [self .target .currentCostume ].rotationCenterX , self .target .costumes [self .target .currentCostume ].rotationCenterY )
91- offset .rotate_ip (90 + self .direction )
94+ offset .rotate_ip (270 + self .direction )
9295 self .image = pygame .transform .rotozoom (self .sprite , 90 - self .direction , 1 )
9396 # offset = pygame.Vector2(0, 0)
94- self .rect .x = scratch . WIDTH // 2 + self . x + offset .x
95- self .rect .y = scratch . HEIGHT // 2 - self . y + offset .y
97+ self .rect .x = pivotX - offset .x
98+ self .rect .y = pivotY - offset .y
9699 print (self .rect .x , self .rect .y , "/" , self .x , self .y , "/" , offset .x , offset .y )
97- # TODO update current rotation centre to correct sprite position
98100
99101 # Relatively set self position
100102 def setXyDelta (self , dx , dy ):
0 commit comments