Game Development Reference
In-Depth Information
} else if (left < minLeft) {
this.moveToStart();
}
};
// Manually move the player to a certain
point along its track,independent of
// what its speed data attribute is.
this.moveToPercent = function(percent) {
element.style.left = parseInt(percent *
maxLeft) + "px";
if (percent >= 100) {
this.moveToFinish();
} else if (percent <= 0) {
this.moveToStart();
}
};
// Determine if the player has reached the
end of its track
this.isFinished = function() {
return parseInt(element.style.left) >=
maxLeft;
};
// Place the player at the beginning of its
track
this.moveToStart = function() {
element.style.left = this.getMinLeft() +
"px";
};
// Move the player to the very end of its
track
this.moveToFinish = function() {
element.style.left = this.getMaxLeft() +
"px";
Search WWH ::




Custom Search