2017년 8월 12일 토요일

Work-Around for Ball (or Sprite) Dragged Handler Issues


In an attempt to have multiple balls on a canvas have the ability to be independently available to be dragged around, I was having a lot of difficulty overcoming a vulnerability of the ball.dragged feature.  As similarly outlined in these other posts, "only allow dragging of one animation object at a time?", "Image sprite dragging cannibalism", "problem dragging only one sprite making puzzle game please help",  If each ball has a ball.dragged handler block, as you drag on ball across the other ball they will both then drag together directly on top of each other.  This had the illusion that one disappears when it is actually just directly behind it.

After almost giving up, I came up with the solution shown below.  It is basically a way to isolate which ball is enabled and disabled (without using a VERY needed Handler, like "onRelease" or "upTouch") as a function of which ball was selected first.  Even when the clock timer interval setting was low (10-100ms), the balls movement are mutually exclusive.

I am not a "trained programmer" so can others PLEASE test, verify and comment about its logic and usefulness?

I intend to use the advanced features so that I can incorporate many more balls on the canvas.
This should also work for image sprites.
In my application, I will be placing an image sprite right over and track with a no color ball to take advantage of the circular collide perimeter.

I hope this helps some.

--
thank you!
can you upload a zip file, this would make it easier to test...

--
Attached is the zip.

There are a few extra blocks and components that can be ignored.

I will also be adding a provision that will restrict any ball motion if the canvas (no sprite) is clicked first.

I look forward to the feedback.


--
Very nicely done SireFoss! The app works in my emulator perfectly :)

--
Thank you, thank you

--
I got it working with 3 objects...however, what does the p1 and the p2 refer to?
Also, when I have the object get to a certain point, and having an action...it sort of works, but not completely. will try adjusting timer

--
with the new features of Version 129 we now can simplify the solution, see here
https://groups.google.com/d/msg/programming-with-app-inventor/txX75RaCG2s/0HrA2AtuCNAJ
--
Would the z level help in this situation?

--
using the same z levels or different z levels did not help
or do you have another simpler solution?

--

댓글 없음:

댓글 쓰기