Jump to content
Beocro

Spriter and Java - Some Sprites Rendering In Weird Positions

Recommended Posts

Hey everyone! Normally I wouldn't post on the forums for a problem, but I've been trying to figure this out for quite a while with no dice. I've been trying to render the Grey Guy using Trixt0r's Java-Spriter library with the Java2D method, but for some reason, the head and his hair aren't wanting to be rendered correctly.(That black blob on his chest is the 'hair') They just won't stay in the right positions. I really don't know what to do. Could there be a bug in the library code, or did I just mess up somewhere (most likely)? Does anyone know what could cause this? I'm fairly sure I duplicated the code from the examples exactly, so I won't post the code unless I really need to. Hopefully someone can help me, progress on my game has been halted while I try to figure this out. :)

Here's the Spriter project+files if you want to inspect them: http://filz.us/2ztZ
Note: I did PM Trixt0r about this a few days ago and haven't gotten any response, so I'm hoping the community can help me out.

Share this post


Link to post
Share on other sites

I figured it out! It was the fact that I scaled the head and hair, I think Trixt0r's library might not handle that correctly (which would be surprising) or I made some kind of mistake in the rendering code (more likely). I'll try to figure it out and will return with the results.

Share this post


Link to post
Share on other sites

Sorry, I did see your message, but forgot to answer back -.-

 

Are you using the Java2D renderer, I implemented or your own?

If not mine, can I see the code?

 

Is the character rendered correctly with LibGDX, Slick2D and LWJGL?

 

- Trixt0r

Share this post


Link to post
Share on other sites

Sorry it took so long to respond! I got a little busy. ^-^" I just tested scaling in your example with Java2D, and it seems to work perfectly fine. Obviously, I messed something up when copying it over. I'll see if I can figure out what I did wrong.

Share this post


Link to post
Share on other sites

I figured it out! I have absolutely no idea why this worked, but I was trying to adjust values to get it to render correctly and happened to fix it. I simply replaced this code in my Drawer implementation's draw() method:

int height = -(int)(sprite.getHeight()*object.scale.y);graphics.drawImage(sprite, (int)newX, (int)newY-height, (int)(sprite.getWidth()*object.scale.x), height, null);

with this:
 

graphics.drawImage(sprite, (int)newX, (int)(newY+sprite.getHeight()), (int)(sprite.getWidth()*object.scale.x), (int)(-sprite.getHeight()*object.scale.y), null);//Note the lack of *object.scale.y in the Y position.

I assume it was my mistake with my implementation anyway, but at least I got it working, although I am still perplexed about how this fixed it.

Share this post


Link to post
Share on other sites

Good job.

 

Yes. The Java2D renderer renders the animation not correctly ( the Slick2D renderer also), while LibGDX and LWJGL do it properly.

 

The problem is, that the y-axis in Java2D is inverted while in Spriter it is not.

 

I will push the fix today. Thanks for figuring it out.

 

- Trixt0r

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...