Tag Info

Hot answers tagged

50

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 ...


14

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 ...


10

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.)


9

The problem with using texture atlases and adjacent texels leaking has to do with the way linear texture filtering works. For any point in the texture that is not sampled exactly at the center of a texel, linear sampling will sample 4 adjacent texels and compute the value at the location you asked as the weighted (based on distance from the sample point) ...


9

To do this effectively without 'generating all possible options,' you're going to want to use a layering approach... at least in theory, even if in practice you eventually collapse the layered textures to a single sprite for draw-call reduction, which I think you should and will detail later. The layering approach involves having a sprite set for all your ...


8

It is possible that the total size of a sprite sheet will affect performance of your game in some reasonably small fashion. Extremely small sprite sheets generally mean that you have many, which in turn implies many state changes, and frequent state changes are not good for performance. Extremely large sprite sheets consume more GPU RAM, and if they need to ...


6

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 ...


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 ...


6

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

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

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 ...


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

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 ...


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

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 ...


5

After spending a week searching the web and checking every related blog post, i found the solution. http://www.denysalmaral.com/2012/04/px-spritesrender-3ds-max-scripted.html This script renders and names the images perfectly, after it i combine them using "GlueIT" Works like a charm, Hope it will help others.


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

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

This is a little different than your object-based approach, but here is the code I'm using to preload tiles from a spritesheet into canvas elements: tileSize = 16; sprites1x1Image = new Image(); sprites1x1Image.src = 'images/sprites-1x1.png'; sprites1x1Image.onload = function() { sprites1x1 = []; var names1x1 = [ 'character1', 'character2', ...



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