//This is for the background animation
$.playground().registerCallback(function(){
//Offset all the pane:
var newPos = (parseInt($("#background1").css("left")) - smallStarSpeed - PLAYGROUND_WIDTH) % (-2 * PLAYGROUND_WIDTH) + PLAYGROUND_WIDTH;
$("#background1").css("left", newPos);
newPos = (parseInt($("#background2").css("left")) - smallStarSpeed + 1 - PLAYGROUND_WIDTH) % (-2 * PLAYGROUND_WIDTH) + PLAYGROUND_WIDTH;
$("#background2").css("left", newPos);
newPos = (parseInt($("#background3").css("left")) - mediumStarSpeed - PLAYGROUND_WIDTH) % (-2 * PLAYGROUND_WIDTH) + PLAYGROUND_WIDTH;
$("#background3").css("left", newPos);
newPos = (parseInt($("#background4").css("left")) - mediumStarSpeed + 1 - PLAYGROUND_WIDTH) % (-2 * PLAYGROUND_WIDTH) + PLAYGROUND_WIDTH;
$("#background4").css("left", newPos);
newPos = (parseInt($("#background5").css("left")) - bigStarSpeed - PLAYGROUND_WIDTH) % (-2 * PLAYGROUND_WIDTH) + PLAYGROUND_WIDTH;
$("#background5").css("left", newPos);
newPos = (parseInt($("#background6").css("left")) - bigStarSpeed + 1 - PLAYGROUND_WIDTH) % (-2 * PLAYGROUND_WIDTH) + PLAYGROUND_WIDTH;
$("#background6").css("left", newPos);
}, REFRESH_RATE);
...why do we use NewPos as a variable name over and over again. Shouldn't be unique names like var smallStarPos, and mediumStarPos, and bigStarPos?
Any insight on this will be great!
$("#background1") |
background1
and background2
have the same animation "background1"
.
.addSprite("background1", {animation: background1,
width: PLAYGROUND_WIDTH,
height: PLAYGROUND_HEIGHT})
.addSprite("background2", {animation: background2,
width: PLAYGROUND_WIDTH,
height: PLAYGROUND_HEIGHT,
posx: PLAYGROUND_WIDTH})
It looks like you're new here. If you want to get involved, click one of these buttons!