public static void draw(Sprite sprite, Camera camera = null) { if (!sprite.visible) return; //Bind tileset texture sprite.tileset.bind(); Util.Rect rect = sprite.rect; if (camera != null) camera.worldToScreen(ref rect); if (!Util.Maths.isRectVisible(rect, targetWidth, targetHeight)) return; //Bind to GL_TEXTURE0 and GL_TEXTURE1 shaderIndexedBitmapSprite["indexTexture"].SetValue(0); shaderIndexedBitmapSprite["paletteTexture"].SetValue(1); shaderIndexedBitmapSprite["orthoMatrix"].SetValue( Util.Maths.matrixPixelProjection(rect, targetWidth, targetHeight)); shaderIndexedBitmapSprite["uvMatrix"].SetValue( sprite.uvMatrix(sprite.tileset.width, sprite.tileset.height)); //Draw LowLevelRenderer.draw(); }
public bool overlaps(Sprite s) { return rect.overlaps(s.rect); }