I have a student working on the interactive card and we can’t figure out why the spaceship in his program gets smaller and then comes back. He is using the counter pattern with scale and it all seems right to me. Any help would be appreciated! Here is his code:
var sky = createSprite(200, 200);
sky.setAnimation(“sky”);
var star1 = createSprite(40, 40);
star1.setAnimation(“star1”);
star1.scale = 0.2;
var star2 = createSprite(320, 80);
star2.setAnimation(“star2”);
star2.scale = 0.2;
var star3 = createSprite(170, 130);
star3.setAnimation(“star3”);
star3.scale = 0.2;
var star4 = createSprite(60, 130);
star4.setAnimation(“star4”);
star4.scale = 0.15;
var star5 = createSprite(230, 80);
star5.setAnimation(“star5”);
star5.scale = 0.15;
var ufo = createSprite(200, 200);
ufo.setAnimation(“ufo”);
ufo.visible = false;
ufo.scale = 0.7;
var star_count = 0;
function draw() {
if (mousePressedOver(star1) && mouseWentDown(“leftButton”)) {
star1.visible = false;
star_count = star_count + 1;
}
if (mousePressedOver(star2) && mouseWentDown(“leftButton”)) {
star2.visible = false;
star_count = star_count + 1;
}
if (mousePressedOver(star3) && mouseWentDown(“leftButton”)) {
star3.visible = false;
star_count = star_count + 1;
}
if (mousePressedOver(star4) && mouseWentDown(“leftButton”)) {
star4.visible = false;
star_count = star_count + 1;
}
if (mousePressedOver(star5) && mouseWentDown(“leftButton”)) {
star5.visible = false;
star_count = star_count + 1;
}
if (star_count >= 5) {
ufo.visible = true;
ufo.rotation = randomNumber(-10, 10);
ufo.scale = ufo.scale - 0.1;
}
drawSprites();
textSize(30);
fill(“red”);
text(“click the stars for a suprise”, 10, 300);
}