/* * x == row * y == column */ private void _assembleTextureAtlas(CTextureAtlas textureAtlas, int xStart = 0, int yStart = 0, bool reverse = false) { int xStartHold = xStart; int yStartHold = yStart; for (int y = 0; y <= _fixedHeight - 1; y++, yStart++) { xStart = xStartHold; for (int x = 0; x <= _fixedWidth - 1; x++, xStart++) { //NOW the math is completely fine! :) //The math is completely fine. //this math seems a bit iffy due to the cellspacing, but we'll see how it goes! -Steve int x0 = 0; int y0 = 0; if (reverse) { x0 = _fixedWidth - 1 - x; y0 = _fixedHeight - 1 - y; } else { x0 = x; y0 = y; } textureAtlas._textureAtlas[x0, y0] = new Rectangle ((textureAtlas.FrameWidth + CellSpacing) * xStart, (textureAtlas.FrameHeight + CellSpacing) * yStart, textureAtlas.FrameWidth, textureAtlas.FrameHeight); } } }
public static void addTexture(string textureName, CTextureAtlas atlas) { if (!textures.ContainsKey(textureName)) { textures.Add(textureName, atlas); } }
public CSprite(CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, params VertexPositionColor[] vertices) : base(shader, vertices) { _imageAtlas = atlas; _size = new Rectangle(0,0, atlas.FrameWidth, atlas.FrameHeight); _name = _imageAtlas.sourceImage.Name; _flipH = flipH; _flipV = flipV; _totalFrames = atlas.tileXCount * atlas.tileYCount; }
public CSprite(string atlasName, CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, params VertexPositionColor[] vertices) : base(shader, vertices) { _imageAtlas = atlas; _atlasName = atlasName; _size = new Rectangle(0, 0, atlas.FrameWidth, atlas.FrameHeight); _name = _imageAtlas.sourceImage.Name; _flipH = flipH; _flipV = flipV; _totalFrames = atlas.tileXCount * atlas.tileYCount; }
private void init(string atlasName, CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, bool isEffect = false, int rotation = 0, params VertexPositionColor[] vertices) { _imageAtlas = atlas; _atlasName = atlasName; _size = new Rectangle(0, 0, atlas.FrameWidth, atlas.FrameHeight); _name = _imageAtlas.sourceImage.Name; _flipH = flipH; _flipV = flipV; _totalFrames = atlas.tileXCount * atlas.tileYCount; _isEffect = isEffect; _rotation = rotation; }
public CSprite(string atlasName, CTextureAtlas atlas, Effect shader = null, bool flipH = false, bool flipV = false, bool isEffect = false, params VertexPositionColor[] vertices) : base(shader, vertices) { init(atlasName, atlas, shader, flipH, flipV, isEffect, 0, vertices); }
public void clean() { _imageAtlas = null; }
/* * x == row * y == column */ private void _assembleTextureAtlas(CTextureAtlas textureAtlas, int xStart = 0, int yStart = 0) { int xStartHold = xStart; int yStartHold = yStart; for (int y = 0; y <= _fixedHeight - 1; y++, yStart++) { xStart = xStartHold; for (int x = 0; x <= _fixedWidth - 1; x++, xStart++) { //NOW the math is completely fine! :) //The math is completely fine. //this math seems a bit iffy due to the cellspacing, but we'll see how it goes! -Steve textureAtlas._textureAtlas[x,y] = new Rectangle ((textureAtlas.FrameWidth + CellSpacing) * xStart, (textureAtlas.FrameHeight + CellSpacing) * yStart, textureAtlas.FrameWidth, textureAtlas.FrameHeight); } } }
/* * x == row * y == column */ private void _assembleTextureAtlas(CTextureAtlas textureAtlas) { for (int y = 0; y <= (textureAtlas.SourceImage.Bounds.Height / textureAtlas.FrameHeight) - 1; y++) { for (int x = 0; x <= (textureAtlas.SourceImage.Bounds.Width / textureAtlas.FrameWidth) - 1; x++) { textureAtlas._textureAtlas[x,y] = new Rectangle (textureAtlas.FrameWidth * x, textureAtlas.FrameHeight * y, textureAtlas.FrameWidth + textureAtlas.CellSpacing, textureAtlas.FrameHeight + textureAtlas.CellSpacing); } } }