You can rotate an object around any point with
Rotate a degrees clockwise
Set position to (x-cx)*cos(a)-(y-cy)*sin(a)+cx, (x-cx)*sin(a)+(y-cy)*cos(a)+cy
Where x,y is the point, cx,cy is the center, and a is the degrees to rotate by.
So one possible solution could be to keep track of an offset dx,dy from the object’s xy to rotate around. Initially you’d set that to wherever on the layout minus the sprites position. Then after that you’d update it with a helper function.
Number rx=0
Number ry=0
Function vrotate(x,y,a)
— set rx to x*cos(a)-y*sin(a)
— set ry to x*sin(a)+y*cos(a)
Function rotateSprite(u, a)
Pick sprite by uid u
— sprite: set position to self.x+self.dx, self.y+self.dy
— sprite: rotate a degrees clockwise
— call vrotate(sprite.dx, sprite.dy, a)
— sprite: set dx to rx
— sprite: set dy to ry
— sprite: set position to self.x-self.dx, self.y-self.dy
Alternatively a different approach could be to have dx,dy be values from 0-1 to specify a point within the objects quad. Then to use that as a center you’d set the angle between two set position actions. It basically undoes the offset, rotates, then moves by updated offset.
Set position to Self.x-(Self.dx*self.width*cos(self.angle)-self.dy*self.height*sin(self.angle)), Self.y-(Self.dx*self.width*sin(self.angle)+self.dy*self.height*cos(self.angle))
Set angle to anything
Set position to Self.x+(Self.dx*self.width*cos(self.angle)-self.dy*self.height*sin(self.angle)), Self.y+(Self.dx*self.width*sin(self.angle)+self.dy*self.height*cos(self.angle))
Either way you need to change angle via events. Can’t use with a behavior that changes the angle.