Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | habamax |
Is there a way to rotate TouchScreenButton around center?
I would like to add Tween to wobble the button on press and can’t figure out how to do rotation around center of the button.
I can probably do it ugly way:
tween.interpolate_property(self, "rotation_degrees", 0, -20, 0.1, Tween.TRANS_BOUNCE,Tween.EASE_IN)
tween.interpolate_property(self, "position:x", self.position.x, self.position.x-40, 0.1, Tween.TRANS_BOUNCE,Tween.EASE_IN)
tween.interpolate_property(self, "position:y", self.position.y, self.position.y+50, 0.1, Tween.TRANS_BOUNCE,Tween.EASE_IN)
tween.start()
But it is quite cumbersome to hardcode those position changes.
Is there something “origin” based? Like
self.transform.origin = Vector2(position.x/2, position.y/2)
self.rotation = 1