Unit 3 - Lesson 24 Code Issue

Hi there, my wonderfully bright student would like to know why her sprites visibility doesn’t change in her code. Thanks for your help!

Hi @c.kerlin,

Cute idea for a scene! From what I can tell and I think the intent is, the code is working! But, the old scene needs to be covered-up (or drawn over) for the new scene. To do this, just draw a background. You can play around with where the background is drawn (top of the draw loop or at the top of each scene).

Good luck!
~Michelle

Greetings @c.kerlin,

As @melynn has stated this is a canvas issue! we refer to it as a canvas because whatever you manage to draw on it stays until you cover over it,
Background Documentation: Code.org
now that you know the problem where do i put it?
well it may make sense to put it at the end first you actually will only get a blank screen calling it first will lead to greater success for anything else you’d like to draw afterwords

Spoiler Code (use as reference if needed)

function draw() {
  background("white") // can accept many formats much like fill || stroke
  if(World.mouseY < 200){
    drawScene1();
    joe.setAnimation("joe");
  } else {
    drawScene2();
    joe.setAnimation("billy-bob-joe");
  }
  drawSprites();
}

by replacing this 1 line you are effectively blanking the canvas for the next frame leaving none of the previous draw calls visible from the previous frame

Hope this helps!

1 Like

Thanks tons! Must be the end of year fog in our brains :slight_smile: We got it to work!

Thanks tons! We got it to work. Can’t believe we didn’t think about this :slight_smile: