GameMaker: Studio

GameMaker: Studio

查看统计:
LaunchPad 2019 年 4 月 13 日 上午 4:53
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?
最后由 LaunchPad 编辑于; 2019 年 4 月 13 日 上午 4:53
< >
正在显示第 1 - 4 条,共 4 条留言
The Winter Bud 2019 年 4 月 13 日 上午 5:35 
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.
最后由 The Winter Bud 编辑于; 2023 年 6 月 19 日 下午 12:39
ulufarkas 2023 年 4 月 28 日 下午 1:22 
引用自 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 2023 年 6 月 18 日 下午 4:01 
引用自 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 2024 年 4 月 27 日 下午 6:21 
引用自 ulufarkas
引用自 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
< >
正在显示第 1 - 4 条,共 4 条留言
每页显示数: 1530 50