简体   繁体   中英

How do I use the sprite sheet?

How could I use this sprite sheet to implement the characters in my game

Sprite sheet - https://www.deviantart.com/gooperblooper22/art/Space-Invaders-Sprite-Sheet-135338373

As MadProgrammer mentioned the best solution would be to split the sprite sheet into several dedicated ones.

But if you want to go with it as it is (and assuming you are not using OpenGL):

Create a class like SpriteAnimation holding a reference to the loaded image (maybe BufferedImage) and an array for the definitions what the actuall relevent parts of the image are. This question seems like a great resource of how to draw the image.

You will need to extend the code for the animation part switching the "sprites" depending on the timesteps and your animation needs. This question shows how to define the parts and animate them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM