How to Avoid Imagesprite Cannibalism in App Inventor
When more than one ImageSprite is on a Canvas and those sprites can be dragged, then it is common for one sprite to 'capture' another if they touch. Once 'captured' the two are stuck together. To avoid this a few simple steps are required.
EditSteps
-
1Get an idea of the whole project first. What we are going to do is add a special placeholder ImageSprite to the Canvas and test inside each of your ImageSprites' Dragged event blocks to make sure it is the one that is currently being dragged. If it is the current ImageSprite then it will allow itself to be dragged. If it is not the current ImageSprite then it will not react to the event This is best shown with images from the Screen Designer and Blocks Editor.
-
2Create PlaceHolderISP ImageSprite. Uncheck it's Visible property.
-
3Create a global variable CurrentISP.
-
4Drag out TouchDown, TouchUp event blocks. For each ImageSprite, set their values as shown above.
-
5Add 'If' blocks. Does the CurrentISP variable contain the Dragged event's component value?
-
6Your Canvas will now be free of ImageSprite cannibals!
We could really use your help!
homesteading?

focus groups?

car stereos?

slipcovers?

Article Info
Categories: Website Application Instructions
Recent edits by: Anna, Scottfromscott
Thanks to all authors for creating a page that has been read 390 times.