How do I make the ball move towards a random location?

Hey,
I'm trying to code the ball so that when the button is clicked it would move towards a random location for few seconds and then change the direction and repeat it until it reaches X = 270.


When I want to try it out, it just freezes.
Any ideas why or how to do it?

Instead of a loop, use a Clock Timer from the Sensors drawer.

Move your blocks from the while loop into the Clock1 Timer event.

How do I make it so that it stops doing this when the Ball1.X = 270?

I remember you're probably working on a game. I tested your app several times. Randomly bouncing would not be a good idea. I would think in your place over the rebound depending on which way the bouncing element is moving.

Now I'm trying a different game which is fairly simple. You have 2 buttons, buy stock and sell stock. the ball is to show the price so when u buy it then it randomly mvoes forwards and it goes down or up and when you click sell it stops and the point of the game is to buy it for less and sell for more. I saw a game called "get rich 3d" its a typical money grabber, made in few hours with free assets and tons of ads. I liked the concept tho so I tried to recreate it, but it isnt that simple since im using the ball component the first time ever.

I can send the .aia file if necessary

Here's a small sample, using a small Ball as a target for the move...

Thanks, but do you know how to make it so that the ball would move forward a bit and up or down each few seconds randomly till it reaches the border or just X 270? Sorry I'm new to the ball component and overall to mit app inventor.

See chapters 5 and 17 of the free book at
http://www.appinventor.org/book2
from

Thanks a lot, it worked!

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