0

So I got an image of a player animation( in file 900x900). I want to load it once and split into PImages 100x100 so that each one of them is a separate PImage. I am not a fan of using 81 separate files each 100x100 and loading them all. Is there a way of doing that in Processing.

I could just store PImage as one and create 81 Rectangle as place of a frame in big image, but how to draw just a part of PImage?

SkillGG
  • 647
  • 4
  • 18
  • 1
    In addition to to Kevin's answer, also check out [`PImage's copy()`](https://processing.org/reference/PImage_copy_.html) and [this long answer](https://stackoverflow.com/questions/55556823/how-do-you-work-with-sprites-and-why-were-they-used-so-widely-in-older-games/55559855#55559855) if you have the time ;) – George Profenza May 13 '19 at 15:19

1 Answers1

2

Questions like this are best answered by looking at the Processing reference.

Specifically, check out the reference for the PImage class here.

The get() function (reference here) allows you to split a PImage up into smaller PImage instances.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
  • Oh. I didn't think that was what `get()` does. I thought it just gave a pixel color of given spot in the image. I don't know why. But if that's what it does than thank you. I thought it has to be somewhere there. – SkillGG May 13 '19 at 15:21
  • 1
    @SkillGG The `get()` function can also give you the color of a specific pixel. It depends on what parameters you pass into it. – Kevin Workman May 13 '19 at 15:59
  • Yeah. I just read too little to notice that. My mistake. I gave up too early. – SkillGG May 13 '19 at 18:45