예제 #1
0
        protected override void OnFrameChange()
        {
            _frame = _resource.frames[currentFrame];

            transformDirty = true;
            colorDirty     = true;
        }
예제 #2
0
 protected override void ResetDisplayObject()
 {
     _frame          = null;
     _scrollRect     = null;
     _flipHorizontal = false;
     _flipVertical   = false;
     base.ResetDisplayObject();
 }
예제 #3
0
        internal SheetFrame[] GetFrames()
        {
            if (description == null)
            {
                var textureInfo = GetTexture(path);
                return(new SheetFrame(textureInfo.texture, Vector2.zero, textureInfo.scale).AsArray());
            }

            var sheetFrames = new List <SheetFrame>(description.Length);

            for (var i = 1; i < description.Length; i++)
            {
                var line = description[i];

                if (line == HD_TAG)
                {
                    _isHd = true;
                    continue;
                }

                if (line.StartsWith(FRAME_TAG, StringComparison.Ordinal))
                {
                    var textureInfo = GetTexture(path);
                    var parts       = line.Substring(FRAME_TAG.Length).Split(",");

                    var frame = new SheetFrame(
                        textureInfo.texture,
                        new Rect(
                            Convert.ToInt32(parts[0]),
                            Convert.ToInt32(parts[1]),
                            Convert.ToInt32(parts[2]),
                            Convert.ToInt32(parts[3])),
                        new Vector2(
                            Convert.ToInt32(parts[4]),
                            Convert.ToInt32(parts[5])),
                        textureInfo.scale);

                    sheetFrames.Add(frame);
                }
            }

            return(sheetFrames.ToArray());
        }
예제 #4
0
        protected void AddQuad(QuadCollection quads, SheetFrame frame,
                               ref Vector2 charPos, ref Vector2 anchor, ref ColorTransform colorMult)
        {
            var texture       = frame.texture;
            var textureBounds = frame.textureBounds;

            Matrix4x4 localMatrix, globalMatrix;
            var       letterScale    = fontScale * frame.textureScale;
            var       letterScaleVec = new Vector2(letterScale, letterScale);

            MatrixUtil.Create2D(ref letterScaleVec, 0, ref charPos, out localMatrix);
            MatrixUtil.Multiply(ref localMatrix, ref compositeMatrix, out globalMatrix);

            var textureSize = new Vector2(texture.width, texture.height);

            var spriteQuad = new SpriteQuad();

            spriteQuad.UpdateTransform(ref globalMatrix, ref textureBounds, ref textureSize, ref anchor);
            spriteQuad.UpdateColor(ref colorMult);

            quads.Add(spriteQuad);
        }
예제 #5
0
 public FlashSprite(Texture2D texture)
 {
     _frame = new SheetFrame(texture);
 }