Making sprites visible/invisible

Kerbe & Kerbe1

My student wants to move her mouse over a little pink sprite (Kerbe), causing Kerbe to disappear and a much large pink blob (Kerbe1) to appear.

When she moves the mouse away from where little Kerbe was (and/or lifts her finger off the left mouse?), little Kerbe comes back - and she doesn’t want that.

We tried to do something like:

If mouseover Kerbe then Kerbe visible = false and Kerbe1 visible = true.

Nothing we thought of worked and in one case a little grey square appeared, sometimes with little Kerbe as well and sometimes without.

I think it should be simple, but it’s escaping me.

Thank you for helping.

Gary Ellis


The link doesn’t appear to be working, but if I am envisioning this correctly, I think they might want to look at a different trigger other than mouseOver… mouseDown perhaps?

Try that and/or see if you can make sure that project sharing is available and that you have shared the link with the “share” button and we are happy to look at it closer.



1 Like

The link should work now.
Thank you!


PS They couldn’t quite get it to work the way they wanted. They figured out a kind of workaround, but I wish she could get it the way she wanted.


A few things here. It looks like all of the “createSprite” blocks are inside the draw loop, so every sprite is being created over and over again (as that is how the draw loop works). So, the first thing I would recommend is moving all of the creation blocks (code) to the top of the code, but before the draw loop starts.

The setAnimation blocks could also be moved outside of the draw loop, but you will also need to add a .visible block to the sprites that need to start off being invisible.

Here’s a screenshot of what I am referring to showing part of the blocks I would move outside of the draw loop…

Screen Shot 2022-03-22 at 4.29.00 PM

Then, inside the draw loop, you would put your background and your conditionals.

Then, if kirbe is supposed to disappear and not come back, you would probably need to create a variable at the top of your code (outside of the draw loop). It could be called anything (like “clicked”). Set it to false.

Then, you would want clicked to become true when the mouse was pressed over kirbe.

Then, if clicked is true (a new conditional), you would hide kirbe and make kirbe1 visible).

The clicked variable acts like a switch. Pressing the mouse over Kirbe turns on the switch, but when you release the mouse, the switch is still turned on, so kirbe is still hidden and kirbe1 still shows up… here’s another screenshot.

Screen Shot 2022-03-22 at 4.32.29 PM

I was able to get it to work by doing that. I would encourage them to give it a shot and if they still have problems, share us their modified code and we can look at it again!

Good luck!