2017년 3월 24일 금요일

How to change an image sprite once you click on it.


My students just finished the "Mole Mash" tutorial, and now we are both interested in how you would change an image once you click on it. For example: Once you click on the Mole, it changes to a different image.(like a sad mole) We have been trying to figure it out for a few days now, and I am wondering if anyone has a solution for this. 

Thank you for your time!

--
which means, if you click the sprite, then it changes the image and if you release then the original image appears?
use the touchdown and touchup event and set the image accordingly...

--
I guess I'm confused on how to do that. I am new to this, and haven't learned the touch down or touch up event. This is what I have now and when I click on the mole it disappears. 

Screen Shot 2017-03-20 at 3.35.44 PM.png 표시 중

-- 
Also one of my students is making a man jump on a trampoline, and when the man jumps on and off the trampoline he wants the image sprite to change. Is there a way to do that?

-- 
Sadface.Visible is a boolean value (true or false), see also the documentation http://ai2.appinventor.mit.edu/reference/components/animation.html#ImageSprite



Visible
True if the sprite is visible.


you should use a text block and file name instead, for example "sadface.jpg"...
Also one of my students is making a man jump on a trampoline, and when the man jumps on and off the trampoline he wants the image sprite to change. Is there a way to do that?

how does jumping work? by button click? if yes, then he can do the same...

--
Drag in a Clock from Sensors if you don't have one yet.

When you change the Picture of a SMashed Mole,
you need to leave him visible for a second for showmanship,
before hiding him and healing him for next appearance.

Start an empty list of smashed sprites that need to be cleaned up,
and have the list serviced by another clock, removing from slot 1 and adding at the end when hit.
Or you could just leave them visible in their smashed face, and have the 
mole hiding code recover their bodies and heal them when it gets to them.

-- 
By the way, if you need to see how to change any sprite picture, see this doc ...

-- 

댓글 없음:

댓글 쓰기