Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Sprite position in grabber or in allegro

This thread is locked; no one can reply to it. rss feed Print
Sprite position in grabber or in allegro
dothedru22
Member #7,325
June 2006

Is there a way to line up the sprites correctly in grabber. I'm making a side scroller where the sprites line up at the feet and it would be so much easier to just line them up in grabber. but for some reason anything i change in grabber doesnt work. like i changed the x and y pos and the grid and everything but nothing seems to change. any help would be really appreciated. thanks.

Tobias Dammers
Member #2,604
August 2002
avatar

What exactly do you mean, "line up"? For a typical sidescroller, the feet will touch the bottom edge of the sprite, and you'd draw them at (x; feet_y - sprite->h). If your sprites are drawn correctly, then you shouldn't have to adjust anything in grabber.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

dothedru22
Member #7,325
June 2006

well like in the sprite animation example that comes with allegro. the animation lines up perfectly in grabber. im wandering if it was already set up that way in a paint program(photoshop, psp, etc) or aligned that way in grabber. because in the actual code there not changing any of the y or x coordinates whend drawing.

Tobias Dammers
Member #2,604
August 2002
avatar

The animation lines up because its individual frames are arranged so that they do. To be more precise, they are (probably) equally sized, and the character is always at the same position within the sprite.
When drawing a sprite, its entire area (including transparent pixels) is used. If, for example, you have a sprite that is all transparent except a pixel at position (20; 13), and you draw that sprite onto the screen at position (200; 400), then the non-transparent pixel will be at (220; 413).
So the best way to make your sprite animations line up is:
1. use the same sprite size for all frames, filling extra space with transparent (color #0 in palette mode, magic pink in hi/truecolor)
2. Put the actual images at the same position within the sprite. What this means exactly depends on the kind of object you are animating.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

dothedru22
Member #7,325
June 2006

Ok thanks man. So basically i have to line up the sprites in paint shop pro. thanks.

Go to: