Images & Animations
Blitz3D Forums/Blitz3D Beginners Area/Images & Animations
| ||
Hi, getting to grips with using sprites and have a couple of questions. 1) I'm doing a LoadAnimImage and have used flag=2 for dynamic as this is the fastest when coming to plot it on screen. Yes? Also in the documentation it says frames should be horizontally placed, i.e. a very wide sprite. What I've done is load a 360 by 720 jpeg using LoadAnimImage with frame size 36 by 36 (i.e. 200 frames) and when ploting it does the correct frame even though I have not got them all placed horizontally. Is this 'feature' set or should I make it a horizontal monster? 2) Using the above jpeg (i.e. no mask etc) I find that DrawImage & DrawRect take the same time to draw the frames. Should I just use DrawImage or maybe DrawRect? Thanks in advance Marg |
| ||
1) Yup. That's perfectly okay. Quote from this article on my website: Blitz's LoadAnimImage command doesn't care how your animation frames are positioned within the image, as long as it knows how many frames there are and what size each one is.. You could give it.. ![]() ![]() ![]() .. or even.. ![]() .. (as long as the last two frames are blank) and Blitz will produce the same results. 2) DrawBlock you mean? If there will never be a Masked Transparent pixel in your sprite, then yeah, feel free to use DrawBlock. |
| ||
Just to add a bit... DrawBlock is supposed to be a bit quicker than DrawImage as it doesn't play with the mask colour at all. |
| ||
As for arranging the frames of an animation, while Blitz doesn't care how the frames are laid out, sometimes it's easier for YOU if you arrange the frames a certain way. For example, the first arrangement above (1-12 all in a long string) might be useful if you have one sprite animating over 12 frames. It could help keep it "visually" organized for you. But- in the case where you have say 4 different views of the same sprite- a character walking left, right, up and down, with say 3 frames per direction, arranging it that way would make the image appear somewhat jumbled to YOU. (Remember, Blitz doesn't care) Instead, you could arrange the images as in the THIRD example above, or 4 rows of 3 images each. One row for each direction the sprite walks. That helps keep it more "visually" organized for YOU, while Blitz will load the images the same either way. Whatever works best for you. |
| ||
um... can you mask a jpeg? I thought it was only pngs? seeing as Blitz doesn't handle gifs... Marg, being able to mask a sprite is very handy, cos if you mask it, then you can do better collision testing. The Imagescollide function will check the drawing, not the background, to see if something has hit it. Imagesoverlap, on the other hand, checks for a collision with the whole block. If you got a square sprite, you;re good, otherwise a png with a mask and using Imagescollide to collisiontest is probably the way to go. Note on best file formats: Jpegs use a compression algorithm best suited to photographic images - or any images where tones blur into each other a lot. It stands for Joint Photographic Experts Group: JPEG or .jpg - it was developed expressly for photographs. Portable Network Graphics, or PNG files are very good (good means smallest-filesize-for-quality) for images using areas of simple colour in well-defined blocks. Sprites for example. A photo in a png can be huge while it is small as a jpeg, and a square of white can be huge as a jpeg but tiny as a png. OK, that is webmastering 001 finished :) |
| ||
can you mask a jpeg? I thought it was only pngs? JPEGs don't have masks but there's nothing to stop you converting PNGs into a pair of JPEGs -- one for the image the other for the mask. This will tend to be a lot more compact than PNGs for almost all images (and unless you go for low quality/high compression you won't notice the artifacts). |
| ||
a pair of jpegs smaller than a single png? for photos, not for block colour. Must respectfully differ, podperson. But anyone can test for themeselves. Getting a jpeg to give a pure hue with no artifacts is just NOT its job, thats where bmps and gifs and pngs come in. ![]() ![]() in this example the jpeg is bigger than the png, and its at the lowest possible setting, both the same colour to begin with. ![]() ![]() And where there is blurring, the png is bigger than the jpeg. Rightclick for properties, you can see what I mean. I have not cheated on the settings, I swear :) |