Problem: Program only runs the first line of the functions

My student’s program isn’t doing what it’s supposed to. Her letter to the forum is below.

Here’s one of the codes that aren’t working (I have this same thing but for different sprites)

function SelectBrush() {
if (mousePressedOver(brushIcon)) {
brushIcon.setAnimation(“brushOutline”);

stampIcon.setAnimation(“stamp”);
colorSelector.setAnimation(“color”);
eraserIcon.setAnimation(“erase”);
IncDecIcon.setAnimation(“big/sma”);
pickerIcon.setAnimation(“picker”);
}
}

What it’s supposed to do:
When the mouse presses over brushIcon, it’s supposed to change brushIcon’s animation to brushOutline and all the others to something else.

What it’s doing:
It’s changing brushIcon’s animation to brushOutline but it isn’t changing the other animations.

The entire program is below. She is in 7th grade.

// Create your variables here
//Make new sprites for the outlined animations

var Helper = 0;
// Create your sprites here
var Start = createSprite(200, 200);
Start.setAnimation(“Start”);
Start.scale = 1.5;

var brushIcon = createSprite(25, 75);
brushIcon.setAnimation(“brush”);
brushIcon.visible = false;
brushIcon.scale = 0.04;

var pickerIcon = createSprite(26, 125);
pickerIcon.setAnimation(“picker”);
pickerIcon.visible = false;
pickerIcon.scale = 0.08;

var IncDecIcon = createSprite(25, 325);
IncDecIcon.setAnimation(“big/sma”);
IncDecIcon.visible = false;
IncDecIcon.scale = 0.17;

var stampIcon = createSprite(30, 175);
stampIcon.setAnimation(“stamp”);
stampIcon.visible = false;
stampIcon.scale = 0.08;

var colorSelector = createSprite(25, 275);
colorSelector.setAnimation(“color”);
colorSelector.visible = false;
colorSelector.scale = 0.18;

var eraserIcon = createSprite(27, 227);
eraserIcon.setAnimation(“erase”);
eraserIcon.visible = false;
eraserIcon.scale = 0.18;

var brushIcon = createSprite(25, 75);
brushIcon.setAnimation(“brush”);
brushIcon.visible = false;
brushIcon.scale = 0.04;

var pickerIcon = createSprite(26, 125);
pickerIcon.setAnimation(“picker”);
pickerIcon.visible = false;
pickerIcon.scale = 0.08;

var IncDecIcon = createSprite(25, 325);
IncDecIcon.setAnimation(“big/sma”);
IncDecIcon.visible = false;
IncDecIcon.scale = 0.17;

var stampIcon = createSprite(30, 175);
stampIcon.setAnimation(“stamp”);
stampIcon.visible = false;
stampIcon.scale = 0.08;

var colorSelector = createSprite(25, 275);
colorSelector.setAnimation(“color”);
colorSelector.visible = false;
colorSelector.scale = 0.18;

var eraserIcon = createSprite(27, 227);
eraserIcon.setAnimation(“erase”);
eraserIcon.visible = false;
eraserIcon.scale = 0.18;

var backArrow = createSprite(25,25);
backArrow.setAnimation(“BackArrow”);
backArrow.visible = false;
backArrow.scale = 0.08;

function draw() {
// update sprites
showIcons();

SelectIncDec();
SelectEraser();
SelectColor();
SelectStamp();
SelectPicker();
SelectBrush();
back();
drawSprites();

StartScreen();
}

// Create your functions here
function StartScreen() {
if (Helper == 0){
Start.visible = true;
textSize(50);
fill(“white”);
text(“pAint”, 137, 220);
textSize(25);
fill(“white”);
text(“Press ENTER to start!”, 77, 250);
if (keyDown(“ENTER”)){
Helper = 1;
background(“white”);
}
}
}

function showIcons(){
if (Helper > 0){
Start.visible = false;
brushIcon.visible = true;
pickerIcon.visible = true;
stampIcon.visible = true;
colorSelector.visible = true;
eraserIcon.visible = true;
backArrow.visible = true;
IncDecIcon.visible = true;
}
}

function SelectBrush() {
if (mousePressedOver(“brushIcon”)) {
brushIcon.setAnimation(“brushOutline”);

stampIcon.setAnimation(“stamp”);
colorSelector.setAnimation(“color”);
eraserIcon.setAnimation(“erase”);
IncDecIcon.setAnimation(“big/sma”);
pickerIcon.setAnimation(“picker”);

}
}

function SelectPicker() {
if (mousePressedOver(pickerIcon)) {
pickerIcon.setAnimation(“pickerOutline”);

brushIcon.setAnimation(“brush”);
stampIcon.setAnimation(“stamp”);
colorSelector.setAnimation(“color”);
eraserIcon.setAnimation(“erase”);
IncDecIcon.setAnimation(“big/sma”);
}
}

function SelectStamp() {
if (mousePressedOver(stampIcon)) {
stampIcon.setAnimation(“stampOutline”);

pickerIcon.setAnimation(“picker”);
brushIcon.setAnimation(“brush”);
colorSelector.setAnimation(“color”);
eraserIcon.setAnimation(“erase”);
IncDecIcon.setAnimation(“big/sma”);
}
}

function SelectColor() {
if (mousePressedOver(colorSelector)) {
colorSelector.setAnimation(“colorOutline”);

stampIcon.setAnimation(“stamp”);
pickerIcon.setAnimation(“picker”);
brushIcon.setAnimation(“brush”);
eraserIcon.setAnimation(“erase”);
IncDecIcon.setAnimation(“big/sma”);
}
}

function SelectEraser() {
if (mousePressedOver(eraserIcon)) {

eraserIcon.setAnimation(“eraseOutline”);
colorSelector.setAnimation(“color”);
stampIcon.setAnimation(“stamp”);
pickerIcon.setAnimation(“picker”);
brushIcon.setAnimation(“brush”);
IncDecIcon.setAnimation(“big/sma”);
drawSprites();

}
}

function SelectIncDec() {
if (mousePressedOver(IncDecIcon)) {
IncDecIcon.setAnimation(“big/smaOutline”);

eraserIcon.setAnimation(“erase”);
colorSelector.setAnimation(“color”);
stampIcon.setAnimation(“stamp”);
pickerIcon.setAnimation(“picker”);
brushIcon.setAnimation(“brush”);
drawSprites();
}
}

function back() {
if (mousePressedOver(backArrow)) {
Helper = 0;
brushIcon.visible = false;
pickerIcon.visible = false;
stampIcon.visible = false;
colorSelector.visible = false;
eraserIcon.visible = false;
backArrow.visible = false;
IncDecIcon.visible = false;
}
}

Please post the link to the project. It makes it much easier to help debug the problems. Thanks!

Take the quotation marks off around brushIcon in line 123

2 Likes

Daniel,

Checking in - did @jadams1 suggestion make sense and work?

Brad

Nope. It still doesn’t work.