示例#1
0
    /// <summary>
    /// Sets sprite by identifier from the new collection.
    /// </summary>
    public void SetSprite(tk2dSpriteCollectionData newCollection, int newSpriteId)
    {
        bool switchedCollection = false;

        if (Collection != newCollection)
        {
            Collection.RemoveRetain(this);
            newCollection.AddRetain(this);
            Collection         = newCollection;
            _spriteId          = -1;    // force an update, but only when the collection has changed
            switchedCollection = true;
        }

        spriteId = newSpriteId;

        if (switchedCollection)
        {
            UpdateMaterial();
        }
    }