Game Development Reference
In-Depth Information
//Adds the specified object (int array) at the end of the ArrayList.
public void addAnimationSegment( int [] ani){
this .animationSegmentList.add(ani);
}
//Sets the Animation Segment
public void setAnimationSegment( int segment){
this .currSegment = segment;
this .currFrame = 0;
}
//Changes the current FrameID of the Animation ArrayList.
//Adds the current FrameID by 1 => num1,
//Gets the length of the Animation ArrayList => num2,
//Returns a remainder of num1 and num2.
public void nextFrame(){
int [] currSeg = animationSegmentList.get(currSegment);
currFrame = (currFrame + 1)%currSeg.length;
}
Controlling Animations
The following methods are designed to control the animations of sprites:
//Starts animations
public void startAnimation(){
st.isGameOn = true ;
if (!st.isAlive()){
st.start();
}
}
//Pauses animations
public void pauseAnimation(){
st.isGameOn = false ;
}
Search WWH ::




Custom Search