Ejemplo n.º 1
0
        internal override Vector2X[] adjustUVs(Vector2X[] uv, Vector2X[] result = null)
        {
            SubTextureX texture = this;

            _transform2X.identity();
            while (texture != null)
            {
                _transform2X = Transform2X.multiply(_transform2X, texture.transform);
                texture      = texture.parent as SubTextureX;
            }

            Vector2X item;

            if (result == null)
            {
                result = new Vector2X[4];
            }
            for (int i = 0; i < 4; i++)
            {
                item      = uv[i];
                result[i] = _transform2X.transformVector(item);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override void render(RenderSupport support, float parentAlpha)
        {
            float alpha       = parentAlpha * this.alpha;
            int   numChildren = mChildren.Count;


            for (int i = 0; i < numChildren; ++i)
            {
                DisplayObjectX child = mChildren[i];

                if (child.hasVisibleArea)
                {
                    child.sceneTransform = Transform2X.multiply(mSceneTransform, child.transform);
                    support.blendMode    = child.blendMode;

//                    if (filter)
//                    {
//                        filter.render(child, support, alpha);
//                    }
//                    else
//                    {
                    child.render(support, alpha);
//                    }

                    support.blendMode = blendMode;
                }
            }
        }
Ejemplo n.º 3
0
        public DisplayObjectX()
        {
            mX         = mY = mPivotX = mPivotY = 0.0f;
            mRotation  = 0;
            mScaleX    = mScaleY = mAlpha = 1.0f;
            mVisible   = true;
            mTouchable = false;
            mBlendMode = BlendModeX.AUTO;

            mTransform = new Transform2X();

            mSceneTransform       = new Transform2X();
            mSceneInvertTransform = new Transform2X();
        }
Ejemplo n.º 4
0
        public SubTextureX(TextureX parentTexture, RectangleX region, RectangleX frame = null)
        {
            if (region == null)
            {
                region = new RectangleX(0, 0, parentTexture.width, parentTexture.height);
            }

            mParent = parentTexture;
            mFrame  = frame != null?frame.clone() : null;

            mWidth  = region.width;
            mHeight = region.height;


            mTransform = new Transform2X();

            mTransform.scale(region.width / mParent.width,
                             region.height / mParent.height);
            mTransform.translate(region.x / mParent.width,
                                 -1 - region.y / mParent.height);
        }
Ejemplo n.º 5
0
        public Transform2X getTransformationMatrix(DisplayObjectX targetSpace, Transform2X resultMatrix = null)
        {
            DisplayObjectX commonParent;
            DisplayObjectX currentObject;

            if (resultMatrix != null)
            {
                resultMatrix.identity();
            }
            else
            {
                resultMatrix = new Transform2X();
            }

            if (targetSpace == this)
            {
                return(resultMatrix);
            }
            else if (targetSpace == mParent || (targetSpace == null && mParent == null))
            {
                resultMatrix.copyFrom(transform);
                return(resultMatrix);
            }
            else if (targetSpace == null || targetSpace == stage)
            {
                // targetCoordinateSpace 'null' represents the target space of the base object.
                // -> move up from this to base

                currentObject = this;
                while (currentObject != targetSpace)
                {
                    resultMatrix  = Transform2X.multiply(resultMatrix, currentObject.transform);
                    currentObject = currentObject.mParent;
                }

                return(resultMatrix);
            }
            else if (targetSpace.mParent == this) // optimization
            {
                targetSpace.getTransformationMatrix(this, resultMatrix);
                resultMatrix.invert();

                return(resultMatrix);
            }

            // 1. find a common parent of this and the target space
            commonParent = findCommonParent(this, targetSpace);
            // 2. move up from this to common parent

            currentObject = this;
            while (currentObject != commonParent)
            {
                resultMatrix  = Transform2X.multiply(resultMatrix, currentObject.transform);
                currentObject = currentObject.mParent;
            }

            if (commonParent == targetSpace)
            {
                return(resultMatrix);
            }
            // 3. now move up from target until we reach the common parent

            sHelperTransform.identity();
            currentObject = targetSpace;
            while (currentObject != commonParent)
            {
                sHelperTransform = Transform2X.multiply(sHelperTransform, currentObject.transform);
                currentObject    = currentObject.mParent;
            }

            // 4. now combine the two matrices

            sHelperTransform.invert();
            resultMatrix = Transform2X.multiply(resultMatrix, sHelperTransform);

            return(resultMatrix);
        }