Game Development Reference
In-Depth Information
Using linear interpolation for left-hand rotation
We want to throw the grenade when the Enter key is pressed. Let's first go over the
class to handle the animation of the left hand.
Open the LeftHand.js file from the primitive/game folder of the code bundle in
your text editor.
The LeftHand class also inherits StageObject . We have defined some new properties
( rotations , counter , and grenadeCallBack ). The rotations array holds the angles
that we need to interpolate on. The integer counter maintains number of times the
update function has been invoked. The variable grenadeCallback , holds the reference
to the function that has to be invoked once the animation has finished. The constructor
initializes the rotations array with values from 90 to 75 degrees. The visible
property has been initialized to false to avoid rendering of the left arm initially:
LeftHand= inherit(StageObject, function (){
superc(this);
this.rotations=[];
for(var j=90.0;j>=75.0;--j){
 
Search WWH ::




Custom Search