• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [solved] Is there a way to detect a sprites image_index changing?

K

Kaltagg

Guest
Is there a way to detect a sprites image_index variable changing? What I am doing is trying to create an object, that whenever the sprites sub image number changes, creates a burst of particles. I have all of the particles worked out, and they show up when the object is destroyed (I have them being created under the destroy event), but I can't figure out something to put in an if statement, or an event that I can use, for this purpose. Any ideas?
 

TehCupcakes

Member
Of course you could do it the way Ragarnak mentioned... But I personally prefer not to have these kind of checks in step, and instead perform the necessary actions at the time of the change. Granted, you probably change the sprite quite frequently, so it would make sense to make a script that takes the sprite as an argument and then performs the sprite change, followed by creation of any particles. Then always call this script instead of changing sprite_index directly.

EDIT: Sorry, misread. :)
 
Last edited:
Of course you could do it the way Ragarnak mentioned... But I personally prefer not to have these kind of checks in step, and instead perform the necessary actions at the time of the change. Granted, you probably change the sprite quite frequently, so it would make sense to make a script that takes the sprite as an argument and then performs the sprite change, followed by creation of any particles. Then always call this script instead of changing sprite_index directly.
Um... image_index is not the same as sprite_index. image_index is the subimage of the sprite, whereas sprite_index is the index to the current sprite itself, not a subimage. @Kaltagg wants the particles to happen when the subimage number changes, not when the sprite is changed for a different one (based on my reading of the first post), so @Ragarnak is right with that solution.
 
Top