Animation creation [2d]

To create the animation I use two Rectangles’, one will be used to determine the area of the spritesheet that will be used, and the second will take that area and draw it to the screen. spriteBatch.Draw(texture, drawRec, frameRec, Color.White);

To work out the position of the first Rectangle over the spritesheet I have a variable to store the frame number starting at 0 counting up to 11(for this sheet), this will be used to work out the X position “Current Position * Frame Width = X position”.

frameRec.
Walk right Frame 0 x 43 = 0 Rectangle position: X = 0, Y = 0

Walk right Frame 1 x 43 = 43 Rectangle position: X = 43 , Y = 0

Walk left Frame 3 x 43 = 129 Rectangle position: X = 129 , Y = 64

3 Likes