Skip to content

Draw.text() eats up a LOT of memory. #104

@DelishusCake

Description

@DelishusCake

Draw.text creates a new Text graphic every time it is called. Can be fixed pretty simply with caching:

         /**
         * Draws text.
         * @param   text        The text to render.
         * @param   x       X position.
         * @param   y       Y position.
         * @param   options     Options (see Text constructor).
         */
        public static function text(text:String, x:Number = 0, y:Number = 0, options:Object = null):void
        {
            if (!_textCache[text]) _textCache[text] = new Text(text, x, y, options);
            _textCache[text].x = x;
            _textCache[text].y = y;
            _textCache[text].render(_target, FP.zero, _camera);
        }

        // Drawing information.
        /** @private */ private static var _textCache:Object = { };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions