Bubble 16 - Help with Edges debugging


Hello. I spent a lot of time with the edge code, and got mine to detect the edges. An 8th student of mine came up and asked about making it detect edges because it is in the suggested extras. I cannot find the difference between his code and mine. Mine works, with the sprite.bounceOff(edges) command, but when he puts it in his, it freezes everything. When he hits run, everything shows like it is going to work, but the control keys do not move and he loses his velocity. There is an error code, but I’m not sure how to fix it. The error code goes away when we remove the bounce off command and everything works without it. This code works on mine though. We tried putting it in an if statement, but that didn’t work either.

This is a screenshot of his screen. (The picture did not upload so I’m trying a hyperlink to the picture) Screenshot of error

The code is below. The line that is causing the problem is in the last line above the }

Thanks for any help!

var character = createSprite(200, 200);


var score = 0;

var plane = createSprite(200, 400);


var coin = createSprite(randomNumber(0, 400), randomNumber(40, 360));


var sun = createSprite(200, 200);


sun.scale = 0.50;


sun.debug = true;

function draw() {




text(“Score:”, 5, 5, 20, 20);

text(score , 70, 5, 20, 20);

// Simulating Gravity

character.velocityY = character.velocityY + 0.1;

// update sprites


character.velocityY = -5;


if (keyWentDown(“right”)) {

character.velocityX = character.velocityX+0.3;


if (keyWentDown(“left”)) {

character.velocityX = character.velocityX-0.3;


if (character.isTouching(coin)) {

coin.x = randomNumber(0, 400);

coin.y = randomNumber(40,360);

score = score+1;


if (character.isTouching(sun)) {



if (coin.isTouching(sun)) {



if (character.isTouching(plane)) {







I don’t have permission to see the image.
It also may be helpful to post a link to the project so that we can more easily debug it.


I fixed the link, and thanks for the idea to share the link to his project. It is here! Project LInk


To use the edges you have to
before you can bounce off of them. I added that method call before the draw loop and it made the error go away.

Here is an example from the documentation.

var sprite = createSprite(200, 200);
sprite.setVelocity(randomNumber(-5, 5), randomNumber(-5, 5));
function draw() {


Ohhh!! Thank you so much! I have that in my program, and completely missed he didn’t have that. Thanks for finding that!


That smile on his face when his game worked! Thanks again!


I created a few How To guides for my students. Here is an example Edge Sprite How To