/////////////////////////////////////////////////////// // // Methods // /////////////////////////////////////////////////////// /// <summary> /// Attaches a sprite to the batch using a batch element /// </summary> /// <param name="newSprite"></param> /// <param name="newId"></param> /// <returns></returns> public SpriteBatchElement Attach(Sprite newSprite, uint newId) { SpriteBatchElement newElement = this.BaseAttach(newId) as SpriteBatchElement; newElement.SetSprite(newSprite); return(newElement); }
// Prefills the pool with the given number of elements protected override void FillReserve(int fillSize) { for (int i = fillSize; i > 0; i--) { SpriteBatchElement newNode = new SpriteBatchElement(); this.reservedList.PushFront(newNode); } }
/// <summary> /// Detaches a sprite from the batch /// </summary> /// <param name="oldName"></param> /// <param name="oldId"></param> /// <returns></returns> public bool Detach(Sprite.Name oldName, uint oldId) { SpriteBatchElement oldNode = this.BaseDetach(oldName, oldId) as SpriteBatchElement; if (oldNode == null) { return(false); } oldNode.Reset(); return(true); }
/// <summary> /// Draws all sprites in the batch /// </summary> public void Draw() { SpriteBatchElement itr = this.activeList.Head as SpriteBatchElement; while (itr != null) { // Draw one sprite itr.Draw(); // Next node itr = itr.next as SpriteBatchElement; } }