sv3nxd
Member
I draw a sprite rotated and horizontally flipped.
I do it with draw_sprite_ext and with draw_sprite_general, but I get a different outcome with each, despite having the same variables.
With draw_sprite_general, flipping the sprite seems to set the origin to center? I don't know and I can't really figure it out.
Anyways, the drawn sprite is offset by about half it's height. Really weird.
Code:
Outcome:
[SOLVED]
For anyone running into this problem:
Apparently draw_sprite_general uses the bounding-box to scale/flip the image, not the whole image.
If your image has it's bounding-box not set to "full" and got some free-space, then it's gonna deform like it did in my case.
Use sprite_duplicate(_sprite) and sprite_collision_mask(_sprite, false, 1, 0, 0, 0, 0, 1, 0) to ensure that the bbox is set to full.
Also remember to delete the duplicate again with sprite_delete(_sprite)
I do it with draw_sprite_ext and with draw_sprite_general, but I get a different outcome with each, despite having the same variables.
With draw_sprite_general, flipping the sprite seems to set the origin to center? I don't know and I can't really figure it out.
Anyways, the drawn sprite is offset by about half it's height. Really weird.
Code:
GML:
//BOTTOM BORDER
//_tile = sprite with a size of 24x24 pixels
//spr_w = 24
//spr_h = 24
for(var i = 0; i < width - spr_h; i+=spr_h) {
draw_sprite_ext(_tile, image_index, x + i, y + height - spr_w + 1, -1, 1, 90, c_white, 1);
}
var h = width mod spr_h;
draw_sprite_general(_tile, image_index, 0, 0, spr_w, spr_h - h, x + i, y + height - spr_w + 1, -1, 1, 90, c_white, c_white, c_white, c_white, 1);
Outcome:
[SOLVED]
For anyone running into this problem:
Apparently draw_sprite_general uses the bounding-box to scale/flip the image, not the whole image.
If your image has it's bounding-box not set to "full" and got some free-space, then it's gonna deform like it did in my case.
Use sprite_duplicate(_sprite) and sprite_collision_mask(_sprite, false, 1, 0, 0, 0, 0, 1, 0) to ensure that the bbox is set to full.
Also remember to delete the duplicate again with sprite_delete(_sprite)
Last edited: