From a9c6266a3f2540d825d7dd88febb67961e03f885 Mon Sep 17 00:00:00 2001 From: Daniel Sperl Date: Tue, 18 Nov 2014 11:40:12 +0100 Subject: [PATCH] added 'setQuad' method to QuadBatch class --- starling/src/starling/display/QuadBatch.as | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/starling/src/starling/display/QuadBatch.as b/starling/src/starling/display/QuadBatch.as index f2ed3ce44..d65622689 100644 --- a/starling/src/starling/display/QuadBatch.as +++ b/starling/src/starling/display/QuadBatch.as @@ -309,7 +309,7 @@ package starling.display mSyncRequired = true; mNumQuads++; } - + /** Adds another QuadBatch to this batch. Just like the 'addQuad' method, you have to * make sure that you only add batches with an equal state. */ public function addQuadBatch(quadBatch:QuadBatch, parentAlpha:Number=1.0, @@ -427,7 +427,20 @@ package starling.display mSyncRequired = true; } - + + /** Replaces a quad or image at a certain index with another one. */ + public function setQuad(quadID:Number, quad:Quad):void + { + var matrix:Matrix = quad.transformationMatrix; + var alpha:Number = quad.alpha; + var vertexID:int = quadID * 4; + + quad.copyVertexDataTransformedTo(mVertexData, vertexID, matrix); + if (alpha != 1.0) mVertexData.scaleAlpha(vertexID, alpha, 4); + + mSyncRequired = true; + } + /** Calculates the bounds of a specific quad, optionally transformed by a matrix. * If you pass a 'resultRect', the result will be stored in this rectangle * instead of creating a new object. */