Esempio n. 1
0
        public void batchQuad(Quad quad, float parentAlpha, TextureX texture)
        {
            if (mQuadBatches[mCurrentQuadBatchID].isStateChange(quad, parentAlpha, 1, texture))
            {
                finishQuadBatch();
            }

            mQuadBatches[mCurrentQuadBatchID].addQuad(quad, parentAlpha, texture);
        }
Esempio n. 2
0
        public Image(TextureX texture)
        {
            _texture = texture;

            RectangleX frame  = _texture.frame;
            float      width  = frame != null ? frame.width : texture.width;
            float      height = frame != null ? frame.height : texture.height;

            this.init(width, height);
        }
        public Scale9Image(TextureX texture, RectangleX centerRect)
        {
            _tW   = texture.width;
            _tH   = texture.height;
            _grid = centerRect;

            _width  = _tW;
            _height = _tH;

            _tl = new Image(TextureX.fromTexture(texture, new RectangleX(0, 0, _grid.x, _grid.y)));

            _tc = new Image(TextureX.fromTexture(texture, new RectangleX(_grid.x, 0, _grid.width, _grid.y)));

            _tr = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x + _grid.width, 0, texture.width - (_grid.x + _grid.width), _grid.y)));

            _cl = new Image(TextureX.fromTexture(texture, new RectangleX(0, _grid.y, _grid.x, _grid.height)));

            _cc = new Image(TextureX.fromTexture(texture, new RectangleX(_grid.x, _grid.y, _grid.width, _grid.height)));

            _cr = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x + _grid.width, _grid.y, texture.width - (_grid.x + _grid.width), _grid.height)));

            _bl = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(0, _grid.y + _grid.height, _grid.x, texture.height - (_grid.y + _grid.height))));

            _bc = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x, _grid.y + _grid.height, _grid.width,
                                                                texture.height - (_grid.y + _grid.height))));

            _br = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x + _grid.width, _grid.y + _grid.height,
                                                                texture.width - (_grid.x + _grid.width), texture.height - (_grid.y + _grid.height))));

            _tc.x = _cc.x = _bc.x = _grid.x;
            _cl.y = _cc.y = _cr.y = _grid.y;

            addChild(_tl);
            addChild(_tc);
            addChild(_tr);

            addChild(_cl);
            addChild(_cc);
            addChild(_cr);

            addChild(_bl);
            addChild(_bc);
            addChild(_br);

            apply9Scale(_tW, _tH);
        }
        internal bool isStateChange(Quad quad, float parentAlpha, int numQuads = 1, TextureX texture = null)
        {
            if (mNumQuads == 0)
            {
                return(false);
            }
            else if (mNumQuads + numQuads > MAX_NUM_QUADS)
            {
                return(true);
            }

            if (_texture != texture.nativeTexture)
            {
                return(true);
            }

            return(false);
        }
        internal void addQuad(Quad quad, float parentAlpha, TextureX texture)
        {
            if (mNumQuads == 0)
            {
                this._shader = quad.shader;
                if (texture != null)
                {
                    this._texture = texture.nativeTexture;
                }
            }

            quad.copyVertexDataTo(vertices, uvs);

            for (int i = 0; i < 4; i++)
            {
                colors.Add(quad.color);
            }

            mNumQuads++;
        }
        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);
        }
Esempio n. 7
0
 public static TextureX fromTexture(TextureX texture, RectangleX region = null, RectangleX frame = null)
 {
     return(new SubTextureX(texture, region, frame));
 }