Activity 16 How to Create Edge Sprites

Can someone please tell me how to create “edge” sprites to keep the character from bouncing out in Puzzle 16? I looked at the example solution, but can’t seem to find the right trunk from the animation library.

Ms. Chun,

A way to do this is to have an if statement which checks the condition of x and y position, and if it’s true and over the edge +400 or -0 you could have the sprite rotate 180 degrees and continue on its path.

In the example they have created sprites that are the edges and then used the bounceOff block (might need to use text based programming for that character.bounceOff(edge) ). This way you are creating additional sprites to interact with.

Let me know if that helps!
Brad

1 Like

@jchun I think they just made their own sprite that is as tall or as wide as the screen. I can’t find the trunk and trunk flipped in the sprite library.

I need help with the edges, please help!

My students figured out to make invisible thin rectangles on all sides and then use the character.bounceOff(edge) command. I am curious now about Brad’s “sprite rotate 180*” method. I don’t believe any of my students discovered that solution.

You can draw your own by setting the height to 400 and the width to 5. Do not color it to make it invisible. Use 0,200 for x and y when you create the sprite.

1 Like

Several of us are having our Character Sprite disappear when we add the “bounceOff” blocks for the 4 edges we created. Has anyone had this happen? If so, have you found a solution?

Hi Catherine,

Could you post a link to the code from these students? That would make it easier to help with debugging.

Thank you

1 Like

Here is a Google Doc that I provide to my students. Hope it helps

Create Edge SPrites

Could you open the permissions so we can see it?

I changed the permissions on the doc. Hopefully all can see it now.

Mr Riley,

We can see it - thanks for the resource!

Brad

How to draw your own and set these height width

There’s a nifty line of code that can be used to create edge sprites for edge detection. it’s called createEdgeSprites() it creates a group of sprites at the edges, and puts them all into a group, referenced by edges you can use sprite.bounceOff(edges) for this exact thing.

no more of that tricky creating your own edge sprites, as it does it for you.

2 Likes

You beat me to the same suggestion @kookooloopdaking I discovered those by accident once and they are a time saver.

Mike