How would I simplify this into a procedure?

How would I simplify this into a procedure? They are all slightly different. Would I use an any sprite block? How?

Try with one common procedure along with when any sprites dragged event

The when any sprites dragged event does not fit into the procedure block.

How many more types of garbage sprites were you planning to add?

You could reuse one Sprite for different types of garbage by choosing a different .Picture for it at run time, and have the three different drag targets look to see if the Picture is in a list of acceptable Pictures for that bin (recycle/compost/garbage).

1 Like

I was planning on having eight sprites to be sorted and then there would be three sprites for the trash, recycling, and compost. What you suggested could work, but I would have to rework the user interface of my app. Is there a way to do it to have all 8 sprites shown and then picking whichever to be sorted?

This looks like a good place to use a lookup in pairs list block, with a two column table:

  • Sprite being dragged
  • appropriate container for that sprite.

(A table is a list of lists.)

That would allow you to use a single generic sprite collision event to test if the sprite being dragged collided with the appropriate container.

Beware of collisions with other pieces of garbage, though.
You would need to ignore those, perhaps by keeping a master list of all 8 garbage sprites, and using an is in list check before checking the container table.

To avoid sprite cannibalism deactivate all other sprites on sprite touchdown and reactivate them on touch up, otherwise they will stick to your finger like styrofoam balls.