I am totally new to programming and I am looking at pictures as I learn.
In the Diamond 9 that explains Debugging with Watchers
it shows by the circled 1
var “watch me” = 0
which I think means the watch me variable gets the 0 value.,
When I tried Activity 10 where I have to predict before watching the watchers,
I said it was not initialized because what I saw was
var “pan” = createSprite (200, 200);
which I thought meant the pan’s location was going to be 200,200 on the grid.
so what piece of code initialized the pan variable?
Thanks, Elaine
Hi Elaine,
I pasted the code to point out what each line of code does.
var pan = createSprite(200, 200);
pan.setAnimation(“pan”);
function draw() {
background(“palegreen”);
pan.rotation = pan.rotation + 1;
drawSprites();
}
The first line: Creates a sprite at the initial specified position.
Second line: Set the image or animation for the sprite
Third line: “function draw” :To create animations in Game Lab you’ll need a way to keep drawing frame after frame
Fifth line: Causes the pan to rotate clockwise +1 every time the draw loop runs.
The watcher code is actually hidden in this example.
Hopefully this helps.
Thank you so much this is exactly what I needed. Sometimes in the code.org there is only 1 example explained and of course there are thousands of different variations, is there another resource I can review to further explain a couple more examples like you did? Especially about the code watcher concept? (the next exercise) I reviewed the video several times but it doesn’t really explain HOW the watcher helps you debug. I do see the times that each variable ran in the frame but what does it mean? This concept is not as straight forward as looking to make sure variable names have no spaces, does not start with a number, etc. Thank you again for your help.