Пример #1
0
    /**
    * Return the TextureDisplay.
    * @example 
    * <listing>
    * var texturedisplay:Object = factory.getTextureDisplay('dragon');
    * </listing>
    * @param    The name of this Texture.
    * @param    The name of the TextureAtlas.
    * @param    The registration pivotX position.
    * @param    The registration pivotY position.
    * @return An Object.
    */
    Object* BaseFactory::getTextureDisplay(const String &textureName, const String &textureAtlasName, Number pivotX, Number pivotY)
    {
        ITextureAtlas* textureAtlas = 0;
        if(!textureAtlasName.empty())
        {
            std::map<String , ITextureAtlas*>::iterator iter = _textureAtlasDic.find(textureAtlasName);
            if(iter != _textureAtlasDic.end())
            {
                textureAtlas = iter->second;
            }
        }
        //if(!textureAtlas && !textureAtlasName)
        //{
        //    for (textureAtlasName in _textureAtlasDic)
        //    {
        //        textureAtlas = _textureAtlasDic[textureAtlasName];
        //        if(textureAtlas.getRegion(textureName))
        //        {
        //            break;
        //        }
        //        textureAtlas = null;
        //    }
        //}
        if(textureAtlas)
        {
            if(isNaN(pivotX) || isNaN(pivotY))
            {
                SkeletonData* data = _dataDic[textureAtlasName];
                if(data)
                {
                    Point *pivot = data->getSubTexturePivot(textureName);
                    if(pivot)
                    {
                        pivotX = pivot->x;
                        pivotY = pivot->y;
                    }
                }
            }

            return generateDisplay(textureAtlas, textureName, pivotX, pivotY);
        }
        return nullptr;
    }