GameMaker: Studio

GameMaker: Studio

View Stats:
LaunchPad Apr 13, 2019 @ 4:53am
How to change the default sprite origin location?
So i was trying to find a way on how to change the default sprite's origin location after u make a sprite. So for example after i make a new sprite i want its origin to be top left as a default. So how do i do it?
Last edited by LaunchPad; Apr 13, 2019 @ 4:53am
< >
Showing 1-4 of 4 comments
The Winter Bud Apr 13, 2019 @ 5:35am 
You can change the origin of the sprite in the sprite editor.

If you are looking to change it in game while the game is running try.
sprite_set_offset(ind, xoff, yoff);
Argument - Description
  • ind - The index of the sprite to change the offset of.
  • xoff - The x position of the origin.
  • yoff - The y position of the origin.
Example:
sprite_assign(spr_Custom, spr_Base); var xo=sprite_get_xoffset(spr_Base); var yo=sprite_get_yoffset(spr_Base); sprite_set_offset(spr_Custom, xo, yo);
The above code assigns the sprite indexed in "spr_Base" to the sprite indexed in "spr_Custom" and then uses the x and y offset values of "spr_Base" to set the new sprite's origin.
Last edited by The Winter Bud; Jun 19, 2023 @ 12:39pm
ulufarkas Apr 28, 2023 @ 1:22pm 
Originally posted by The Winter Bud:
You can change the origin of the sprite in the sprite editor. If you are looking to change it in game while the game is running try.
sprite_set_offset(ind, xoff, yoff);
Argument - Description
  • ind - The index of the sprite to change the offset of.
  • xoff - The x position of the origin.
  • yoff - The y position of the origin.
Example:
sprite_assign(spr_Custom, spr_Base); var xo=sprite_get_xoffset(spr_Base); var yo=sprite_get_yoffset(spr_Base); sprite_set_offset(spr_Custom, xo, yo);
The above code assigns the sprite indexed in "spr_Base" to the sprite indexed in "spr_Custom" and then uses the x and y offset values of "spr_Base" to set the new sprite's origin.
he just wanted to change default settings but you provided a totally irrelevant answer. why?
The Winter Bud Jun 18, 2023 @ 4:01pm 
Originally posted by ulufarkas:
he just wanted to change default settings but you provided a totally irrelevant answer. why?
I supplied both ways to change the origin. One in the editor and one using script.
Badviper Apr 27, 2024 @ 6:21pm 
Originally posted by ulufarkas:
Originally posted by The Winter Bud:
You can change the origin of the sprite in the sprite editor. If you are looking to change it in game while the game is running try.
sprite_set_offset(ind, xoff, yoff);

Example:
sprite_assign(spr_Custom, spr_Base); var xo=sprite_get_xoffset(spr_Base); var yo=sprite_get_yoffset(spr_Base); sprite_set_offset(spr_Custom, xo, yo);
The above code assigns the sprite indexed in "spr_Base" to the sprite indexed in "spr_Custom" and then uses the x and y offset values of "spr_Base" to set the new sprite's origin.
he just wanted to change default settings but you provided a totally irrelevant answer. why?
Plus, this secondary way of changing the sprite origin is exactly what I was looking for. For once google was helpful. xp
< >
Showing 1-4 of 4 comments
Per page: 1530 50