I have tried all the if/else combinations I can think of to get the bees to appear over the flower and disappear when not over the flower and I just can’t get it. Someone please help! I’ve been on this same activity for 4 hours. I need to be lead learner on this activity soon!
Never mind. I finally got it.
Hi tdavis. I’m struggling with this one too. Can you please share your solution?
It makes sense with the visible commands! I always remind my students that there’s more than one way to solve a problem. Thank you so much!
It’s absolutely awesome to see people supporting one another on here, however, the forum is not locked down from students. Could you remove your solution so we can continue to encourage students to problem solve their solutions? Please feel free to share solutions such as this via direct message to other users. Goodness knows we need help sometimes too! Thanks!
Done. Thank you for letting me know! I thought it was a teacher only place.
Were you able to get the solution for this? I’m STUCK!
Here is what I did:
var flower = createSprite(100, 200);
flower.setAnimation(“flower”);
var bee1 = createSprite(randomNumber(0, 400), randomNumber(0, 400));
bee1.setAnimation(“bee”);
var bee2 = createSprite(randomNumber(0, 400), randomNumber(0, 400));
bee2.setAnimation(“bee”);
var bee3 = createSprite(randomNumber(0, 400), randomNumber(0, 400));
bee3.setAnimation(“bee”);
World.frameRate = 20;
function draw() {
background(‘lightgreen’);
bee1.x = World.mouseX + randomNumber(-50, 50);
bee1.y = World.mouseY + randomNumber(-50, 50);
if (bee1.x < 200) {
bee1.visible = true;
} else {
bee1.visible = false;
}
bee2.x = World.mouseX + randomNumber(-50, 50);
bee2.y = World.mouseY + randomNumber(-50, 50);
if (bee2.x < 200) {
bee2.visible = true;
} else {
bee2.visible = false;
}
bee3.x = World.mouseX + randomNumber(-50, 50);
bee3.y = World.mouseY + randomNumber(-50, 50);
if (bee3.x < 200) {
bee3.visible = true;
} else {
bee3.visible = false;
}
drawSprites();
}
My students are working on the challenge to make the bees appear only over the actual flower (not the stem).
While I know this is definitely not the most ‘efficient’ way to code this - I’m struggling to find why this code doesn’t work for this:
Thanks!!!
If I go line by line from top to bottom, here is what I see:
If the mouse.x is less than 200, then check the mouse.y and if that is less than 200, then show and wiggle the bee.
BUT if mouse.x is more than 200, don’t check the mouse.y and hide the bee. Once that happens, there are no instructions to make the bee visible again once it has been hidden even if the first if statement is true .
Hope that helps,
Michelle