示例#1
0
        /// <summary>
        /// Creates an object with a sprite component and adds that sprite to the
        /// ammonomicon for later use.
        /// </summary>
        public static GameObject CreateSpriteObject(string name, string resourcePath)
        {
            GameObject spriteObject = SpriteBuilder.SpriteFromResource(_ItemCollection, resourcePath);

            spriteObject.name = name;
            return(spriteObject);
        }
示例#2
0
        /// <summary>
        /// Returns an object with a tk2dSprite component with the texture provided
        /// </summary>
        public static GameObject SpriteFromTexture(tk2dSpriteCollectionData collection, Texture2D texture, string spriteName)
        {
            GameObject obj    = new GameObject();
            tk2dSprite sprite = obj.AddComponent <tk2dSprite>();

            int id = SpriteBuilder.AddSpriteToCollection(spriteName, collection);

            sprite.SetSprite(collection, id);
            sprite.SortingOrder = 0;
            sprite.UsesSpriteCollection(collection);

            return(obj);
        }
示例#3
0
        public static GameObject ItemSpriteFromResource(string spriteName)
        {
            string extension    = !spriteName.EndsWith(".png") ? ".png" : "";
            string resourcePath = spriteName + extension;

            var texture = ResourceExtractor.GetTextureFromResource(resourcePath);

            if (texture == null)
            {
                return(null);
            }

            return(SpriteBuilder.SpriteFromTexture(_ItemCollection, texture, resourcePath));
        }
示例#4
0
 /// <summary>
 /// Adds a sprite definition to the Ammonomicon sprite collection
 /// </summary>
 /// <returns>The spriteID of the defintion in the ammonomicon collection</returns>
 public static int AddSpriteToAmmonomicon(tk2dSpriteDefinition spriteDefinition)
 {
     return(SpriteBuilder.AddSpriteToCollection(spriteDefinition, _AmmonomiconCollection));
 }