Hello. The "other" in the function .CollidedWith is printing a strange and long id instead of the name of the sprite it collides with. Does anyone know how I can simply get the name of the sprite? In this case the name of the bin a random product is dragged to.
Thank you in advance!
You will need to make two lists, one for the imageSprite components and one for their string
names. Get the index of other
from the first list on collided, then get the string name by using that index with the second list.
There is a PR in the AppInventor github for a block that returns the names of components, but not sure if it is coming through in the next release.
Thank you for your response. It doesn't seem to be working Is this what you ment the solution was? I created the list "listCompo" with all the components and following the same order, another one with the string names.
I have compared each item in the first list with "other", to save the index of when this happens and later use it to see if the product was well recycled.
You use a Maths block here:
Try with the logic block:
Also, will global whereItGoes actually match an item in the stringNames list ?
Actually in the end it didn't work. The first time it was lucky and it said I had recycled well but now it is just printing random indexes, so most times it is wrong, and occasionally the guess is right. Any other suggestions?
Thank you!
Could you share your aia project? I can have a look see if I can find the issue.
I believe we have a little bug in the system.
Try this example aia project
binman.aia (3 KB)
It should work as expected if you drag the black ball onto any of the other coloured balls (and let go - touch up).
However, if in the blocks, you remove the Ball4 visibility blocks from the Touch Up event, whichever ever coloured ball you drag to, the colour blue is returned.
I will now have a look at your project....
I tried using the touch up function with a semaphore to make the program wait until the dragging was finished but it didn't work either. However, the code about making the ball go back to its position is useful for my project. Thanks
I don't believe the "bug" I found is the issue with your project, I need a few minutes to figure it out....
OK, this seems to work.
Begreen2revised.aia (3.7 MB)
I have replaced the collidedWith event with the Touch Up, and used the collidedWith other method.
You should also do some work on your images, resize (e.g. the Fanta tin) and crop away all the excess transparent areas.
thank you for your help and the tips. It is very much appreciated.
my pleasure, looks like a good project to be doing
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.