Skip to content

Animation Manger Test

Raghuram Iyer "Ragzzy-R" edited this page May 19, 2014 · 14 revisions

This article tells how to use Animation Manager to maintain states.Most of them are easy to understand if you just take a look at Animation

             walkAnimator = new Animator(1,7);
	 slideAnimator= new Animator(1,3);
	 player = new AnimatableEntity(1);

we just initialize oru animators with row and colum as parameters.this row and column are derived from the rows and columns of the spritesheet being used. As you can argue not all spritesheets are exactly given row and columns.(especially the one's made with some automatic tools). You can use another constructor which takes one arguement. The below code is equivalent to the above code

             walkAnimator = new Animator(7);
	 slideAnimator= new Animator(3);
	 player = new AnimatableEntity(1);

The AnimatableEntity is Also initialized.It takes one parameter that gives the minimum number of animators it will attach.

            walkAnimator.addFrameDimesion(0, 0,   0, 70, 64);
	walkAnimator.addFrameDimesion(1, 82,  0, 70, 64);
	walkAnimator.addFrameDimesion(2, 152, 0, 70, 64);
	walkAnimator.addFrameDimesion(3, 236, 0, 70, 64);
	walkAnimator.addFrameDimesion(4, 312, 0, 70, 64);
	walkAnimator.addFrameDimesion(5, 382, 0, 70, 64);
	walkAnimator.addFrameDimesion(6, 457, 0, 70, 64);

The above lines are the only boring part. We need to add each frame's dimension.one by one, which is lame actually. But this is the best I could think of.If anyone is ready to provide a better solution I'd be more than happy.

The paramenters of that function are index,x,y,width and height in that order.

Again the above function calls are needed only if ur graphic artist is retarded and draws sprites randomly or you just use a ripped sprite from google. If the sprite sheet is well organized in the form of matrix with each frames with same height and width then you can use this.

void setAllFramesDimension(int width,int height);  //call once
void addFrameCoOrdinates(int frameIndex,int x,int y);   //call for each frame

Clone this wiki locally