This add on will walk you through
how to code a hidden surprise in your display window.
To start, add a new sprite by clicking
on choose new sprite from library.
This project we'll use the gift to surprise the shopper
with a discount, but you can pick any sprite you'd like.
Next, make the sprite go to a location
when the flag is clicked.
Drag out a when flag clicked block and a go to block.
Snap them together.
Now, whenever the flag is clicked,
the sprite will go to the same X and Y point on the stage.
Next, decide what kind of surprise
you want to program for your window display.
Drag out an if then statement from the control menu
and snap it under the go to block.
Add a touching block from the sensing menu
into the if then statement.
Select mouse pointer from the drop down menu
in the touching block, so the condition reads,
if touching mouse-pointer then.
In this example, the gift will say you get 20% off!
Using a say block from the looks menu.
You can make your sprite do whatever
you want when the mouse-pointer touches it.
Now test it out.
Nothing happens when the mouse pointer touches the gift.
That's because this sprite checks
if it's touching the mouse pointer only once.
This sprite should check the conditional statement
continuously, so place a forever loop
around the if then statement.
Now test the code.
Awesome!
The gift says, you get 20% off,
when the mouse-pointer touches it.
For an added challenge, you can program
the gift to hide when the flag is clicked
and appear when the mouse pointer touches it.
Click on the looks menu and a hide block right
after the when flag clicked block
and add a show block inside the if then statement.
Test it out.
Awesome!
You can also add a pick random block
into the X and Y coordinates of the go to block.
This will increase the difficulty of
a shopper finding your hidden surprise.
Do this by dragging a pick random block
from the operators menu and placing it
inside the X and Y positions in the go to block.
The sprite will now go to a random position
when the flag is clicked.
The values in the pick random blocks should not go
outside the range of the storefront window.
The width of the storefront window
is negative 240 to positive 240.
Enter these values into the pick random
block for the X coordinates.
The height of the storefront window is
from negative 180 to positive 100.
These values should go into the pick random
block for the Y coordinates.
Test this out.
Every time the flag is clicked, the gift hides,
goes to a random spot within the storefront
and waits until the mouse-pointer touches it.
Once the mouse pointer touches the hidden gift,
it will say, you get 20% off!
Now it's your turn.
Add a new sprite.
Code it to go to a hidden spot on the stage
using hide, go to, and pick random blocks.
Code your sprite to do a hidden surprise
when it touches the mouse using the forever loop
and if then statement, touching, and show blocks.
You can make anything happen using
the motion and looks blocks.
Consider using sound blocks as well.