It looks like you're new here. If you want to get involved, click one of these buttons!
From what I know sprite sheets save memory used or so I've heard. Wouldn't adding sprite sheet support be beneficial? How do you animate something in codea without a sprite sheet? Is it just redrawing the scene and the sprite being a different image in the animation?
Comments
today it's roll-your-own , or dig through the forums and find someone else's.
Try using meshes, and setting the texture coordinates...
That's a good idea. Someone make a sprite sheet demo. I'm still trying to understand all these matrices and viewports.
Sprite sheets in codea don't save any memory.
Codea uses a texture atlas for all textures (works just like a sprite sheet), but the issue some people face is speed. The idea being that managing your own sprite sheet will be faster than the inbuilt lookup of the entire texture atlas.
But I have to say just calling each 'image' to draw for each frame is fast enough in my experience.
Here's a demo of an animation from a sprite sheet using meshes. You probably want to ship out the sprite handling to a separate class, but this is just to demo the concept.
You can get the sprite sheet here (hopefully!)
http://db.tt/eMJa1tsS
Could't get the sheet, though i tried from my ipad and i wasn't logged in. Your public link does not go to your account.
Hmmm not sure how to post the link then
Ok this should now work. Have edited the original post above too
http://db.tt/eMJa1tsS
I could copy and paste it on my ipad. Thank you for the really helpfull example.
Hi all,
I tried this sample and it works fine but I get some artifacts at the top and bottom of the animated sprite in the form of a thin horizontal line. It's not that noticeable with the Zombie example since the colours are dark, but when I tried it with a more colourful image it was more noticeable.
Has anyone got an idea why it might be happening?
Paul.
If your running on a retina device then it might be due to the texture bleeding in from the edges. This is a common problem on a lot of high resolution graphic devices and the reason why texturepacker and similar tools allow for a degree of padding between elements - try shifting your texture u.v coords in by half a pixel
Yes, i'm running on iPad Air 1. You're also correct that my sprite sheet doesn't have any padding between elements. I'll try and fix that first in the sprite sheet image.
Many thanks!
@osullivp You could also try noSmooth() to disable the smoothing that causes bleeding, but your graphics will be pixelated (I would assume that would be fine, people don't typically use high-res spritesheets).
Here's a version saving each image in a table. Tap the screen to move thru the images. It's possible the artifacts in the other code is caused by capturing some of the image above or below the current image.
@dave1707 there's something wrong with your code. the tab[i] rendering looks terrible, and isn't extracting properly from the original sprite sheet. can you post a screen shot of what yours is supposed to look like when working properly?
@matkatmusic What is the size of the ZombieSpriteSheet that's in your Dropbox. It should have a size of 80 x 80 . That's what this code is set up for. If it still doesn't work, maybe I'll change the code to read the sheet from the link given above.
@matkatmusic As for what it's supposed to look like, the whole sprite sheet will be on the left of the screen and an individual character the same size of the sprite sheet will be on the right. Each time you tap the screen, the next character in the sprite sheet will be shown.
i see that, it's just way zoomed in on the right. like, i see a partial view of the dude's legs.
I fixed it. the spritesheet was 160x160
the sprite sheet in question was one of those dropbox links above. not sure which one. it's whichever one was 160x160
@matkatmusic I guess that would explain the problem. I was looking at my code again and noticed that there's an error in it. The column of sprites on the very right of the sprite sheet aren't being shown. I guess I could fix it, but every sprite sheet is going to have it own unique code setup anyways.
Here’s a zip of the @matkatmusic version.
Sprite sheet included so no one has to download nothin’.
I also scaled the images up so they are easier to see.