I know this seems kind of stupid but the title isn’t all that it seems, I want code to run whenever a SPECIFIC sprite is made, not just a sprite TYPE for example: on created sprite name do something
How would I do this?
I know this seems kind of stupid but the title isn’t all that it seems, I want code to run whenever a SPECIFIC sprite is made, not just a sprite TYPE for example: on created sprite name do something
How would I do this?
You would have to run the code when you create the sprite. Like, wherever you are creating the sprite in the code, you just put the code you want to run after that sprite gets created. If you are picking random sprites to create them, then you would have to check if the image of the sprite is the same as the image of the sprite you are checking for, then run the code if it’s the same. I don’t think you can use an “=“ to compare images, but there is a block for that in the Images tab (in the advanced category).
Oh, sorry, I think I missed a part of your question, but you should be able to check the name of a sprite with one of the “=“ blocks, the one under the normal one with the little (“ “) boxes, which take strings instead of numbers. This is assuming you are using the sprite data extension or something similar to give your sprites names.
If you are thinking of the “name” being the variable you used, like “set (mySprite) to sprite…” with “mySprite” being the name, then I really don’t see why you can’t just put the code you want to run underneath the “set (mySprite)…” block to make it run when the sprite is created, unless there’s something I’m missing here?
Yeah you are kind of missing something, that would work if the sprite didn’t have multiple of it created, it chooses the NEWEST sprite of that variable, ignoring all of the others and making them obsolete, this is a problem because of the fact my game has bullets that explode into more bullets(which don’t explode)
try on sprite created of kind and create a custom kind for that sprite
I see. I would just make two new sprite types, one for the exploding bullet and the other for the one that doesn’t explode. That’s the easy solution, but if you want to keep just one type then I would recommend taking a look at the Sprite Data extension, which would allow you to basically “name” each Sprite with maybe a name or a number and then a different name/number when they explode.