I made a game which includes shooting a shotgun, I used the Sprite-FX extension to rotate the shotgun around me but when I tried to change it’s image or animate it, it resets the rotation and then the image is replaced by the old one. I think it’s a problem with the actually extension as I can’t find any instances of the image changing except at the start. If there is a fix, can you please help me with it.
It’s not a bug, it’s just how the extension works, the setImage block is run before the sprite-fx rotation sets the rotated image so it’s just overwritten.
I forked the extension at sargedev/sprite-fx to export the rotateImage function which you could use to rotate the image after you set it to a frame of your animation, tho I didn’t make a block for the method so it’s only available in javascript right now.
Here’s an example of what I mean, press A to run a simple animation while the sprite rotates. Feel free to look at the code and you can replace the images in the frames array with any images you like to make a custom animation
If you want to change the image without it reverting, you have to use the “clone current image from x to y” block, but you you clone the sprite’s image onto itself. You have to do this right before you change the image every time. As for animation… there’s no easy way unfortunately. There IS a quite convoluted way I found, so if you want me to yap about, just tell me. I do think this should be fixed, cause it makes the extension considerably less useful.
Yeah, I kinda just want to add a single frame for firing, if you can tell me, I would love to hear
Well, in the sprite utils extension (it’s super useful, download it if you haven’t), there’s a block that lets you run code on a specific sprite every specified period of time. You can put all your animation frames as individual images in an array, and every time that code runs, you change the image to the next image in the array, and then apply that sprite effect again. Since the code can run at a custom interval, this is basically animation. Hope that made sense!