My students are having trouble getting the code right for their game. They are trying to move their “nuke” left and right along with the circuit board buttons (similar to the Tug-o-War bug game), but pulling it toward their flags… But they can’t get the nuke to move. Please help!!
Hi Lindsey,
Your students are updating the variable that they use to store the nuke’s x property, but they aren’t updating the property block itself. They will need to use the setProperty
block to affect the position of the nuke.
You might want to make sure the students are clear that this line of code
var nuke = getProperty("nuke", "x");
just stores a number (the current x property of the “nuke” element) into the variable nuke
. It doesn’t create any lasting relationship between the element’s x position and the variable.
Elizabeth