1
\$\begingroup\$

I know the method for drawing a region of a texture in slick2d:

image.draw(x, y, srcX, srcY, srcX2, srcY2);

But I have no idea how the texture coordinates work. To draw a region of x:16, y:16, width:32, height:16 from a texture. I tried:

image.draw(0, 0, 16, 16, 32, 16);

and I have tried many other things with no luck. All I get is weirdly cropped and stretched images. Help?

\$\endgroup\$
9
  • \$\begingroup\$ it goes x position on screen, y position, then the texture coordinates of left, top, right, bottom slick.ninjacave.com/javadoc/org/newdawn/slick/… \$\endgroup\$
    – nhydock
    Mar 6, 2014 at 22:39
  • \$\begingroup\$ I wrote a sprite retrieval class... Maybe try that? gamedev.stackexchange.com/questions/47675/… \$\endgroup\$
    – Savlon
    Mar 6, 2014 at 22:42
  • \$\begingroup\$ @nhydock I already tried that and even looked at that page but it didn't work. It doesn't really seem like you know what you're talking about \$\endgroup\$ Mar 6, 2014 at 22:42
  • \$\begingroup\$ @Savlon Yeah but I already have the code to load slick2d images and I just want to know how this method works. \$\endgroup\$ Mar 6, 2014 at 22:44
  • 1
    \$\begingroup\$ "weirdly cropped and stretched images" is a bit of a vague and unhelpful descriptor without a screenshot \$\endgroup\$
    – nhydock
    Mar 6, 2014 at 22:44

0

You must log in to answer this question.

Browse other questions tagged .