Point a sprite towards the direction that I'm dragging it

My game has a draggable sprite, I want it to point upwards when the player drags it upwards, etc, for any angle.
Is there a simple way to do that?

Set the Rotates property of the image sprite to true

http://ai2.appinventor.mit.edu/reference/components/animation.html#ImageSprite

Rotates
If true, the sprite image rotates to match the sprite’s heading. If false, the sprite image does not rotate when the sprite changes heading. The sprite rotates around its centerpoint.

Taifun

Well, it isn't working for me, I thought that some part of the code could be interfering, so to be sure, I created a new project, added a canvas and a sprite, left "Rotates" enabled, and even added code to enable "Rotates"
Screenshot_20240519_125715


temp.aia (670.0 KB)

Set the heading property accordingly

Rotates
If true, the sprite image rotates to match the sprite’s heading. If false, the sprite image does not rotate when the sprite changes heading. The sprite rotates around its centerpoint.

Taifun

ok, so what's a simple way to set the heading value to the direction that the sprite is being dragged?

rotate
temp (1).aia (670.5 KB)

rotate and fly
temp (2).aia (670.6 KB)

Try this, nearly there. Start your imageSprite in the centre of the canvas

YES!
Thanks a lot, that gave the result I was looking for

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.