Bouncing an image sprite off objects and edges? Need help ASAP

323 views
Skip to first unread message

NotACodingWiz

unread,
Apr 30, 2017, 11:49:13 AM4/30/17
to MIT App Inventor Forum
Hello, I've been trying to given an image sprite movement and having it bounce off edges. I am able to make the image sprite bounce of the edges but as soon it gets to the platform it stops. 
What i want the image sprite to do is bounce start movement, bounce of the edge,  then the platform and then basically repeat until it hits my character. 
I've attached the relevant code I've used above. 

Any help would be appreciated, need a solution by today. 
code.tiff

Taifun

unread,
Apr 30, 2017, 12:00:21 PM4/30/17
to MIT App Inventor Forum
because you set the timer to false...
instead of using a clock component you also could use the speed and interval property of the sprite itself...

Interval
The interval in milliseconds at which the sprite's position is updated. For example, if the interval is 50 and the speed is 10, then the sprite will move 10 pixels every 50 milliseconds.
 
Speed
The speed at which the sprite moves. The sprite moves this many pixels every interval.


Taifun

NotACodingWiz

unread,
Apr 30, 2017, 12:12:11 PM4/30/17
to MIT App Inventor Forum
Thanks for replying so quickly!

If I only used the speed property how would I get it's directional movement? I made the speed 20 and took out the clock but all it does is bounce back and forth.

Taifun

unread,
Apr 30, 2017, 12:47:19 PM4/30/17
to MIT App Inventor Forum
see again the documentation 

Heading

Returns the sprite's heading in degrees above the positive x-axis. Zero degrees is toward the right of the screen; 90 degrees is toward the top of the screen


you might want to do some tutorials to learn the basics

Taifun

SteveJG

unread,
Apr 30, 2017, 12:54:00 PM4/30/17
to MIT App Inventor Forum
Have you read   


yet?  It has some very good examples.  Or have you done this tutorial 

?   It seems to do part of what you want to do.


Regards,
Steve

NotACodingWiz

unread,
Apr 30, 2017, 1:33:01 PM4/30/17
to mitappinv...@googlegroups.com
After you said to mess with the degrees I am getting the diagonal direction movement I desired. 
Thank you so much. Here is my code now 

Thanks Taifun
code2.tiff

NotACodingWiz

unread,
Apr 30, 2017, 1:34:17 PM4/30/17
to mitappinv...@googlegroups.com
This is great stuff man thank you for referring me to this, definitely some helpful pieces in here. 
Thanks Steve!
Reply all
Reply to author
Forward
0 new messages