Tag Info

Hot answers tagged

49

My suggestion Too many small PNGs will add a lot of network overhead (because of the size of the HTTP requests, but also the PNG header, and, probably even more importantly, the inability to compress efficently). On the other hand, one very large PNG has the drawbacks that it takes some time to load, and needs to stay permanently in memory (40 megabytes for ...


13

You need to set the sampler state. The default for SpriteBatch is SamplerState.LinearClamp (ie: linear interpolation - the smooth/blurry one). Choose one of the SpriteBatch.Begin calls that takes a SamplerState and pass in SamplerState.PointClamp (selects the pixel at that precice "point").


12

From the problems that you are having I recommend that you do the following: First, work with layers and folders. It really does help, Group individual sprites together in folders so that you can move the whole of them around and parts that are replicated should exist on seperate layers. (So if there is a sword or something it should be on a layer, eyes ...


9

You can always make looong buffer "vertex;texcoord" repeat. And just use indices how you said. It is propably most easy and kinda similar to what you know. If you want to save some memory. There is pretty neat solution and it is to have one sprite in buffer with unite texcoords and create UVs transformation matrix and send it to your shader and multiply ...


9

I've been using TexturePacker to create sprites from a folder of PNG images. I'm porting a game originally developed in Flash, so I'm simply exporting each frame of the MovieClip to png and then importing those images in Texture Packer. Another similar tool is Zwoptex (The latter is Mac software, but TP has a version for Windows too.)


6

ImageMagick's montage command can do this. For example, to compile a bunch of irregular-sized sprites into a sheet of 32 × 32 pixel tiles, you can do: montage sprite*.png -geometry "32x32>+0+0" -background none sheet.png The -geometry "32x32>+0+0" option above will resize all the sprites to 32 × 32 pixels (adding transparent space ...


5

One solution would just be to pack as much as you can on a single sheet: Texture packing algorithm Part of the data that results from that is where the sprite is in the texture and how big it is, so you can use that information to draw the portion of the image that you need for a given sheet. Be sure to not use mipmaps, though.


5

You're telling it how many rows and columns it has. Simply also tell it how many sprites it has on it. Therefore allowing you to skip over the final sprites as you loop. (I assume you know how to index rows and columns with / and %? If not then this will tell you.) So for something like this: const int rowCount = 3; const int columnCount = 6; for(int i = ...


5

Since you wont answer my comment above I will give you a few options. 1 . Use a tilesheet that spans multiple Textures. 2 . Use a List<Texture2D> You can make this easier by making a png sequence with BigImage0001,BigImage0001,BigImage0001.... Import all of those. Make a method that takes a name, Trailing numbers, and total frames. Have it ...


5

Some popular flash game engines (eg. flixel) use sprite-sheets for sprite-animations. This is mainly because they also implemented a bitmap-based rendering engine which doesn't use the native flash display-classes like "Sprite", "MovieClip" for each object but rather a big bitmap-image where stuff is drawn onto using pixel-operations. Using a bitmap-based ...


5

One huge spritesheet is (likely) going to give you better performance, simply because one of the biggest causes of lag is the round trip from browser request to server to browser. 10,000 HTTP calls is going to take much, much longer than 1 HTTP call that returns a file that is 10,000 bigger. There might be other things you can use to decrease lag, ...


5

First of all I recommend separating it so that the frame is updated in the Update method instead of the Draw method. That's because XNA is free to skip a few Draw calls to make up for lost time when the game runs slowly, but not Update, so it should run more consistently. It's also a better idea to leave the Draw method just for rendering, and putting any ...


5

There's a tool called Atlas Image Packer. It'll do as you want, take a number of images and produce a single large image that contains all the other images. Also, I wish I had your problem. A graphics designer producing images for me.


5

Usually there is nothing like "cut out every sprite", because you aren't working with the data itself, but just with references. The hero sprite is not known to the application as "[...insert huge data array here...]" but as "Position 0,64 with size of 48x64 on Texture 5". And that data is trivial to generate nothing you could or should sweat over. For GPU ...


5

Unless you have a high frame rate and very low size requirements, the number of sprites you're talking about won't matter compared to, say, the audio files (especially music!). If game size was the only requirement, I'd say go with pre-baked animations. As long as you only have ten weapons, either way will be roughly the same amount of work for the artist; ...


5

It may not be a direct answer to your question, but it is my advice ;) Do not move your sprites based on the number of frames, but do it based on wall-clock time. Why? Oh well, it is very easy for a game to have a variable frame-rate, so, imagine your character is jumping from platform to platform, and the PC lags for some reason. If his movement is based ...


5

The idea behind condensing sprite sheets is that the actual loading of the file (the sprite sheet) is considered heavy lifting in any game system. Imagine you have this system where all your data types are highly optimized and all these algorithms to reduce the memory foot print but then you have to constantly bottle-neck memory with loading and parsing ...


4

Breaking down what you want to do into solutions: You need some way to watch the file system to trigger this process. Polling it or using FileSystemWatcher come to mind as appropriate solutions. (If this is for some kind of editor, I personally find assigning a hotkey is preferable.) You need a way to actually create sprite sheets. Googling around will ...


4

Don't make a sprite sheet. You are going to want to just create a List<Texture2D> with each frame of animation inside. It will be much more efficient on video memory usage, as you are only passing each frame of animation when the video card needs it, instead of loading everything in at once when you at most will be displaying one frame at a time. ...


4

If you have 3D models there is a program made by EnvyGames, SpriteWorks, which will make 2D sprite sheets out of the models for you. Allows you to play animations and customize a bunch of stuff. I think it's a bit pricey for what it is, $49.99. Here is a tutorial on how to use SpriteWorks Creating Sprites from 3D Models - EnvyGames


4

You need a bigger image, or a (slightly) smaller ball. It is a known issue that raster image algorithms tend to create ugly aliases on round(ish) objects, if they touch the 'edges'. The easiest fix is adding a small 'background space' to all your balls. So for each of your generated tiles, instead of this: +-----+ |.000.| |00000| |00000| |00000| |.000.| ...


4

How is the rotated sprite generated? Are these screenshots of a rotating 3D model? The facing angle could be off due to the camera perspective of the 3D modeling tool. Isometric perspective is not an accurate representation of the 3D space. Stuff far away from the 'camera' does not get smaller. If you just want a quick fix. Solution 2 might be difficult ...


4

You can perform analysis on the image to locate the bounding rectangles of each sprite, sort those bounding rectangles (perhaps by increasing minimum X, then Y) and you'll have a set of bounding regions that correspond to the frames of the sprite sheet. Because this process can be relatively expensive, you will probably want to do this offline, for example ...


4

Most sprite sheets of non-identical dimensions usually have some kind of meta data with where the anchor of the sprite is. There are a lot of tools that do things like strip out full alpha pixels and give you the data you need so that this data isn't manually generated. If you don't have this meta data you have to author it yourself. The most accurate way ...


4

Swapping textures will kill your performance. Modern hardware has only gotten more susceptible to this problem, not less, as the speed and power of the shader units and video RAM are growing much faster than the speed increases of the bus between system RAM and the GPU. The only sane approach is to cut down your texture sizes, or generate procedural ...


4

Using a sprite sheet reduces the need for the computer to load a new/different image in order to draw on the screen. Here is an article which shows the performance differences in XNA (in the emulator and on a device) as well as the animation class used.


4

Hard to say without actually profiling it but some information that might help: When you do not use the rotation parameter or leave it as 0: The rotation transformation is still applied, but SpriteBatch handles it as a special case which costs one Math.Cos and one Math.Sin less for each sprite being drawn, because it already knows that the sine and ...


3

The answer to why to use a sprite-sheet has already been answered in this question. How you use a sprite-sheet in your game is quite simple. Usually you have a class that keeps track of the elapsed time and displays another frame once a given threshold has been reached (eg. if 1/25th of a second has passed or similar). How to display a new frame depends on ...


3

If you really want to do this in code (instead of converting the sprite-sheets you have), I suggest you use the BitmapData:draw method to draw an existing BitmapData object (your Sprite) into another. When using the draw method you can also supply a transform matrix to use, so basically you do the following: Create a new BitmapData object with the same ...


3

Write some Actionscript to generate the spritesheets for you, and either use the BitmapData in flash, or use as3corelib to export the pngs for you. If your originals are vector, it is probably best for flash to take care of the rendering at different rotations/scales, as rotating a png is destructive, and lowers the quality. If you are doing a game in ...



Only top voted, non community-wiki answers of a minimum length are eligible