In this video, you will program the player sprite to follow the mouse pointer.
To start, select the player sprite. Next, click the motion menu, and drag outa "go-to mouse pointer" block. When you click it, the sprite will go towards the mouse pointer'slocation. In this case, the mouse pointer is in the scripts editor, so the sprite goesto the right edge of the stage. The sprite needs to follow the mouse. Thatmeans that the sprite needs to go to the mouse pointer over and over again, not just once.
To do that, use the “forever” block. Now, when you click on this block stack, thesprite will go to the mouse every time. Good! Next, add an event to tell the computerwhen to run this code. Use a "when sprite clicked" event, which tellsthe sprite to follow the mouse pointer when the sprite is clicked.
Great! Finally, try it out to see if it works. Click the sprite. Don’t click and drag thesprite, but instead click and release it. To stop the program, click the stop sign.
Nice job! Now it’s your turn! Program your player sprite using:1. A go to ‘mouse pointer’ block 2. A forever blockand 3. A ‘When this sprite clicked’ eventRemember, if you have a question while working, ask a neighbor or get the attention of yourCS First Guru.