Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual Content: sprite_index page needs to say setting a new sprite with fewer frames causes image_index to reset to 0 #4787

Closed
KormexGit opened this issue Feb 22, 2024 · 1 comment
Assignees
Labels
docs-bug GameMaker Manual Bugs

Comments

@KormexGit
Copy link

Description

If you do something like this

image_index = 3;
show_debug_message(image_index);
sprite_index = spr_has_two_frames;
show_debug_message(image_index);
sprite_index = spr_has_ten_frames;
show_debug_message(image_index);

This will show
3
0
0

In practical situations, swapping sprite_index multiple times a frame will make image_index loop based on the one with the fewest frames since it loops instantly on swap. This can catch people off-guard and be very difficult to debug if you don't know this behavior exists.

I was not able to find any place that this is documented, since the current sprite_index page says:
"Changing the sprite does not change the index of the currently visible frame, so if you change the sprite on frame number 3, the new sprite will be drawn with that frame visible (assuming it has the same number of frames)."
But doesn't say what happens if the new sprite does NOT have the same number of frames, and instead has less frames.

Manual Link

https://manual.gamemaker.io/monthly/en/index.htm#t=GameMaker_Language%2FGML_Reference%2FAsset_Management%2FSprites%2FSprite_Instance_Variables%2Fsprite_index.htm

@KormexGit KormexGit added the docs-bug GameMaker Manual Bugs label Feb 22, 2024
@YYDan YYDan changed the title The fact that sprite_index will instantly loop image_index when changed is not documented Manual Content: sprite_index page needs to say setting a new sprite with fewer frames causes image_index to reset to 0 Feb 22, 2024
@backYard321
Copy link

Description

If you do something like this


image_index = 3;

show_debug_message(image_index);

sprite_index = spr_has_two_frames;

show_debug_message(image_index);

sprite_index = spr_has_ten_frames;

show_debug_message(image_index);

This will show

3

0

0

In practical situations, swapping sprite_index multiple times a frame will make image_index loop based on the one with the fewest frames since it loops instantly on swap. This can catch people off-guard and be very difficult to debug if you don't know this behavior exists.

I was not able to find any place that this is documented, since the current sprite_index page says:

"Changing the sprite does not change the index of the currently visible frame, so if you change the sprite on frame number 3, the new sprite will be drawn with that frame visible (assuming it has the same number of frames)."

But doesn't say what happens if the new sprite does NOT have the same number of frames, and instead has less frames.

Manual Link

https://manual.gamemaker.io/monthly/en/index.htm#t=GameMaker_Language%2FGML_Reference%2FAsset_Management%2FSprites%2FSprite_Instance_Variables%2Fsprite_index.htm

Absolutely - I've seen a few people get tripped up by this (including myself lol) so it would be a major help.

gurpreetsinghmatharoo added a commit to YoYoGames/GameMaker-Manual that referenced this issue May 7, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Team Workload May 7, 2024
@gurpreetsinghmatharoo gurpreetsinghmatharoo moved this from Done to Ready for QA in Team Workload May 7, 2024
gurpreetsinghmatharoo added a commit to YoYoGames/GameMaker-Manual that referenced this issue Aug 8, 2024
…tion sprite will reset the image_index

YoYoGames/GameMaker-Bugs#4787

(cherry picked from commit ee02bd9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-bug GameMaker Manual Bugs
Projects
Status: Ready for QA
Development

No branches or pull requests

3 participants