Goal:
Now that our app has all the components it needs, we now need to code these part.
First we need to make our light saber “activate”. We are going to simulate this by having the canvas draw a line that will look like a lightsaber blades.
We also need to create a variable that tells our code whether the lightsaber is activated or not.
Steps:
- From Variables, place initialize global block on the screen and type “saberOn” in the box.
- From Logic, attach a false block to the end of the initialize global saberOn block.
- From Canvas, place a when Canvas1.Flung block onto the screen.
- From Control, place a IF statement block inside of the when Canvas1.Flung block.
- From Logic, attach a =(equal) block to the IF portion of the IF statement block.
- From Variables, place a get block in the left side of the =(equal) block and set it to saberOn.
- From Logic, place a false block in the right side of the =(equal) block.