Code not working right in Interactive Card


#1

Can someone help please. One of my students is trying to make the scene change when the left mouse button is pushed down. When we run the code, only Scene 1 is displaying and nothing else is happening. What are we missing?


#2

Hi Sarah,

This is one way to make the scenes switch. Hope this helps your students with their Card. Please share with how it works out. Karen

var scene1 = createSprite(200, 200);
scene1.setAnimation(“scene1”);
var scene2 = createSprite(200, 200);
scene2.setAnimation(“scene2”);
function draw() {
if (keyDown(“down”)) {
scene1.visible = true;
scene2.visible= false;
}
if (keyWentUp(“down”)) {
scene1.visible= false;
scene2.visible = true;
}
drawSprites();
}