Question

I've created a Canvas on my Screen and put an ImageSprite with de Canvas' width and height. Now when the ImageSprite is touched its visibility shall change. This works fine as long as I touch it once it disappears and is invisible. But when I touch it again nothing happens, although it should get visible again.

Here is a snapshot of my AppInventor Code:

ImageSpriteSnapshot

Was it helpful?

Solution

The problem is that since it gets hidden, it is no longer available for you to click anymore after that -- because it is hidden.

Do two things:

One: Set your ImageSprite1 to have a specific width and height, instead of using Automatic.

Two: Change your logic to use the Picture attribute instead of the Visible attribute:

when ImageSprit1.Touched
ifelse ImageSprite1.Picture = Image.png
then-do set ImageSprite1.Picture to text 
else-do set ImageSprite1.Picture to text Image.png

This way when you touch the ImageSprite, it set's it's Picture to nothing, making it seem hidden. (But if you specify the width and height first, the ImageSprite will retain it's dimensions and still be available to touch again. When you touch it again, it will show it's Picture again.

Make sure to replace Image.png with the name of your actual image.

The "text" puzzle piece is found under the "Built-in" tab in the Blocks Editor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top