GMS 2 Parent Object, change cursor to object's sprite.

I want to make the cursor change into the image of the object that is clicked on in the inventory. In each inventory object's LMB Release event I have the command to change the cursor to each specific sprite. For example, if the Inv_Wrench_Obj is clicked, I have the code:

cursor_sprite=Inv_Wrench_Spr
window_set_cursor(cr_none)

And this works great. However, I have 26 different items I need to do this with. Rather than code all 26 of them this way, I'd like to make a parent object. But I cannot seem to figure out what to put after cursor_sprite= in order to make each object display it's own sprite as the cursor.

Any thoughts?
Thanks.
 

Nidoking

Member
If there's an instance of each object, declare a variable in each one that stores the cursor sprite you want to use. If the sprite you want to use is the one that's already assigned, use its sprite_index.
 
If there's an instance of each object, declare a variable in each one that stores the cursor sprite you want to use. If the sprite you want to use is the one that's already assigned, use its sprite_index.
I do want to use each object's sprite_index. However, I'd like to avoid going in to each object to code, if I can at all help it. I was hoping there would be a command that was something like cursor_sprite=self.image_index in a parent object that every child would inherit. However, I can get it to work.
 

Nidoking

Member
I was hoping there would be a command that was something like cursor_sprite=self.image_index in a parent object that every child would inherit.
It's sprite_index, not image_index, but that is the exact line. If you have a problem with that, you'll need to describe what the problem actually is.
 
Top