Move imageSprite along circular path..

516 views
Skip to first unread message

Richard Nero

unread,
Sep 23, 2015, 11:44:05 PM9/23/15
to MIT App Inventor Forum
Sorry guys. Did not find answer to simple question ans searching also did not help. 

How do I make imageSprite to move along the periphery of imaginary circle?

Thanks for help. 

Italo

unread,
Sep 24, 2015, 3:25:35 AM9/24/15
to mitappinv...@googlegroups.com
This is the easy way. The hard way would use math that I don't really remember how to use, but the other guys here will probably post soon.



Greg Jensen

unread,
Sep 24, 2015, 1:51:00 PM9/24/15
to MIT App Inventor Forum
You can create the appearance of a circular movement by using an image sprite that is mostly clear then rotating it.  e.g. Draw an arrow in the top left corner of an image that has the pixel dimensions = the diameter of the circle you want. The image will be mostly clear (no colour) except for an arrow. Place it on the canvas at the co-ordinates of the centre of your circle minus the radius in both X and Y. Use a Clock.timer, or whatever, to change the sprite heading but don't move it at all.   

Abraham Getzler

unread,
Sep 24, 2015, 2:23:00 PM9/24/15
to mitappinv...@googlegroups.com
Here's the trigonometry if you want to calculate x,y positions
for the sprite on the fly ..

delta y = - r * sin(theta)
delta x =  r * cos(theta)
(editted by ABG for correction)

where r is the radius, as measured from your pivot point to the point of suspension on your sprite
(for Ferris Wheel cars, at their top center, for example)

theta is the angle in degrees counterclockwise from East of the sprite point of suspension,
as measured from the pivot point.  You can use the heading of an invisible rotating ball,
if you like, or a global variable, and increment it periodically as in the other posts.

delta x = the amount to add to the fixed pivot point's x value to get the x coordinate
of the suspension point

delta y = the amount to add to the fixed pivot point's y value to get the y coordinate
of the suspension point.  (Note that y coordinates run downwards, not upwards.)

All coordinates are in pixels, and should be calculated by taking fixed per centages 
of your canvas height and/or width, depending on which is smaller.

ABG




Abraham Getzler

unread,
Sep 24, 2015, 2:25:06 PM9/24/15
to MIT App Inventor Forum

delta y = - r * sin(theta)
delta x =  r * cos(theta)
(editted by ABG for correction)

ABG

Scott Ferguson

unread,
Sep 25, 2015, 2:59:20 PM9/25/15
to MIT App Inventor Forum

Here are some blocks to illustrate Abraham's example:



The output is a circle plotted around the left black ball and a red ball orbiting the right black ball:



---

sf


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