Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Smarter Image Flipping (Gosu + Chipmunk)?
- By justindz Date 2009-03-03 16:16
Question on flipping images. I saw your comment on -1 xfactor. That worked swimmingly. However, because the image is drawing from the top left, when I flip the guy as he moves left and right he "teleports" a little--he doesn't appear to switch in place.

Any tips on how to make him change directions "in place?" Specifically, any tips on how to do it without screwing up Chipmunk. I'm sort of nervous about fudging the drawing too far away from the actual position tracking that Chipmunk does on the body.

Gosu is awesome.

[note: posted this on the google wiki before I realized I should probably put it here]
- By hima Date 2009-03-03 17:16
How about changing the  drawing coordinate from top-left to center-center?  You may need to change the coordinate, but I think it's easier this way. :)
- By justindz Date 2009-03-03 17:44
Just subtract half the sprite width and half the height from the drawing coordinates in the draw function?  That's probably quite simple, if that's what you're suggesting.  I'll have to ponder any side-effects in Chipmunk.
- By hima Date 2009-03-03 18:09
Oh what I mean is this one

draw_rot(x, y, z, angle, center_x=0.5, center_y=0.5, factor_x=1, factor_y=1, color=0xffffffff, mode=:default): center_x Relative horizontal position of the rotation center on the image. 0 is the left border, 1 is the right border, 0.5 is the center (and default)—the same applies to center_y, respectively.

Instead of draw, using draw_rot and you can specify what kind of coordinate you want to use. Hope that helps!
- By justindz Date 2009-03-03 18:55
Perfect.  Probably something I should have figured out on my own!  I'm very, very new to graphics of any sort.  Thanks a ton.
Up Topic Gosu / Gosu Exchange / Smarter Image Flipping (Gosu + Chipmunk)?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill