# Activity 16 How to Create Edge Sprites

**URL:** <https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420>\
**Category:** Unit and Lesson Discussion\
**Tags:** csd-unit-3, csd-unit-3-lesson-18\
**Created:** [April 6, 2018, 9:02am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420 "2018-04-06T09:02:59Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchun](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jchun](https://forum.code.org/u/jchun)\
**Post date:** [April 6, 2018, 9:02am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/1 "2018-04-06T09:02:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bradleywellsashley](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bradleywellsashley/32/522_2.png) [@bradleywellsashley](https://forum.code.org/u/bradleywellsashley)\
**Post date:** [April 8, 2018, 4:46pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/2 "2018-04-08T16:46:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jold](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jold/32/5811_2.png) [@jold](https://forum.code.org/u/jold)\
**Post date:** [April 10, 2018, 1:57pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/3 "2018-04-10T13:57:27Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![stefaniem](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@stefaniem](https://forum.code.org/u/stefaniem)\
**Post date:** [February 11, 2019, 2:44pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/4 "2019-02-11T14:44:44Z")

</div>

I need help with the edges, please help!

---

<div class="post-metadata">

**Author:** ![koliner](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@koliner](https://forum.code.org/u/koliner)\
**Post date:** [February 11, 2019, 4:31pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/5 "2019-02-11T16:31:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sevalmeshkov](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@sevalmeshkov](https://forum.code.org/u/sevalmeshkov)\
**Post date:** [March 8, 2019, 10:13pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/6 "2019-03-08T22:13:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![catherine.kenny](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/catherine.kenny/32/3255_2.png) [@catherine.kenny](https://forum.code.org/u/catherine.kenny)\
**Post date:** [April 11, 2019, 6:50am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/7 "2019-04-11T06:50:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![karenma](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/karenma/32/4924_2.png) [@karenma](https://forum.code.org/u/karenma)\
**Post date:** [April 12, 2019, 3:50am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/8 "2019-04-12T03:50:48Z")

</div>

Hi Catherine,

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

Thank you

---

<div class="post-metadata">

**Author:** ![mriley](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mriley](https://forum.code.org/u/mriley)\
**Post date:** [April 29, 2019, 5:18pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/9 "2019-04-29T17:18:01Z")

</div>

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

[Create Edge SPrites](https://docs.google.com/document/d/1JVUf7VvULXS0NS4e0TzOj5b1njfqIhN3O3wXZmRQwE0/edit?usp=sharing)

---

<div class="post-metadata">

**Author:** ![edavis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/edavis/32/4927_2.png) [@edavis](https://forum.code.org/u/edavis)\
**Post date:** [May 2, 2019, 1:24am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/10 "2019-05-02T01:24:41Z")

</div>

Could you open the permissions so we can see it?

---

<div class="post-metadata">

**Author:** ![mriley](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mriley](https://forum.code.org/u/mriley)\
**Post date:** [May 2, 2019, 12:24pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/11 "2019-05-02T12:24:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bradleywellsashley](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bradleywellsashley/32/522_2.png) [@bradleywellsashley](https://forum.code.org/u/bradleywellsashley)\
**Post date:** [May 5, 2019, 12:26am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/12 "2019-05-05T00:26:25Z")

</div>

Mr Riley,

We can see it - thanks for the resource!

Brad

---

<div class="post-metadata">

**Author:** ![cjackson](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cjackson](https://forum.code.org/u/cjackson)\
**Post date:** [February 13, 2020, 7:13pm UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/13 "2020-02-13T19:13:27Z")

</div>

> [@sevalmeshkov](#):
>
> 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.

How to draw your own and set these height width

---

<div class="post-metadata">

**Author:** ![kookooloopdaking](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/kookooloopdaking/32/5224_2.png) [@kookooloopdaking](https://forum.code.org/u/kookooloopdaking)\
**Post date:** [February 14, 2020, 2:44am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/14 "2020-02-14T02:44:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [February 14, 2020, 2:53am UTC](https://forum.code.org/t/activity-16-how-to-create-edge-sprites/15420/15 "2020-02-14T02:53:11Z")

</div>

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

Mike
