2017년 5월 7일 일요일

Make a DrawCircle behave like a Ball


Hey! so I've been trying to develop a PinBall app with AppInventor but I haven't found a way to add gravity to a ball. A few days ago I found some code that made a DrawCircle with Gravity and Bounce but it doesn´t collide with any objects and I can't find a way to do so. And I can't find a way to add gravity to a ball either since most vectors only seem to work with other procedures (For example DrawCircle). so, is there a way to make the DrawCircle collide with other sprites? or to substitute the DrawCircle with a ball while adding the gravity? Thanks!

You can see in the attached file the gravity code on the right, the code that makes the pinball pads move on the top left, and what I've tried to do for the collisions on the bottom left.

--
Downloaded blocks image?

-- 
Great, forgot to attach it haha. There are the blocks


-- 
If you want collisions, switch to Ball components, or prepare yourself to do a lot
of work in your clock timer event checking every possible moving object
for proximity to every other obstacle.

See these samples ...



-- 
Regarding gravity, to add that to a sprite or ball moving under its own power
(Speed > 0), you would have to translate speed and direction into X velocity
and Y velocity, then change the Y velocity a little each clock tick,
feeding the two velocities back into the speed and direction.

-- 
Do you have a code example? I tired but I guess I failed haha

-- 
you can find several gravity examples in Scott's Developers Library here search for gravity

--

댓글 없음:

댓글 쓰기