Normalize ImageSprite Headings

250 views
Skip to first unread message

Scott Ferguson

unread,
Apr 18, 2014, 10:49:50 PM4/18/14
to
> YouTube video <


ImageSprites can rotate in App Inventor, but their Heading values can contain decimal places and they can be either positive or negative. 

Also, an ImageSprite with a Heading of 90 is pointing in exactly the same direction as one with a Heading of -270 degrees.

This video shows how to always have an ImageSprite's Heading in the range 0 <= Heading < 360 rounded to the **nearest whole degree.


Language blocks featured:


* Math round

* Math modulo


Component blocks featured:


* Canvas Dragged

* ImageSprite PointInDirection


---

hAPPy INVENTORing!


**round-to-even is used in App Inventor where 3.5 rounds up to 4 but 4.5 rounds down to 4 so the average of rounding is more consistent than always rounding .5 up.


ImageSpriteHeading.aia
Reply all
Reply to author
Forward
0 new messages