Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added optional blending enable/disable to RenderLayerSpriteBatchImpl

  • Loading branch information...
commit ad3bf55dad7be6b49760e3cd6e6cf08aa903a71a 1 parent 227f4a8
Ariel Coppes authored
18  commons-gdx-artemis/src/main/java/com/gemserk/commons/artemis/systems/RenderLayerSpriteBatchImpl.java
@@ -39,8 +39,14 @@
39 39
 	private Factory factory;
40 40
 
41 41
 	private boolean ownsSpriteBatch;
  42
+	
  43
+	private boolean blending;
42 44
 
43  
-	public RenderLayerSpriteBatchImpl(int minLayer, int maxLayer, Libgdx2dCamera camera, SpriteBatch spriteBatch) {
  45
+	public void setBlending(boolean blending) {
  46
+		this.blending = blending;
  47
+	}
  48
+	
  49
+	public RenderLayerSpriteBatchImpl(int minLayer, int maxLayer, Libgdx2dCamera camera, SpriteBatch spriteBatch, boolean blending) {
44 50
 		this.camera = camera;
45 51
 		this.spriteBatch = spriteBatch;
46 52
 		// this.orderedByLayerEntities = new OrderedByLayerEntities(minLayer, maxLayer);
@@ -48,6 +54,11 @@ public RenderLayerSpriteBatchImpl(int minLayer, int maxLayer, Libgdx2dCamera cam
48 54
 		this.enabled = true;
49 55
 		this.factory = new Factory();
50 56
 		this.ownsSpriteBatch = false;
  57
+		this.blending = blending;
  58
+	}
  59
+	
  60
+	public RenderLayerSpriteBatchImpl(int minLayer, int maxLayer, Libgdx2dCamera camera, SpriteBatch spriteBatch) {
  61
+		this(minLayer, maxLayer, camera, spriteBatch, true);
51 62
 	}
52 63
 
53 64
 	public RenderLayerSpriteBatchImpl(int minLayer, int maxLayer, Libgdx2dCamera camera) {
@@ -90,6 +101,11 @@ public void render() {
90 101
 
91 102
 		RandomAccessMap<Entity, EntityComponents> entityComponents = factory.entityComponents;
92 103
 
  104
+		if (blending && !spriteBatch.isBlendingEnabled())
  105
+			spriteBatch.enableBlending();
  106
+		else if (!blending && spriteBatch.isBlendingEnabled())
  107
+			spriteBatch.disableBlending();
  108
+		
93 109
 		spriteBatch.begin();
94 110
 		for (int i = 0; i < orderedByLayerRenderables.size(); i++) {
95 111
 			Renderable renderable = orderedByLayerRenderables.get(i);

0 notes on commit ad3bf55

Please sign in to comment.
Something went wrong with that request. Please try again.