So in my CS class I have been working on code.org I wanted to make something but it doesnt work because mousePressedOver is not one click. I don't really know anymore coding so this is why I need help, I couldn't find any answers online.
// framerate
World.frameRate = 120;
// sound
playSound("baller.mp3");
// variables+sprites
var balloon = createSprite(200, 200);
balloon.setAnimation("balloon");
balloon.scale = 0.1;
var baller = createSprite(200, 200);
baller.setAnimation("baller");
look at the comment where it says secret that is where I need help.
//draw loop
function draw() {
// background
background("white");
// scale and visible
balloon.scale = balloon.scale + 0.03;
baller.visible = false;
// if statement
if (balloon.scale > 0.5) {
baller.visible = true;
balloon.visible = false;
}
// secret
if (mousePressedOver(baller)) {
var shhhh = createSprite(200, 200);
shhhh.setAnimation("thing");
shhhh.scale = 0.3;
textSize(25);
text("You werent supposed to see this...", 20,50);
baller.visible = false;
}
// draw sprites
drawSprites();
}
You can use if (mousePressedOver(baller) && mouseWentDown("leftButton")) {}
to check if the Sprite is clicked once.
Edited:
Define a boolean variable ;
var showHiddenText = false;
Add this after you define background("white");
if(showHiddenText){
text("You werent supposed to see this...", 20,50)
}
Control it by changing the boolean value;
if (mousePressedOver(baller) && mouseDown()) {
showHiddenText = true;
}